Esempio n. 1
0
 /// <summary>
 /// 启动事件
 /// </summary>
 public override void OnInitialize()
 {
     Config.path = QMApi.GetPluginDataDirectory();
     if (Config.Get("config.ini", "all", "robot", "") != "")
     {
         enable = true;
     }
     Genshin.Start();
     Tieba.Start();
     Manga.Start();
 }
Esempio n. 2
0
        /// <summary>
        /// 提取cookie需要部分
        /// </summary>
        /// <param name="cookie"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        private string GetPart(string cookie, params string[] keys)
        {
            string result = "";

            foreach (string i in keys)
            {
                if (!cookie.Contains(i + "="))
                {
                    continue;
                }
                if (!cookie.Substring(cookie.IndexOf(i + "=")).Contains(";"))
                {
                    result += cookie.Substring(cookie.IndexOf(i + "=")) + ";";
                }
                else
                {
                    result += i + "=" + Tieba.Mid(cookie, i + "=", ";") + ";";
                }
            }
            return(result);
        }
Esempio n. 3
0
 public void OnReceivePrivateMessage(long robotQQ, long fromGroup, long fromQQ, string message)
 {
     if (message == "启动" && !enable)
     {
         Config.Set("config.ini", "all", "robot", robotQQ.ToString());
         enable = true;
         SendPrivateMessage(robotQQ, fromGroup, fromQQ, "启动成功");
     }
     else if (message == "关闭" && enable)
     {
         Config.Set("config.ini", "all", "robot", "");
         enable = false;
         SendPrivateMessage(robotQQ, fromGroup, fromQQ, "关闭成功");
     }
     else if (!enable)
     {
     }
     else if (message == "原神签到")
     {
         SendPrivateMessage(robotQQ, fromGroup, fromQQ, "Cookie录入开始,请发送一条单独包含Cookie的消息(多账号可用 # 分割Cookie)\n输入none清除已录入数据");
         Config.Set("genshin.ini", fromQQ.ToString(), "writing", "true");
     }
     else if (Config.Get("genshin.ini", fromQQ.ToString(), "writing", "false") == "true")
     {
         Config.Set("genshin.ini", fromQQ.ToString(), "writing", "false");
         if (message == "none")
         {
             Config.Set("genshin.ini", fromQQ.ToString(), "cookie", "");
             Config.Set("genshin.ini", fromQQ.ToString(), "group", "");
             Config.Set("genshin.ini", "all", "member", Config.Get("genshin.ini", "all", "member").Replace("," + fromQQ.ToString(), "").Replace(fromQQ.ToString(), ""));
             SendPrivateMessage(robotQQ, fromGroup, fromQQ, "清除成功");
         }
         else
         {
             string cookies = "";
             foreach (string i in message.Split('#'))
             {
                 if (cookies != "")
                 {
                     cookies += "#";
                 }
                 cookies += GetPart(i, "account_id", "cookie_token");
             }
             Config.Set("genshin.ini", fromQQ.ToString(), "cookie", cookies);
             Config.Set("genshin.ini", fromQQ.ToString(), "group", fromGroup.ToString());
             if (!Config.Get("genshin.ini", "all", "member").Contains(fromQQ.ToString()))
             {
                 Config.Set("genshin.ini", "all", "member", Config.Get("genshin.ini", "all", "member", "") == "" ? fromQQ.ToString() : Config.Get("genshin.ini", "all", "member") + "," + fromQQ.ToString());
             }
             SendPrivateMessage(robotQQ, fromGroup, fromQQ, "Cookie录入完毕!接下来将进行一次测试签到");
             try
             {
                 string[] cookie = Config.Get("genshin.ini", fromQQ.ToString(), "cookie").Split('#');
                 foreach (string i in cookie)
                 {
                     SendPrivateMessage(robotQQ, fromGroup, fromQQ, Genshin.Run(i));
                 }
             }
             catch
             {
                 SendPrivateMessage(robotQQ, fromGroup, fromQQ, "发生未知错误,请联系物理管理员");
             }
         }
     }
     else if (message == "贴吧签到")
     {
         SendPrivateMessage(robotQQ, fromGroup, fromQQ, "Cookie录入开始,请发送一条单独包含Cookie的消息\n输入none清除已录入数据");
         Config.Set("tieba.ini", fromQQ.ToString(), "writing", "true");
     }
     else if (Config.Get("tieba.ini", fromQQ.ToString(), "writing", "false") == "true")
     {
         Config.Set("tieba.ini", fromQQ.ToString(), "writing", "false");
         if (message == "none")
         {
             Config.Set("tieba.ini", fromQQ.ToString(), "cookie", "");
             Config.Set("tieba.ini", fromQQ.ToString(), "group", "");
             Config.Set("tieba.ini", "all", "member", Config.Get("tieba.ini", "all", "member").Replace("," + fromQQ.ToString(), "").Replace(fromQQ.ToString(), ""));
             SendPrivateMessage(robotQQ, fromGroup, fromQQ, "清除成功");
         }
         else
         {
             Config.Set("tieba.ini", fromQQ.ToString(), "cookie", GetPart(message, "BDUSS"));
             Config.Set("tieba.ini", fromQQ.ToString(), "group", fromGroup.ToString());
             if (!Config.Get("tieba.ini", "all", "member").Contains(fromQQ.ToString()))
             {
                 Config.Set("tieba.ini", "all", "member", Config.Get("tieba.ini", "all", "member", "") == "" ? fromQQ.ToString() : Config.Get("tieba.ini", "all", "member") + "," + fromQQ.ToString());
             }
             SendPrivateMessage(robotQQ, fromGroup, fromQQ, "Cookie录入完毕!接下来将进行一次测试签到");
             try
             {
                 string cookie = Config.Get("tieba.ini", fromQQ.ToString(), "cookie");
                 string result = Tieba.Run(cookie);
                 SendPrivateMessage(robotQQ, fromGroup, fromQQ, result);
                 if (result.Contains("失败"))
                 {
                     SendPrivateMessage(robotQQ, fromGroup, fromQQ, "将于 10 分钟内重试");
                 }
             }
             catch
             {
                 SendPrivateMessage(robotQQ, fromGroup, fromQQ, "发生未知错误,请联系物理管理员");
             }
         }
     }
     else if (message == "漫画签到")
     {
         SendPrivateMessage(robotQQ, fromGroup, fromQQ, "Cookie录入开始,请发送一条单独包含Cookie的消息\n输入none清除已录入数据");
         Config.Set("manga.ini", fromQQ.ToString(), "writing", "true");
     }
     else if (Config.Get("manga.ini", fromQQ.ToString(), "writing", "false") == "true")
     {
         Config.Set("manga.ini", fromQQ.ToString(), "writing", "false");
         if (message == "none")
         {
             Config.Set("manga.ini", fromQQ.ToString(), "cookie", "");
             Config.Set("manga.ini", fromQQ.ToString(), "group", "");
             Config.Set("manga.ini", "all", "member", Config.Get("manga.ini", "all", "member").Replace("," + fromQQ.ToString(), "").Replace(fromQQ.ToString(), ""));
             SendPrivateMessage(robotQQ, fromGroup, fromQQ, "清除成功");
         }
         else
         {
             Config.Set("manga.ini", fromQQ.ToString(), "cookie", GetPart(message, "SESSDATA", "bili_jct"));
             Config.Set("manga.ini", fromQQ.ToString(), "group", fromGroup.ToString());
             if (!Config.Get("manga.ini", "all", "member").Contains(fromQQ.ToString()))
             {
                 Config.Set("manga.ini", "all", "member", Config.Get("manga.ini", "all", "member", "") == "" ? fromQQ.ToString() : Config.Get("manga.ini", "all", "member") + "," + fromQQ.ToString());
             }
             SendPrivateMessage(robotQQ, fromGroup, fromQQ, "Cookie录入完毕!接下来将进行一次测试签到");
             try
             {
                 string cookie = Config.Get("manga.ini", fromQQ.ToString(), "cookie");
                 string result = Manga.Run(cookie);
                 SendPrivateMessage(robotQQ, fromGroup, fromQQ, result);
                 if (result.Contains("失败"))
                 {
                     SendPrivateMessage(robotQQ, fromGroup, fromQQ, "将于 10 分钟内重试");
                 }
             }
             catch
             {
                 SendPrivateMessage(robotQQ, fromGroup, fromQQ, "发生未知错误,请联系物理管理员");
             }
         }
     }
 }