Esempio n. 1
0
        /// <summary>
        /// 运行插件
        /// </summary>
        /// <returns>null:运行插件成功,string:错误信息</returns>
        public override string Start()
        {
            // 初始化插件配置
            this.Config = PluginConfig.Init <PasserbyConfig>(this, "PasserbyPlugin");
            if (this.Config.PokemonImageBaseDir == "" || this.Config.PokemonImageBaseDir.IsEmpty() || this.Config.PokemonImageBaseDir.IsNull())
            {
                this.Config.PokemonImageBaseDir = "D:\\PokemonImages";
            }
            OnLog("pokemonDir:" + this.Config.PokemonImageBaseDir);
            // 获取宝可梦文件列表
            this.evolveImgList          = getPokemonImgList(this.Config.PokemonImageBaseDir + "\\evolveImg");
            this.megaEvolveImgList      = getPokemonImgList(this.Config.PokemonImageBaseDir + "\\megaEvolveImg");
            this.speciesStrengthImgList = getPokemonImgList(this.Config.PokemonImageBaseDir + "\\speciesStrength");
            this.transformImgList       = getPokemonImgList(this.Config.PokemonImageBaseDir + "\\transformImg");
            this.typeOppositeImgList    = getPokemonImgList(this.Config.PokemonImageBaseDir + "\\typeOpposite");
            // sqlite连接字符串
            string dataSource = "QQ\\" + DbBase.RobotQQ.ToString() + "\\DataBase\\52Poke.db3";

            SQLiteHelper.setConnectionString(dataSource);

            this.SDK = new QQClientSDK();

            #region 事件订阅
            // 订阅群消息
            this.SDK.ReceiveClusterIM += SDK_ReceiveClusterIM;
            #endregion

            return(null);
        }
Esempio n. 2
0
        public AddedToClusterController(Plugin plugin, AddedToClusterQQEventArgs e)
        {
            this.Client = plugin;
            this.e      = e;

            Config = DataBase.db.GetClusterConfig(e.Cluster.ExternalId);
            Conf   = PluginConfig.Init <Config>();
        }
        public override bool Initialize(IPluginHost host)
        {
            if (host == null)
            {
                return(false);
            }

            _host         = host;
            _customConfig = PluginConfig.Init(_host.CustomConfig);

            KeePass.Util.UpdateCheckEx.SetFileSigKey(UpdateUrl, "<RSAKeyValue><Modulus>0qk0X8E7nOAvNUd3qQoUUpRh2JKIn4k3x95F30ToHEXasJXphNSfCwIa7Ci8Ij0rPU2sycuJVM9k6F5D4Nx2w/h/Eg8/sPEKeRJFuIVIDnGZMV15ven08Ya1LrV3/UeUh6TZ58VulyHssHiNy9U4h+STohbVueShgvfKq7HmOS1Jbaz0atr5mewqUzyyXZTx/U2DN2vwsksQYQJCJWre5hy2nPHmCukEuPthiWj8DlU2PRbAisEWc6JYj3O/64h3X8qVaPjZbSUwz/liFwfRv+1W6TNjAgqYBGhq5JV4wx9PohD4a34xZJOYLN1TwjtMDoD+ILaKA5tjPahj7lb3VYubcegt+hmR18GEceEJwCC4pa1yyP+GYz0/aeKkfP+1h3bItcJrdrALDSYNqF9+Ux+8hm7NrGt6LkJFK5iJhcp/W/Vm7EwySaUBlf7/zI7jfgO98jLUv3lxunwffWVWlZn2YFIeZMqXahGG6CpfYkU7nmbVRDecWNk5EJkhZDZHf0S2Y8eM5Spw7SJI45nhHNNRsXkUxGVLyB4yMm3M8DpTKi8Gv2vHBfQCFWktRZ9HeGsZUNatffMgh8K1HxBUfVu2XVcB7BbB5Xp/9Ela3rRUK6ByG7RJMYjefaPxt6MLQzQVVBw7HFTaYOBKbZI2cU0CyDNBVLAuDC4ETf6EhKE=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");

            do
            {
                // deux cas possibles :
                // lorsque Keepass charge le plugin pour la première fois
                // lorsque le mot de passe ne permet pas d'ouvrir le base de données
                if (!_customConfig.IsConfigured.Get())
                {
                    OpenOptions();
                }

                if (!_customConfig.IsEnabled.Get())
                {
                    return(true);
                }

                // récupération de la base de données
                IOConnectionInfo db = new IOConnectionInfo();
                db.Path = _customConfig.DatabaseLocation.Get();

                // master password
                string       password = _customConfig.Password.Get();
                CompositeKey cp       = new CompositeKey();
                cp.AddUserKey(new KcpPassword(password));

                // tentative de connexion à la base de données
                // si la connexion échoue alors on considère que le plugin est mal configuré et l'utilisateur devra donc le reconfiguré
                try
                {
                    _host.Database.Open(db, cp, null);
                    // permet d'afficher la base de données dans l'interface de Keepass
                    _host.MainWindow.UpdateUI(true, null, true, null, true, null, false);
                }
                catch (System.Exception)
                {
                    MessageBox.Show("KeePassAutoUnlock : Impossible to open the database");
                    _customConfig.IsConfigured.Set(false);
                }
            } while (!_customConfig.IsConfigured.Get());

            return(true);
        }
