Пример #1
0
        private static bool IsCharactorCreator(MsgInformation MsgDTO, string charactor)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == MsgDTO.FromGroup &&
                                                             cs.Charactor == charactor);

            return(query.First().Creator == MsgDTO.FromQQ);
        }
Пример #2
0
        public void OnMsgReceived(MsgInformation MsgDTO)
        {
            // 群聊消息
            if (MsgDTO.FromGroup != 0)
            {
                if (GroupSettingSvc[MsgDTO.FromGroup] == null)
                {
                    return;
                }

                if (Global.IsTesting && !Global.TestGroups.Contains(MsgDTO.FromGroup))
                {
                    return;
                }
            }

            var msgEx = MsgDTO.ToEx();

            if (!DirtyFilterSvc.Filter(msgEx))
            {
                return;
            }

            MsgCallBack(msgEx);
        }
Пример #3
0
        /// <summary>
        /// 每日限制检查
        /// </summary>
        /// <param name="enterAttr"></param>
        /// <param name="MsgDTO"></param>
        /// <param name="limitRecord"></param>
        /// <returns></returns>
        private static bool DailyLimitCheck(EnterCommandAttribute enterAttr, MsgInformation MsgDTO, DailyLimitRecord limitRecord)
        {
            var isTestingGroup = Global.TestGroups.Contains(MsgDTO.FromGroup);
            var timesLimit     = isTestingGroup ? enterAttr.TestingDailyLimit : enterAttr.DailyLimit;

            return(timesLimit == 0 || limitRecord.Check(timesLimit));
        }
Пример #4
0
        /// <summary>
        /// 普通消息接收事件
        /// </summary>
        /// <param name="MsgDTO"></param>
        public void OnMsgReceived(MsgInformation MsgDTO)
        {
            var worldLine = JudgeWorldLine(MsgDTO.FromGroup);
            var world     = AllWorlds.FirstOrDefault(p => p.Name == worldLine);

            world?.OnMsgReceived(MsgDTO);
        }
Пример #5
0
        private void Recruit(MsgInformation MsgDTO, MsgSession session)
        {
            var castle = KindomCastle.Get(MsgDTO.FromGroup, MsgDTO.FromQQ);

            CollectTaxes(castle, session);
            RecruitCommissariat(castle, session);

            castle.Update();
        }
Пример #6
0
        public void CallBack(WaitingModel model, QQEventModel eventModel)
        {
            var info = new MsgInformation()
            {
                Information = InformationType.CommandBack,
                RelationId  = model.RelationId,
                Msg         = JsonConvert.SerializeObject(eventModel.Result)
            };

            WSMgr.PublishInformation(info);
        }
Пример #7
0
        public void Resolve(MsgCommand command)
        {
            var stateDic = WSMgr.ClientsDic.ToDictionary(c => c.Key, c => c.Value.IsConnected);
            var info     = new MsgInformation()
            {
                Information = InformationType.CommandBack,
                Msg         = JsonConvert.SerializeObject(stateDic),
                RelationId  = command.Id
            };

            WSMgr.PublishInformation(info);
        }
Пример #8
0
        private static bool IsQQFullChar(MsgInformation MsgDTO)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == MsgDTO.FromGroup &&
                                                             cs.Creator == MsgDTO.FromQQ);

            if (query.IsNullOrEmpty())
            {
                return(false);
            }
            query = query.GroupBy(p => p.Charactor).Select(p => p.First()).ToList();
            return(!query.IsNullOrEmpty() && query.Count > MaxCharNumPerQQ);
        }
Пример #9
0
        public void CallBack(WaitingModel model, QQEventModel eventModel)
        {
            try
            {
                dynamic result    = eventModel.Result["result"];
                var     buddy     = result["buddy"];
                var     info_list = buddy["info_list"];

                var info = new MsgInformation()
                {
                    Information = InformationType.CommandBack,
                    RelationId  = model.RelationId,
                    Msg         = JsonConvert.SerializeObject(info_list[0])
                };
                WSMgr.PublishInformation(info);
            }
            catch (Exception e)
            {
                RuntimeLogger.Log(e);
            }
        }
