コード例 #1
0
 private void FormSettings_Load(object sender, EventArgs e)
 {
     textBox1.Text = LinqXML.read(MyPlugin.confirm, "群号");
     textBox2.Text = LinqXML.read(MyPlugin.confirm, "admin");
     textBox4.Text = LinqXML.read(MyPlugin.confirm, "IP");
     textBox5.Text = LinqXML.read(MyPlugin.confirm, "Port");
 }
コード例 #2
0
        private void button_Click(object sender, EventArgs e)
        {
            int tmp;

            LinqXML.write(MyPlugin.confirm, "IP", textBox4.Text);
            LinqXML.write(MyPlugin.confirm, "Port", textBox5.Text);
            if (!int.TryParse(textBox5.Text, out tmp))
            {
                MessageBox.Show("请正确输入数字");
                return;
            }
            MyPlugin.Port      = int.Parse(textBox5.Text);
            MyPlugin.ipaddress = textBox4.Text;
            button.Text        = "已设置";
        }
コード例 #3
0
        /// <summary>
        /// 应用启动,完成插件线程、全局变量等自身运行所必须的初始化工作。
        /// </summary>
        public override void Startup()
        {
            //完成插件线程、全局变量等自身运行所必须的初始化工作。

            FormSettings frm = new FormSettings();
            //frm.ShowDialog();
            string check = LinqXML.read(confirm, "群号");

            if (check == "")
            {
                MessageBox.Show("未设置群号,请设置"); frm.ShowDialog();
            }
            else
            {
                GroupSet = long.Parse(check);
            }
            ipaddress = LinqXML.read(confirm, "IP");
            if (ipaddress == "")
            {
                MessageBox.Show("未设置IP,请设置"); frm.ShowDialog();
            }
            else
            {
                ipaddress = LinqXML.read(confirm, "IP");
            }
            check = LinqXML.read(confirm, "Port");
            if (check == "")
            {
                MessageBox.Show("未设置端口,请设置"); frm.ShowDialog();
            }
            else
            {
                Port = int.Parse(LinqXML.read(confirm, "Port"));
            }
            CQ.SendGroupMessage(GroupSet, "机器人已启动-作者yan_color");
            socket.start_socket();
        }
コード例 #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     LinqXML.write(MyPlugin.confirm, "admin", textBox2.Text);
     button2.Text = "添加成功";
 }
コード例 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     LinqXML.write(MyPlugin.confirm, "群号", textBox1.Text);
     MyPlugin.GroupSet = long.Parse(textBox1.Text);
     button1.Text      = "设置成功";
 }
コード例 #6
0
 /// <summary>
 /// Type=2 群消息。
 /// </summary>
 /// <param name="subType">子类型,目前固定为1。</param>
 /// <param name="sendTime">发送时间(时间戳)。</param>
 /// <param name="fromGroup">来源群号。</param>
 /// <param name="fromQQ">来源QQ。</param>
 /// <param name="fromAnonymous">来源匿名者。</param>
 /// <param name="msg">消息内容。</param>
 /// <param name="font">字体。</param>
 public override void GroupMessage(int subType, int sendTime, long fromGroup, long fromQQ, string fromAnonymous, string msg, int font)
 {
     // 处理群消息。
     if (fromGroup == GroupSet)
     {
         string x = msg.Substring(0, 4);
         if (x == "服务器:" || x == "服务器:")
         {
             string reply = LinqXML.read(confirm, fromQQ.ToString());
             if (reply != "")
             {
                 text = reply + ':' + RemoveLeft(msg, 4);
                 text = "群消息" + text;
             }
             else
             {
                 CQ.SendGroupMessage(fromGroup, "检测到你没有绑定服务器id,发送“绑定[id]”来绑定(中间没空格也不用[id:]),如:绑定yan_color");
             }
         }
         if (msg.IndexOf("绑定") == 0)
         {
             if (LinqXML.read(confirm, fromQQ.ToString()) == "")
             {
                 string a = msg.Replace("绑定", "");
                 msg = a;
                 if (a == "")
                 {
                     CQ.SendGroupMessage(GroupSet, "id为空");
                 }
                 else if (a == "id")
                 {
                     CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "绑定失败,禁止绑定为:id");
                 }
                 else if (a == "ID")
                 {
                     CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "绑定失败,禁止绑定为:ID");
                 }
                 else if (a.IndexOf("id:") == 0 || a.IndexOf("iD:") == 0 || a.IndexOf("ID:") == 0 || a.IndexOf("Id:") == 0 ||
                          a.IndexOf("id:") == 0 || a.IndexOf("iD:") == 0 || a.IndexOf("ID:") == 0 || a.IndexOf("Id:") == 0)
                 {
                     a = msg.Remove(0, 2);
                     a = a.Replace("-", "");
                     LinqXML.write(confirm, fromQQ.ToString(), a);
                     CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "绑定id:" + msg.Replace("绑定", "") + "成功!");
                 }
                 else
                 {
                     LinqXML.write(confirm, fromQQ.ToString(), msg.Replace("绑定", ""));
                     CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "绑定id:" + msg.Replace("绑定", "") + "成功!");
                 }
             }
             else
             {
                 CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "你已经绑定过了,想换id私聊服主去吧");
             }
         }
         if (msg == "在线人数")
         {
             CQ.SendGroupMessage(GroupSet, "查询中");
             text = "在线人数:";
         }
         if (msg == "服务器状态")
         {
             CQ.SendGroupMessage(GroupSet, "查询中,如果没有回复,则证明服务器未开启");
             text = "指令服务器状态";
         }
         if (msg.IndexOf("功能菜单") == 0)
         {
             CQ.SendGroupMessage(fromGroup, "输入“在线人数”可以查询服务器在线人数。\r\n输入“服务器状态”可以查询服务器是否在运行。\r\n输入“服务器:【内容】”可以向服务器里发送消息。\r\n输入“金钱查询”可以查询游戏币。");
         }
         if (msg.IndexOf("机器人:关闭") == 0)
         {
             if (LinqXML.read(confirm, "admin") == fromQQ.ToString())
             {
                 CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "正在关闭");
                 socket.stop_socket();
                 CQ.SendGroupMessage(GroupSet, CQ.CQCode_At(fromQQ) + "已关闭");
             }
         }
     }
 }