/// <summary> /// 发布已通过版本 /// </summary> /// <param name="authorizerAccessToken"></param> /// <param name="shopId"></param> /// <param name="logDbContext"></param> public APIResult ReleaseVersion(string authorizerAccessToken, ShopWechatOpenAuthorizer item, TemplateInfo tempInfo) { var releaseResult = CodeApi.Release(authorizerAccessToken); //如果发布成功,则将请求的结果写入到数据库中 if (releaseResult.errcode != Senparc.Weixin.ReturnCode.请求成功) { return(Error("发布失败," + releaseResult.errmsg)); } item.IsRelease = true; item.CurrentTemplateUserVersion = item.ReleaseTemplateUserVersion; item.CurrentTemplateId = tempInfo.template_id; item.CurrentTemplateUserDesc = tempInfo.user_desc; db.SaveChanges(); //这里尝试添加二唯码规则 if (hostingEnvironment != null) { var qrCodeResult = CodeApiExt.QRCodeJumpAddPublish(item.ShopId, authorizerAccessToken, hostingEnvironment); if (qrCodeResult.errcode != ReturnCode.请求成功) { return(Error("添加二维码规则失败 ," + qrCodeResult.errmsg)); } } return(Success()); }
public async System.Threading.Tasks.Task <APIResult <CodeResultJson> > ReleaseAsync([FromBody] ShopIdArgsModel args) { if (!args.ShopId.HasValue) { throw new ArgumentNullException("ShopId"); } CheckShopActor(args.ShopId.Value, ShopActorType.超级管理员); var authorizerAccessToken = GetAuthorizerAccessToken(args.ShopId.Value); var result = await CodeApi.ReleaseAsync(authorizerAccessToken.authorizer_access_token); //如果请求成功,则将请求的结果写入到数据库中 if (result.errcode == Senparc.Weixin.ReturnCode.请求成功) { var authorizer = db.Query <ShopWechatOpenAuthorizer>() .Where(m => !m.IsDel) .Where(m => m.ShopId == args.ShopId.Value) .FirstOrDefault(); authorizer.IsRelease = true; await db.SaveChangesAsync(); //这里尝试添加二唯码规则 try { CodeApiExt.QRCodeJumpAddPublish(args.ShopId.Value, authorizerAccessToken.authorizer_access_token, hostingEnvironment); } catch (Exception) { } } return(Success(result)); }
private static string ParseResponse(TulingResponseData response) { var result = string.Empty; var builder = new StringBuilder(); builder.Append(result); foreach (var res in response.Results) { switch (res.ResultType) { case "text": builder.Append(res.Values.Text); break; case "image": builder.Append(CodeApi.Code_Image(res.Values.Image)); break; case "voice": builder.Append(CodeApi.Code_Voice(res.Values.Voice)); break; case "url": builder.Append($" {res.Values.Url} "); break; } } result = builder.ToString(); return(result); }
protected override void Parse() { var root = document.DocumentNode; var query = SearchNodes(root, n => n.Name == "div" && n.ChildAttributes("class").Any(p => p.Value == "xz_cont")); if (query.IsNullOrEmpty()) { return; } var node = query.First(); var imgs = SearchNodes(node, n => n.Name == "img"); if (imgs.IsNullOrEmpty() || imgs.Count < 4) { return; } var msg = node.InnerText; var srcs = imgs.Select(i => CodeApi.Code_Image(i.Attributes.First(a => a.Name == "src").Value) + "\r\n").ToList(); for (var i = 0; i < Dims.Length; i++) { var index = msg.IndexOf(Dims[i], StringComparison.Ordinal); index += Dims[i].Length; msg = msg.Insert(index, srcs[i]); } Content = msg; }
public bool RecentFlash(MsgInformationEx MsgDTO, object[] param) { var picUrl = PicCacher.Random(); MsgSender.PushMsg(MsgDTO, CodeApi.Code_Flash_Relational(picUrl)); return(true); }
public bool MyPet(MsgInformationEx MsgDTO, object[] param) { var pet = PetRecord.Get(MsgDTO.FromQQ); var levelModel = PetLevelSvc[pet.Level]; var HasExtEndur = VipArmerRecord.Get(MsgDTO.FromQQ).CheckArmer("耐力护符"); var extEndur = HasExtEndur ? "(+10)" : string.Empty; var petEndur = levelModel.Endurance - PetEnduranceRecord.Get(MsgDTO.FromQQ).ConsumeTotal + (HasExtEndur ? 10 : 0); var session = new MsgSession(MsgDTO); session.Add($"{CodeApi.Code_Image_Relational(pet.PicPath)}"); session.Add($"名称:{pet.Name}"); session.Add($"种族:{pet.PetNo}"); session.Add($"食性:{pet.Attribute ?? "无"}"); session.Add($"等级:{Utility.LevelEmoji(pet.Level)}"); session.Add($"{Emoji.心}:{levelModel.HP}"); session.Add($"耐力:{petEndur}/{levelModel.Endurance}{extEndur}"); session.Add($"经验值:{pet.Exp}/{levelModel.Exp}"); if (!pet.Skills.IsNullOrEmpty()) { session.Add($"技能:{pet.Skills.Select(p => $"{p.Key}({p.Value})").JoinToString(",")}"); } if (pet.RemainSkillPoints > 0) { session.Add($"可用技能点:{pet.RemainSkillPoints}"); } session.Send(); return(true); }
private void JudgeResult() { if (IsGameOver()) { PushMsg("很遗憾队伍全灭,请再接再厉!"); return; } if (Gamers.Count == 1) { var winner = Gamers.First(); var treasureStr = TreasureTotal.ToString(); if (string.IsNullOrEmpty(treasureStr)) { PushMsg($"获胜者为 {CodeApi.Code_At(winner.QQNum)} !但是没有任何物品掉落"); return; } PushMsg($"获胜者为 {CodeApi.Code_At(winner.QQNum)} !获得以下物品:\r\n{treasureStr}"); TreasureTotal.SaveToPerson(winner.QQNum); return; } var msg = "恭喜你们获得了胜利!\r\n"; var treasures = TreasureTotal.Split(); msg += $"{CodeApi.Code_At(Gamers[0].QQNum)} 获取了\r\n{treasures[0]}\r\n{CodeApi.Code_At(Gamers[1].QQNum)} 获取了\r\n{treasures[1]}"; PushMsg(msg); treasures[0].SaveToPerson(Gamers[0].QQNum); treasures[1].SaveToPerson(Gamers[1].QQNum); }
private void PlayerAct(XunYuanGamingModel player, int choice, XunyuanMonsterModel monster, XunYuanGamingModel partner) { switch (choice) { case -1: { PushMsg("你放弃了思考!"); break; } case 0: { monster.HP = Math.Max(0, monster.HP - player.Attack); PushMsg($"{monster.Name} 受到了 {CodeApi.Code_At(player.QQNum)} 的 {player.Attack} 点伤害,剩余 {monster.HP} 点生命值"); break; } case 1: { partner.HP = Math.Max(0, partner.HP - player.Attack); PushMsg($"{CodeApi.Code_At(player.QQNum)} 受到了 {CodeApi.Code_At(player.QQNum)} 的 {player.Attack} 点伤害,剩余 {partner.HP} 点生命值"); if (partner.IsDead) { PushMsg($"{CodeApi.Code_At(partner.QQNum)} 被移除了队伍!"); Gamers.Remove(partner); } break; } } }
public bool Fight(MsgInformationEx MsgDTO, object[] param) { var aimNum = (long)param[0]; if (MsgDTO.FromQQ == aimNum) { MsgSender.PushMsg(MsgDTO, "你无法跟自己对决!"); return(false); } if (BindAiSvc.AllAiNums.Contains(aimNum)) { MsgSender.PushMsg(MsgDTO, "鱼唇的人类,你无法挑战ai的威严!"); return(false); } if (ChessSvc.IsGroupInPlaying(MsgDTO.FromGroup)) { MsgSender.PushMsg(MsgDTO, "本群正在进行一场对决,请稍后再试!"); return(false); } if (OSPersonBuff.CheckBuff(MsgDTO.FromQQ, "黄砂")) { MsgSender.PushMsg(MsgDTO, "你当前无法进行挑战!(黄砂)"); return(false); } if (!WaiterSvc.WaitForConfirm(MsgDTO.FromGroup, aimNum, $"{CodeApi.Code_At(MsgDTO.FromQQ)} 正在向你发起一场对决,是否接受?", MsgDTO.BindAi, 10)) { MsgSender.PushMsg(MsgDTO, "对决取消!"); return(false); } if (ChessSvc.IsQQInPlaying(MsgDTO.FromQQ)) { MsgSender.PushMsg(MsgDTO, "你正在进行一场对决,请稍后再试!"); return(false); } if (ChessSvc.IsQQInPlaying(aimNum)) { MsgSender.PushMsg(MsgDTO, "你的对手正在进行一场对决,请稍后再试!"); return(false); } ChessSvc.StartAGame(MsgDTO.FromGroup, MsgDTO.FromQQ, aimNum, (GroupNum, QQNum, Msg, judge) => { var msg = MsgDTO.Clone(); msg.FromQQ = QQNum; msg.FromGroup = GroupNum; var info = WaiterSvc.WaitForInformation(msg, Msg, information => information.FromGroup == GroupNum && information.FromQQ == QQNum && judge(information.Msg), 10, true); return(info == null ? string.Empty : info.Msg); }, MsgDTO.BindAi); return(true); }
private string FortunePrintString(MajFortuneCache fortune) { var msg = "今日麻将运势:" + $"\r\n整体运势:{GetStarString(fortune.FortuneStar)} " + $"\r\n吉位:{fortune.Position} " + $"\r\n牌运:{fortune.Kind} " + $"\r\n代表人物:{fortune.CharactorName} " + $"\r\n{CodeApi.Code_Image(fortune.CharactorPath)}"; return(msg); }
private bool DealDiet(MsgInformationEx MsgDTO, string name, long aimQQ, int price) { var aimDietRec = CookingRecord.Get(aimQQ); if (!aimDietRec.CheckDiet(name)) { MsgSender.PushMsg(MsgDTO, "对方没有该菜肴!"); return(false); } var dietModel = CookingDietSvc[name]; if (dietModel.EstimatedPrice < price) { MsgSender.PushMsg(MsgDTO, $"交易价格不能低于该菜肴的成本价格({dietModel.EstimatedPrice.CurencyFormat()})!"); return(false); } var sourceOSPerson = OSPerson.GetPerson(MsgDTO.FromQQ); var fee = OSPersonBuff.CheckBuff(MsgDTO.FromQQ, "苍天") ? 0 : price / 20; if (sourceOSPerson.Golds < price + fee) { MsgSender.PushMsg(MsgDTO, "你没有足够的金币来支付!"); return(false); } var count = aimDietRec.CookedDietDic[name]; var msg = $"收到来自 {CodeApi.Code_At(MsgDTO.FromQQ)} 的交易请求:\r\n" + $"希望得到的菜肴:{name}\r\n" + $"价格:{price.CurencyFormat()}({dietModel.EstimatedPrice.CurencyFormat()})\r\n" + $"你当前持有:{count}个,是否确认交易?"; if (!WaiterSvc.WaitForConfirm(MsgDTO.FromGroup, aimQQ, msg, MsgDTO.BindAi, 10)) { MsgSender.PushMsg(MsgDTO, "交易取消!"); return(false); } var sourceDietRec = CookingRecord.Get(MsgDTO.FromQQ); sourceDietRec.AddDiet(name); sourceDietRec.Update(); aimDietRec.DietConsume(name); aimDietRec.Update(); sourceOSPerson.Golds -= price + fee; sourceOSPerson.Update(); var aimOSPerson = OSPerson.GetPerson(aimQQ); aimOSPerson.Golds += price; aimOSPerson.Update(); MsgSender.PushMsg(MsgDTO, "交易完毕!"); return(true); }
public bool Xunyuan(MsgInformationEx MsgDTO, object[] param) { var aimQQ = (long)param[0]; if (aimQQ == MsgDTO.FromQQ) { MsgSender.PushMsg(MsgDTO, "你无法和自己寻缘!"); return(false); } if (!XunYuanMgr.CheckGroup(MsgDTO.FromGroup)) { MsgSender.PushMsg(MsgDTO, "此群正在进行一场寻缘,请稍候再试!"); return(false); } if (!XunYuanMgr.CheckQQNum(MsgDTO.FromQQ)) { MsgSender.PushMsg(MsgDTO, "你正在进行一场寻缘,请稍候再试!"); return(false); } if (!XunYuanMgr.CheckQQNum(aimQQ)) { MsgSender.PushMsg(MsgDTO, "对方正在进行一场寻缘,请稍候再试!"); return(false); } var msg = $"{CodeApi.Code_At(aimQQ)} 你正被邀请参加一次寻缘,是否同意?"; if (!WaiterSvc.WaitForConfirm(MsgDTO.FromGroup, aimQQ, msg, MsgDTO.BindAi)) { MsgSender.PushMsg(MsgDTO, "操作取消!"); return(false); } var Gamers = new[] { MsgDTO.FromQQ, aimQQ }.Select(p => { var armerRecord = PersonArmerRecord.Get(p); var osPerson = OSPerson_Doremi.GetPerson(p); var levelModel = LevelSvc.GetByLevel(osPerson.Level); var battleArmers = Rander.RandSort(armerRecord.Armers.ToArray()).Take(10).ToDictionary(a => a.Key, a => a.Value); return(new XunYuanGamingModel() { QQNum = p, Armers = battleArmers, EscapeArmers = armerRecord.EscapeArmers, BasicHP = levelModel.HP, HP = levelModel.HP + ArmerSvc.CountHP(battleArmers), BasicAttack = levelModel.Atk, Attack = levelModel.Atk + ArmerSvc.CountAtk(battleArmers) }); }).ToArray(); XunYuanMgr.StartGame(Gamers, MsgDTO.FromGroup, MsgDTO.BindAi); return(true); }
private static void SendAlertMsg(KanColeGirlVoice randGirl, long groupNum, string BindAi) { MsgSender.PushMsg(new MsgCommand { Command = CommandType.SendGroup, Msg = CodeApi.Code_Voice(randGirl.VoiceUrl), ToGroup = groupNum, BindAi = BindAi }); MsgSender.PushMsg(new MsgCommand { Command = CommandType.SendGroup, Msg = randGirl.Content, ToGroup = groupNum, BindAi = BindAi }); }
public bool MiniStory(MsgInformationEx MsgDTO, object[] param) { var rec = ArknightsMiniStoryRecord.GetLast(); var msg = $"【No.{rec.No}】\r\n{CodeApi.Code_Image_Relational(CachePath + rec.Path)}"; MsgSender.PushMsg(MsgDTO, msg); return(true); }
public bool RandomMajFortune(MsgInformationEx MsgDTO, object[] param) { var fortune = RapidCacher.GetCache($"MajFortune:{MsgDTO.FromQQ}", CommonUtil.UntilTommorow(), () => NewFortune(MsgDTO.FromQQ)); var msg = "今日麻将运势:" + $"\r\n整体运势:{Utility.LevelToStars(fortune.FortuneStar)} " + $"\r\n吉位:{fortune.Position} " + $"\r\n牌运:{fortune.Kind} " + $"\r\n代表人物:{fortune.CharactorName} " + $"\r\n{CodeApi.Code_Image(fortune.CharactorPath)}"; MsgSender.PushMsg(MsgDTO, msg); return(true); }
private bool RandVoice(MsgInformationEx MsgDTO, string name) { var folderPath = "./voices/" + name; var folder = new DirectoryInfo(folderPath); var files = folder.GetFiles(); var file = files.RandElement(); MsgSender.PushMsg(MsgDTO, CodeApi.Code_Voice(file.FullName)); return(true); }
/// <summary> /// 提交审核 /// </summary> /// <param name="authorizerAccessToken"></param> /// <param name="item"></param> /// <param name="tempInfo"></param> public APIResult SubmitVersion(string authorizerAccessToken, ShopWechatOpenAuthorizer item, TemplateInfo tempInfo) { //先上传代码 string extJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(new { ext = new { shopFlag = item.Shop.Flag } }); var commitResult = CodeApi.Commit(authorizerAccessToken, tempInfo.template_id, extJsonString, tempInfo.user_version, tempInfo.user_desc); //如果请求成功,则将请求的参数写入到数据库进行保存 if (commitResult.errcode != Senparc.Weixin.ReturnCode.请求成功) { return(Error("上传代码失败," + commitResult.errmsg)); } //提交审核 List <SubmitAuditPageInfo> list = new List <SubmitAuditPageInfo>(); CategroyInfo category = AuthorizerHelper.GetCategory(authorizerAccessToken); list.Add(new SubmitAuditPageInfo() { first_id = category.first_id, second_id = category.second_id, first_class = category.first_class, second_class = category.second_class, third_class = category.third_class, third_id = category.third_id, title = "点餐", tag = category.first_class, address = "pages/home/home" }); try { var submitAuditResult = CodeApi.SubmitAudit(authorizerAccessToken, list); if (submitAuditResult.errcode != ReturnCode.请求成功) { return(Error("提交审核失败," + submitAuditResult.errmsg)); } item.CurrentTemplateExtJson = extJsonString; item.CurrentAuditId = int.Parse(submitAuditResult.auditid); item.CurrentAuditStatus = 2; //审核状态,其中0为审核成功,1为审核失败,2为审核中 item.ReleaseTemplateUserVersion = tempInfo.user_version; item.IsRelease = false; //将发布状态设置为未发布 db.SaveChanges(); if (item.CurrentAuditStatus == 0) //审核通过则马上发布 { ReleaseVersion(authorizerAccessToken, item, tempInfo); } } catch (Exception ex) { return(Error("提交审核失败," + ex.Message)); } return(Success()); }
public static void PushMsg(MsgInformationEx MsgInfo, string Content, bool isNeedAt = false) { PushMsg(new MsgCommand { Command = MsgInfo.Type == MsgType.Group ? CommandType.SendGroup : CommandType.SendPrivate, Msg = MsgInfo.Type == MsgType.Group && isNeedAt ? $"{CodeApi.Code_At(MsgInfo.FromQQ)} {Content}" : Content, ToGroup = MsgInfo.FromGroup, ToQQ = MsgInfo.FromQQ, BindAi = MsgInfo.BindAi }); }
public bool SayHello(MsgInformationEx MsgDTO, object[] param) { var query = HelloList.FirstOrDefault(h => h.GroupNum == MsgDTO.FromGroup && h.QQNum == MsgDTO.FromQQ); if (query == null) { MsgSender.PushMsg(MsgDTO, "你还没有设定过招呼内容哦~(请使用【打招呼设定】命令来设定每日打招呼内容!)"); return(false); } MsgSender.PushMsg(MsgDTO, $"{CodeApi.Code_At(MsgDTO.FromQQ)} {query.Content}"); return(true); }
private static void DoSkill(MsgInformationEx MsgDTO, long aimQQ, string key, DateTime rebornTime, string skillName) { var cache = new AliveStateCache { QQNum = aimQQ, GroupNum = MsgDTO.FromGroup, Name = skillName, RebornTime = rebornTime }; SCacheService.Cache(key, cache, rebornTime); MsgSender.PushMsg(MsgDTO, $"成功对 {CodeApi.Code_At(aimQQ)} 使用了 {skillName}!他将于 {rebornTime.ToString(CultureInfo.CurrentCulture)} 后复活!"); }
private void MonsterTurn(XunyuanMonsterModel monster) { var target = Gamers[Rander.RandInt(Gamers.Count)]; target.HP = Math.Max(0, target.HP - monster.Atk); PushMsg($"{CodeApi.Code_At(target.QQNum)} 受到了 {monster.Name} 的 {monster.Atk}点攻击伤害!剩余 {target.HP}点生命"); if (!target.IsDead) { return; } PushMsg($"{CodeApi.Code_At(target.QQNum)} 被移除了队伍!"); Gamers.Remove(target); }
public bool KancoleVoice(MsgInformationEx MsgDTO, object[] param) { var girlName = param[0] as string; var voice = GetRandVoiceInfo(girlName); if (voice == null) { return(false); } MsgSender.PushMsg(MsgDTO, CodeApi.Code_Voice(voice.VoiceUrl)); MsgSender.PushMsg(MsgDTO, voice.Content); return(true); }
private static void SendTarotFortune(MsgInformationEx MsgDTO, TarotFortuneDataModel data) { if (data == null) { return; } var msg = $"{CodeApi.Code_Image(TarotServerPath + data.PicSrc)}\r\n"; msg += $"牌名:{data.Name}\r\n"; msg += data.IsPos ? "正位解释:" : "逆位解释:"; msg += data.Description; MsgSender.PushMsg(MsgDTO, msg, true); }
public bool MiniStoryIndex(MsgInformationEx MsgDTO, object[] param) { var no = (int)(long)param[0]; var rec = ArknightsMiniStoryRecord.Get(no); if (rec == null) { MsgSender.PushMsg(MsgDTO, "未找到相应的期号!"); return(false); } var msg = $"【No.{rec.No}】\r\n{CodeApi.Code_Image_Relational(CachePath + rec.Path)}"; MsgSender.PushMsg(MsgDTO, msg); return(true); }
private void FishItem(MsgInformationEx MsgDTO) { if (OSPersonBuff.CheckBuff(MsgDTO.FromQQ, "梅雨") && Rander.RandInt(100) < 30) { MsgSender.PushMsg(MsgDTO, "欸呀呀,捞瓶子失败了!(梅雨)", true); return; } var item = HonorSvc.RandItem(); var record = ItemCollectionRecord.Get(MsgDTO.FromQQ); var honorName = HonorSvc.FindHonorName(item.Name); var count = 1; var vipArmers = VipArmerRecord.Get(MsgDTO.FromQQ); if (vipArmers.CheckArmer("安妮的镜子")) { count = 2; } vipArmers.Armers.Remove(p => p.Name == "安妮的镜子"); vipArmers.Update(); DriftBottleAnalyzeRecord.Record(item.Name, count); var s = record.ItemIncome(item.Name, count); var msg = "你捞到了 \r\n" + $"{(string.IsNullOrEmpty(item.PicPath) ? string.Empty : $"{CodeApi.Code_Image_Relational(item.PicPath)}\r\n")}" + $"{item.Name}{(count > 1 ? $"*{count}" : string.Empty)} \r\n" + $" {item.Description} \r\n" + $"稀有率为 {HonorSvc.ItemRate(item)}%\r\n" + $"售价为:{item.Price} 金币\r\n" + $"特性:{(item.Attributes == null ? "无" : string.Join(",", item.Attributes))}\r\n" + $"你总共拥有该物品 {record.HonorCollections[honorName].Items[item.Name]}个"; if (!string.IsNullOrEmpty(s)) { msg += $"\r\n{s}"; } if (OSPersonBuff.CheckBuff(MsgDTO.FromQQ, "钻石尘") && Rander.RandInt(100) < 50) { OSPerson.GoldConsume(MsgDTO.FromQQ, 40); msg += "\r\n欸呀呀,你丢失了40金币(钻石尘)"; } MsgSender.PushMsg(MsgDTO, msg, true); }
private void SendTarotFortune(MsgInformationEx MsgDTO, TarotCacheModel data) { if (data == null) { return; } var ptr = data.IsPos ? "正位" : "逆位"; var msg = $"{CodeApi.Code_Image_Relational($"{TarotServerPath}{data.SerialName}/{data.CardName}.jpg")}\r\n"; msg += $"牌名:{ptr}{data.CardName}\r\n"; msg += $"{ptr}解释:"; var model = ModelList.First(p => p.Name == data.CardName); msg += data.IsPos ? model.正位 : model.逆位; MsgSender.PushMsg(MsgDTO, msg, true); }
public bool AdvantureAgainst(MsgInformationEx MsgDTO, object[] param) { var aimNum = (long)param[0]; if (MsgDTO.FromQQ == aimNum) { MsgSender.PushMsg(MsgDTO, "你无法跟自己对决!"); return(false); } if (BindAiSvc.AllAiNums.Contains(aimNum)) { MsgSender.PushMsg(MsgDTO, "鱼唇的人类,你无法挑战ai的威严!"); return(false); } if (!AdvGameSvc.CheckGroup(MsgDTO.FromGroup)) { MsgSender.PushMsg(MsgDTO, "本群正在进行一场对决,请稍后再试!"); return(false); } if (!WaiterSvc.WaitForConfirm(MsgDTO.FromGroup, aimNum, $"{CodeApi.Code_At(MsgDTO.FromQQ)} 正在向你发起一场冒险对决,是否接受?", MsgDTO.BindAi, 10)) { MsgSender.PushMsg(MsgDTO, "对决取消!"); return(false); } if (!AdvGameSvc.CheckPlayer(aimNum)) { MsgSender.PushMsg(MsgDTO, "你的对手正在进行一场对决,请稍后再试!"); return(false); } if (!AdvGameSvc.CheckPlayer(MsgDTO.FromQQ)) { MsgSender.PushMsg(MsgDTO, "你正在进行一场对决,请稍后再试!"); return(false); } AdvGameSvc.GameStart(MsgDTO.FromGroup, MsgDTO.FromQQ, aimNum, 1, MsgDTO.BindAi); return(true); }
private void Settlement() { var msg = $"对决结束!{CodeApi.Code_At(Winner.QQNum)}获取了胜利!"; if (Bonus > 0) { msg += $"\r\n获得了全部赏金 {Bonus}金币!"; var osPerson = OSPerson.GetPerson(Winner.QQNum); osPerson.Golds += Bonus; osPerson.Update(); } MsgSender.PushMsg(GroupNum, 0, msg, BindAi); foreach (var player in players) { var p = AdvPlayer.GetPlayer(player.QQNum); p.BattleRecord(p.QQNum == Winner.QQNum); p.Update(); if (p.QQNum != Winner.QQNum) { var osPerson = OSPerson.GetPerson(p.QQNum); osPerson.Golds -= 100; osPerson.Update(); MsgSender.PushMsg(GroupNum, p.QQNum, $"你不幸输掉了对决,扣除100金币,你剩余金币为 {osPerson.Golds}", BindAi); continue; } if (p.WinTotal % 10 != 0) { continue; } var items = HonorSvc.CurMonthLimitItems(); var item = items.RandElement(); MsgSender.PushMsg(GroupNum, p.QQNum, $"你已经累计赢得 {p.WinTotal}场对决,获取额外奖励 {item.Name}*1", BindAi); var record = ItemCollectionRecord.Get(p.QQNum); var honorMsg = record.ItemIncome(item.Name); if (!string.IsNullOrEmpty(honorMsg)) { MsgSender.PushMsg(GroupNum, 0, honorMsg, BindAi); } } }
private static void SendMultiMediaHello(MsgInformationEx MsgDTO, MultiMediaHelloRecord hello) { var path = hello.Location switch { ResourceLocationType.LocalAbsolute => hello.ContentPath, ResourceLocationType.LocalRelative => new FileInfo(hello.ContentPath).FullName, ResourceLocationType.Network => hello.ContentPath, _ => "" }; var msg = hello.MediaType switch { MultiMediaResourceType.Image => CodeApi.Code_Image(path), MultiMediaResourceType.Voice => CodeApi.Code_Voice(path), _ => "" }; MsgSender.PushMsg(MsgDTO, msg); }
public void Review(MsgInformationEx MsgDTO) { var record = MongoService <PicReviewRecord> .Get(p => p.Status == PicReviewStatus.Waiting).OrderBy(p => p.CreateTime).FirstOrDefault(); if (record == null) { MsgSender.PushMsg(MsgDTO, "暂无待审核的图片!"); return; } var msg = $"{CodeApi.Code_Image_Relational($"{CachePath}{record.PicName}")}\r\n"; msg += $"来自 {GroupSettingSvc[record.GroupNum].Name} 的 {record.QQNum}\r\n"; msg += $"用途:{record.Usage}\r\n"; msg += "是否通过?"; var option = WaiterSvc.WaitForOptions(MsgDTO.FromGroup, MsgDTO.FromQQ, msg, new[] { "通过", "不通过", "取消" }, MsgDTO.BindAi); if (option < 0 || option == 2) { MsgSender.PushMsg(MsgDTO, "操作取消!"); return; } record.Status = option == 0 ? PicReviewStatus.Passed : PicReviewStatus.Refused; record.ReviewTime = DateTime.Now; record.Update(); ReviewCallBack[record.Usage](record); msg = record.Status == PicReviewStatus.Passed ? $"恭喜你,你在{record.CreateTime:yyyy-MM-dd HH:mm:ss}提交的用于{record.Usage}的图片审核通过!" : $"很遗憾,你在{record.CreateTime:yyyy-MM-dd HH:mm:ss}提交的用于{record.Usage}的图片未能审核通过!"; MsgSender.PushMsg(record.GroupNum, record.QQNum, msg, GroupSettingSvc[record.GroupNum].BindAi); var picTempFile = new FileInfo($"{CachePath}{record.PicName}"); picTempFile.Delete(); var count = MongoService <PicReviewRecord> .Count(p => p.Status == PicReviewStatus.Waiting); MsgSender.PushMsg(MsgDTO, $"审核完毕!还有{count}张待审核的图片!"); }