Пример #10
0
        public void Resolver(string bindAi, QQEventModel model)
        {
            var changeModel = new GroupMemberChangeModel()
            {
                QQNum    = long.TryParse(model.Params.Qq, out var qqNum) ? qqNum : 0,
                GroupNum = long.TryParse(model.Params.Group, out var groupNum) ? groupNum : 0,
                Type     = 1,
                Operator = long.TryParse(model.Params.Operator, out var op) ? op : 0
            };

            var info = new MsgInformation()
            {
                BindAi      = bindAi,
                Information = InformationType.GroupMemberDecrease,
                Msg         = JsonConvert.SerializeObject(changeModel),
                FromQQ      = changeModel.QQNum,
                FromGroup   = changeModel.GroupNum
            };

            WSMgr.PublishInformation(info);
        }
    }
Пример #11
0
        public void Resolver(string bindAi, QQEventModel model)
        {
            var chargeModel = new ChargeModel()
            {
                QQNum   = long.TryParse(model.Params.Qq, out var qqNum) ? qqNum : 0,
                Amount  = double.TryParse(model.Params.Amount, out var amount) ? Math.Round(amount, 2) : 0,
                Message = model.Params.Message,
                OrderID = model.Params.Id,
                BindAi  = bindAi
            };

            var info = new MsgInformation()
            {
                BindAi      = bindAi,
                Information = InformationType.ReceiveMoney,
                Msg         = JsonConvert.SerializeObject(chargeModel),
                FromQQ      = chargeModel.QQNum
            };

            WSMgr.PublishInformation(info);
        }
    }
Пример #12
0
 public static void PublishInformation(MsgInformation info)
 {
     Global.MQSvc.Send(info, Global.Config.MQSendQueue);
 }
Пример #13
0
        private void ListenCallBack(MsgInformation info)
        {
            var source = "未知";

            if (info.FromGroup == 0)
            {
                source = "私聊";
            }
            else
            {
                var groupSetting = GroupSettingSvc[info.FromGroup];
                if (groupSetting != null)
                {
                    source = groupSetting.Name;
                }
            }

            if (info.FromGroup != 0)
            {
                var setting = GroupSettingSvc[info.FromGroup];
                if (setting == null || setting.BindAi != info.BindAi)
                {
                    return;
                }
            }

            var msg = $"[Info] {info.BindAi} {source} {QqNumReflectSvc[info.FromQQ]} {info.Msg}";

            Global.MsgPublish(msg);

            if (BindAiSvc[info.FromQQ] != null)
            {
                return;
            }

            switch (info.Information)
            {
            case InformationType.Message:
            case InformationType.CommandBack:
                WaiterUnit waitUnit = null;
                lock (_lockObj)
                {
                    if (UnitsDic.ContainsKey(info.FromGroup) && !UnitsDic[info.FromGroup].IsNullOrEmpty())
                    {
                        waitUnit = UnitsDic[info.FromGroup].FirstOrDefault(u => u.JudgePredicate(info));
                    }
                }

                if (waitUnit == null)
                {
                    CrossWorldAiSvc.OnMsgReceived(info);
                    break;
                }

                waitUnit.ResultInfos.Add(info);
                waitUnit.Signal.Set();
                AIAnalyzer.AddCommandCount(new CmdRec()
                {
                    FunctionalAi = "Waiter",
                    Command      = "WaiterCallBack",
                    GroupNum     = info.FromGroup,
                    BindAi       = info.BindAi
                });

                break;

            case InformationType.AuthCode:
                break;

            case InformationType.Error:
                AIAnalyzer.AddError(info.Msg);
                break;

            case InformationType.ReceiveMoney:
                CrossWorldAiSvc.OnMoneyReceived(JsonConvert.DeserializeObject <ChargeModel>(info.Msg));
                break;

            case InformationType.GroupMemberIncrease:
            case InformationType.GroupMemberDecrease:
                CrossWorldAiSvc.OnGroupMemberChanged(JsonConvert.DeserializeObject <GroupMemberChangeModel>(info.Msg));
                break;

            case InformationType.ConnectStateChange:
                var bindai = BindAiSvc[info.BindAi];
                bindai.IsConnected = bool.Parse(info.Msg);
                break;
            }
        }
Пример #14
0
 public MsgSession(MsgInformation MsgDTO)
 {
     this.GroupNum = MsgDTO.FromGroup;
     this.QQNum    = MsgDTO.FromQQ;
     this.BindAi   = MsgDTO.BindAi;
 }