Ejemplo n.º 1
0
        /// <summary>
        /// 从服务器获取AI的回复
        /// </summary>
        /// <param name="message">源语句</param>
        /// <param name="QQNum">发言用户的QQ</param>
        /// <param name="QunNum">发言的群</param>
        /// <returns></returns>
        private static string AIGet(string message, long QQNum, long QunNum = 0)
        {
            var study = OrmManager.Get <StudyWords>(x => x.SourceQQNum == QQNum && x.GroupId == QunNum && x.Source == message && x.Pass);

            if (study == null)
            {
                return("");
            }
            return(study.Aim);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从服务器获取AI的回复
        /// </summary>
        /// <param name="message">源语句</param>
        /// <param name="QQNum">发言用户的QQ</param>
        /// <param name="QunNum">发言的群</param>
        /// <returns></returns>
        private static string AIGet(string message)
        {
            var study = OrmManager.Get <StudyWords>(x => x.Source == message);

            if (study == null)
            {
                return("");
            }
            else
            {
                if (!study.Pass)
                {
                    return("None3");
                }
            }
            return(study.Aim);
        }
Ejemplo n.º 3
0
        private void Client_Logined(object sender, LoginSucessedEventArgs e)
        {
            // OrmManager.Update(state);
            var state = OrmManager.Get <Models.QQState>(x => x.QQNum == e.Session.QQNum);

            var clientManager = ClientManager.GetClientManagerUser(Container, new Models.QQState());

            clientManager.QQ.QQNum   = e.Session.QQNum;
            clientManager.QQ.Logined = true;
            clientManager.QQ.SetCookies(Constract.LoginCookies, e.JsonResult);
            //clientManager.QQ.SetCookies(Constract.QQSession, e.Session);
            if (state != null)
            {
                clientManager.QQ.Id = state.Id;
                OrmManager.Update(clientManager.QQ);
            }
            else
            {
                OrmManager.Insert(clientManager.QQ);
            }
            WorkContext.SetState(Constract.CurrentQQState, clientManager.QQ);
            WorkContext.SetState(Constract.CurrentQQ, clientManager.QQ.QQNum);
            clientManager.Client.DefaultState = clientManager.QQ.State;
            ClientManager.ResetKey();
            //throw new NotImplementedException();
            if (e.ShowMainWindow)
            {
                App.Current.Dispatcher.Invoke(() =>
                {
                    new MainWindow(Container).Show();
                    Logger.Debug("MainWindow has been created and displayed.");
                    // 3.Closes the SignIn window.
                    (Application.Current.Resources[LoginWindow.Key] as LoginWindow)?.Close();
                    Logger.Debug("LoginWindow has been closed.");
                });
            }
        }
Ejemplo n.º 4
0
        public void Answer(AnswerContext context)
        {
            var anwer = "";

            if (CommandKey.Any(x => context.Message.StartsWith(x)) && context.IsManager)
            {
                bool EnableFlag = false;
                if (context.State != null && context.GetState <bool>(SettingKey))
                {
                    EnableFlag = true;
                }
                if (EnableFlag)
                {
                    var groupInfo = OrmManager.Get <GroupInfo>(x => x.QQNum == context.CurrentQQ && x.GroupId == context.SendToId);
                    context.SmartService.InitGroupInfo(context.SendToId);
                    var  adminuin   = groupInfo.Owner;
                    var  memberInfo = OrmManager.Get <MemberInfo>(x => x.QQNum == context.CurrentQQ && x.GroupId == context.SendToId && x.Uin == context.FromUin);
                    bool HaveRight  = false;
                    if (context.FromUin.Equals(adminuin)) //|| context.SmartService.InitRealQQ(context.FromUin).Equals(MasterQQ)
                    {
                        HaveRight = true;
                    }
                    else if (memberInfo != null && memberInfo.IsManager)
                    {
                        HaveRight = true;
                    }
                    else
                    {
                        HaveRight = false;
                    }
                    string[] tmp = context.Message.Trim().Split(' ');
                    if (tmp.Length == 1)
                    {
                        context.Alerts.AddRange(Example());


                        return;
                    }
                    tmp[1] = tmp[1].Replace("\r", "").Replace("\n", "").Replace(" ", "");
                    if (tmp.Length < 2 || tmp[1] == null)
                    {
                        return;
                    }
                    if ((HaveRight) && (tmp[1].Equals("查询状态") || tmp[1].Equals("状态")))
                    {
                        string enableFormate  = "{0}已经启动,关闭命令:群管理 关闭 {0}";
                        string disableFormate = "{0}暂未启动,启动命令:群管理 启动 {0}";
                        foreach (var answer in context.SmartService.GetAnswers().Except(new[] { this }))
                        {
                            if (context.GetState <bool>(answer.SettingKey))
                            {
                                context.Answers.Add(string.Format(enableFormate, answer.Name));
                            }
                            else
                            {
                                context.Answers.Add(string.Format(disableFormate, answer.Name));
                            }
                        }
                        return;
                    }
                    if (HaveRight == false)
                    {
                        if (context.FromRealQQ != 0)
                        {
                            anwer = "用户" + context.FromNick + "不是群管理,无权进行此操作";
                        }
                        else
                        {
                            anwer = context.FromNick + "不是群管理,无权进行此操作";
                        }
                        context.Answers.Add(anwer);
                        return;
                    }
                    else
                    {
                        tmp[1] = tmp[1].Replace("开启", "启动");
                        tmp[1] = tmp[1].Replace("开起", "启动");

                        if (tmp.Length != 3 || tmp[2] == null)
                        {
                            return;
                        }
                        string enableFormate  = "{0}已经启动,关闭命令:群管理 关闭 {0}";
                        string disableFormate = "{0}已经关闭,启动命令:群管理 启动 {0}";
                        string NoThisFormate  = "没有这个 {0} 答话机";
                        var    answers        = context.SmartService.GetAnswers().Except(new[] { this });
                        var    answer         = answers.Where(x => x.Name == tmp[2]);
                        if (answer == null)
                        {
                            context.Answers.Add(string.Format(NoThisFormate, tmp[2]));
                            return;
                        }
                        else
                        {
                            foreach (var item in answer)
                            {
                                if (tmp[2] == item.Name)
                                {
                                    if (tmp[1] == "启动")
                                    {
                                        context.SetState(item.SettingKey, true);
                                        context.Answers.Add(string.Format(enableFormate, item.Name));
                                    }
                                    else
                                    {
                                        context.SetState(item.SettingKey, false);
                                        context.Answers.Add(string.Format(disableFormate, item.Name));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (CommandKey.Any(x => context.Message.StartsWith(x)) && !context.IsManager)
            {
                anwer = "你不是管理员,没有权限";
                context.Answers.Add(anwer);
            }
        }