Esempio n. 4
0
        public RedBagController(Plugin plugin, RedBagEventArgs e)
        {
            this.Client = plugin;
            this.e      = e;

            Config = DataBase.db.GetClusterConfig(e.ExternalId);
            Conf   = PluginConfig.Init <Config>();

            if (Config.Status)
            {
                Config.RedBagProtect.Clear(Config.RedBagProtectTime);
                Config.RedBagProtect.Insert(new DataBase.Models.RedBagProtectData()
                {
                    Content = e.Memo, SendTime = DateTime.Now
                });

                DataBase.db.SaveClusterConfig(Config);
            }
        }
Esempio n. 5
0
 public void RunStep(uint ExternalId, uint QQ, uint Sequence, uint MessageId, uint SilencedTime, string Step, bool IsBlackStep = false)
 {
     if (Step.Contains("移除"))
     {
         this.Client.RemoveMember(ExternalId, QQ);
     }
     if (Step.Contains("禁言") && SilencedTime > 0)
     {
         var Config = DataBase.db.GetClusterConfig(ExternalId);
         if (Config.WarnSilenced && !IsBlackStep)
         {
             var warn = DataBase.db.GetWarning(ExternalId, QQ);
             if (warn == null)
             {
                 warn = new DataBase.Models.Warning()
                 {
                     GroupId = ExternalId,
                     QQ      = QQ,
                     Count   = 0
                 };
             }
             warn.Count++;
             DataBase.db.SaveWarning(warn);
             if (warn.Count > Config.WarningCount)
             {
                 var Conf = PluginConfig.Init <Config>();
                 if (Config.WarningAddToYunBlack)
                 {
                     Conf.YunBlackList.Add(QQ);
                     Conf.Save();
                     this.Client.SendClusterMessage(ExternalId, QQ, Config.WarningResult_N
                                                    .Replace("[违规类型]", "禁言警告")
                                                    .Replace("[执行操作]", "加入云黑名单")
                                                    .Replace("[警告次数]", warn.Count.ToString())
                                                    .Replace("[最大警告次数]", Config.WarningCount.ToString()));
                 }
                 else if (Config.WarningAddToBlack)
                 {
                     Config.QunBlackList.Add(QQ);
                     DataBase.db.SaveClusterConfig(Config);
                     this.Client.SendClusterMessage(ExternalId, QQ, Config.WarningResult_N
                                                    .Replace("[违规类型]", "禁言警告")
                                                    .Replace("[执行操作]", "加入黑名单")
                                                    .Replace("[警告次数]", warn.Count.ToString())
                                                    .Replace("[最大警告次数]", Config.WarningCount.ToString()));
                 }
             }
             else
             {
                 this.Client.SendClusterMessage(ExternalId, QQ, Config.WarningResult_N
                                                .Replace("[违规类型]", "禁言警告")
                                                .Replace("[执行操作]", "警告")
                                                .Replace("[警告次数]", warn.Count.ToString())
                                                .Replace("[最大警告次数]", Config.WarningCount.ToString()));
             }
         }
         int count           = 0;
         var silenced_member = GMUtil.Util.GetAllSilencedMember(ExternalId, this.Client.User.QQ, this.Client.User.skey, this.Client.GetBkn(this.Client.User.skey));
         while (!this.Client.Silenced(ExternalId, QQ, SilencedTime).Contains("禁言成功"))
         {
             if (count < silenced_member.Count)
             {
                 this.Client.Silenced(ExternalId, (uint)silenced_member[count], 0);
             }
             else
             {
                 this.Client.OnLog($"群【{this.Client.User.Clusters.Find(x => x.ExternalId == ExternalId).Name}】成员【{this.Client.GetFriend(QQ).NickName}({QQ})】禁言失败");
                 break;
             }
             count++;
         }
     }
     if (Step.Contains("撤回") && Sequence != 0 && MessageId != 0)
     {
         this.Client.Recall(ExternalId, Sequence, MessageId);
     }
 }