예제 #1
0
파일: CQX.cs 프로젝트: ilzozvye1/CSDN_Auto
 public static void SendMessage(int type, long group, long qqNumber, string message)
 {
     if (type == 21)
     {
         SendPrivateMessage(qqNumber, message);
     }
     else if (type == 2)
     {
         SendGroupMessage(group, CQ.CQCode_At(qqNumber) + "\n" + message);
     }
     else if (type == 4)
     {
         SendDiscussMessage(group, CQ.CQCode_At(qqNumber) + "\n" + message);
     }
 }
예제 #2
0
 /// <summary>
 /// 在指定的群中@某人。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSendAt_Click(object sender, RoutedEventArgs e)
 {
     CQ.SendGroupMessage(Convert.ToInt64(txtGroupNumber.Text), CQ.CQCode_At(Convert.ToInt64(this.txtQQNumber.Text)));
 }
예제 #3
0
파일: MyPlugin.cs 프로젝트: zzzzzga/CQP
 /// <summary>
 /// Type=4 讨论组消息。
 /// </summary>
 /// <param name="subType">子类型,目前固定为1。</param>
 /// <param name="sendTime">发送时间(时间戳)。</param>
 /// <param name="fromDiscuss">来源讨论组。</param>
 /// <param name="fromQQ">来源QQ。</param>
 /// <param name="msg">消息内容。</param>
 /// <param name="font">字体。</param>
 public override void DiscussMessage(int subType, int sendTime, long fromDiscuss, long fromQQ, string msg, int font)
 {
     // 处理讨论组消息。
     CQ.SendDiscussMessage(fromDiscuss, String.Format("[{0}]{1}你发的讨论组消息是:{2}", CQ.ProxyType, CQ.CQCode_At(fromQQ), msg));
 }
예제 #4
0
파일: MyPlugin.cs 프로젝트: zzzzzga/CQP
        /// <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)
        {
            // 处理群消息。
            var groupMember = CQ.GetGroupMemberInfo(fromGroup, fromQQ);

            CQ.SendGroupMessage(fromGroup, String.Format("[{4}]{0} 你的群名片:{1}, 入群时间:{2}, 最后发言:{3}。", CQ.CQ码_At(fromQQ),
                                                         groupMember.GroupCard, groupMember.JoinTime, groupMember.LastSpeakingTime, CQ.ProxyType));
            CQ.SendGroupMessage(fromGroup, String.Format("[{0}]{1}你发的群消息是:{2}", CQ.ProxyType, CQ.CQCode_At(fromQQ), msg));
        }
예제 #5
0
파일: MyPlugin.cs 프로젝트: zzzzzga/CQP
 /// <summary>
 /// Type=11 群文件上传事件。
 /// </summary>
 /// <param name="subType">子类型,目前固定为1。</param>
 /// <param name="sendTime">发送时间(时间戳)。</param>
 /// <param name="fromGroup">来源群号。</param>
 /// <param name="fromQQ">来源QQ。</param>
 /// <param name="file">上传文件信息。</param>
 public override void GroupUpload(int subType, int sendTime, long fromGroup, long fromQQ, string file)
 {
     // 处理群文件上传事件。
     CQ.SendGroupMessage(fromGroup, String.Format("[{0}]{1}你上传了一个文件:{2}", CQ.ProxyType, CQ.CQCode_At(fromQQ), file));
 }
예제 #6
0
        /// <summary>
        /// Type=21 私聊消息。
        /// </summary>
        /// <param name="subType">子类型,11/来自好友 1/来自在线状态 2/来自群 3/来自讨论组。</param>
        /// <param name="sendTime">发送时间(时间戳)。</param>
        /// <param name="fromQQ">来源QQ。</param>
        /// <param name="msg">消息内容。</param>
        /// <param name="font">字体。</param>
        public override void PrivateMessage(int subType, int sendTime, long fromQQ, string msg, int font)
        {
            // 处理私聊消息。
            logs.Log_write("私聊消息" + '[' + fromQQ.ToString() + "][" + CQ.GetQQName(fromQQ) + "]:" + msg);
            if (msg.IndexOf(XML.read(config_read.Event, "绑定文本")) == 0)
            {
                string player = null;
                if (Mysql_mode == true)
                {
                    player = Mysql.mysql_search(Mysql.Mysql_player, fromQQ.ToString());
                }
                else
                {
                    player = XML.read(config_read.player, fromQQ.ToString());
                }
                if (player == null)
                {
                    string player_name = msg.Replace(XML.read(config_read.Event, "绑定文本"), "");
                    if (player_name == " " || player_name == "" || use.IsNatural_Number(player_name) == false)
                    {
                        CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "绑定失败,请检查你的ID");
                    }
                    else
                    {
                        player_name = player_name.Trim();
                        if (Mysql_mode == true)
                        {
                            if (Mysql.mysql_search(Mysql.Mysql_notid, player_name.ToLower()) == "notid")
                            {
                                CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "禁止绑定ID:" + player_name);
                                return;
                            }
                            Mysql.mysql_add(Mysql.Mysql_player, fromQQ.ToString(), player_name.ToString());
                        }
                        else
                        {
                            if (XML.read(config_read.notid, player_name.ToLower()) == "notid")
                            {
                                CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "禁止绑定ID:" + player_name);
                                return;
                            }
                            XML.write(config_read.player, fromQQ.ToString(), player_name);
                        }

                        CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "绑定ID:" + player_name + "成功!");

                        string qq_admin = XML.read(config_read.admin, "发送给的人");
                        if (qq_admin != null)
                        {
                            CQ.SendPrivateMessage(long.Parse(qq_admin), "玩家[" + CQ.GetQQName(fromQQ) + "]绑定了ID:[" + player_name + "]");
                        }
                    }
                }
                else
                {
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "你已经绑定ID了,请找腐竹更改");
                }
            }
            if (msg.IndexOf(XML.read(config_read.Event, "禁言文本")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                string player      = msg.Replace(XML.read(config_read.Event, "禁言文本"), "");
                string player_name = null;
                if (player.IndexOf("[CQ") != -1)
                {
                    player = use.get_string(player, "=", "]");
                    if (Mysql_mode == true)
                    {
                        player_name = Mysql.mysql_search(Mysql.Mysql_player, player);
                    }
                    else
                    {
                        player_name = XML.read(config_read.player, player);
                    }
                }
                else
                {
                    player_name = player;
                }
                player_name = player_name.Trim();
                if (player_name == null)
                {
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "该玩家未绑定ID");
                }
                else
                {
                    if (Mysql_mode == true)
                    {
                        Mysql.mysql_add(Mysql.Mysql_mute, player_name.ToLower(), "true");
                    }
                    else
                    {
                        XML.write(config_read.mute, player_name.ToLower(), "true");
                    }
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "已禁言:[" + player_name + "]");
                }
            }
            if (msg.IndexOf(XML.read(config_read.Event, "解禁文本")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                string player      = msg.Replace(XML.read(config_read.Event, "解禁文本"), "");
                string player_name = null;
                if (player.IndexOf("[CQ") != -1)
                {
                    player = use.get_string(player, "=", "]");
                    if (Mysql_mode == true)
                    {
                        player_name = Mysql.mysql_search(Mysql.Mysql_player, player);
                    }
                    else
                    {
                        player_name = XML.read(config_read.player, player);
                    }
                }
                else
                {
                    player_name = player;
                }
                player_name = player_name.Trim();
                if (player_name == null)
                {
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "该玩家未绑定ID");
                }
                else
                {
                    if (Mysql_mode == true)
                    {
                        Mysql.mysql_add(Mysql.Mysql_mute, player_name.ToLower(), "false");
                    }
                    else
                    {
                        XML.write(config_read.mute, player_name.ToLower(), "false");
                    }
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "已解禁:[" + player_name + "]");
                }
            }
            if (msg.IndexOf(XML.read(config_read.Event, "查询玩家ID")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                string player = msg.Replace(XML.read(config_read.Event, "查询玩家ID"), "");
                player = use.get_string(player, "=", "]");
                string player_name = null;
                if (Mysql_mode == true)
                {
                    player_name = Mysql.mysql_search(Mysql.Mysql_player, fromQQ.ToString());
                }
                else
                {
                    player_name = XML.read(player, fromQQ.ToString());
                }
                CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "玩家ID:" + player_name);
            }
            if (msg.IndexOf(XML.read(config_read.Event, "修改玩家ID")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                string player      = msg.Replace(XML.read(config_read.Event, "修改玩家ID"), "");
                string player_name = player;
                player      = use.get_string(player, "=", "]");
                player_name = use.get_string(player_name, "]");
                player_name = player_name.Trim();
                if (Mysql_mode == true)
                {
                    XML.write(player, player, player_name);
                }
                else
                {
                    Mysql.mysql_add(Mysql.Mysql_player, player, player_name);
                }

                CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "已修改玩家[" + player + "]ID为:" + player_name);
            }
            if (msg == XML.read(config_read.Event, "维护文本") && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                if (XML.read(config_read.config, "维护模式") == "关")
                {
                    XML.write(config_read.config, "维护模式", "开");
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "服务器维护模式已开启");
                    server = false;
                    return;
                }
                else
                {
                    XML.write(config_read.config, "维护模式", "关");
                    CQ.SendPrivateMessage(fromQQ, CQ.CQCode_At(fromQQ) + "服务器维护模式已关闭");
                    server = true;
                    return;
                }
            }
            if (msg.IndexOf("打开菜单") == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                CQ.SendPrivateMessage(fromQQ, "已打开,请前往后台查看");
                OpenSettingForm();
            }
            if (msg == XML.read(config_read.Event, "机器人功能-重读配置文件") && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                CQ.SendPrivateMessage(fromQQ, "开始重读配置文件");
                config_read.read_config();
                CQ.SendPrivateMessage(fromQQ, "重读完成");
            }
            if (msg == XML.read(config_read.Event, "机器人功能-内存回收") && XML.read(config_read.admin, fromQQ.ToString()) != null)
            {
                try
                {
                    GC.Collect();
                    CQ.SendPrivateMessage(fromQQ, "内存回收完毕");
                }
                catch (Exception exception)
                { }
            }
        }
예제 #7
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)
        {
            logs.Log_write('[' + fromGroup.ToString() + ']' + '[' + fromQQ.ToString() + "][" + CQ.GetQQName(fromQQ) + "]:" + msg);
            // 处理群消息。
            if (fromGroup == GroupSet1 || fromGroup == GroupSet2 || fromGroup == GroupSet3)
            {
                if (XML.read(config_read.message, msg) != "" && XML.read(config_read.message, "启用") == "true")
                {
                    CQ.SendGroupMessage(fromGroup, XML.read(config_read.message, msg));
                }
                if (XML.read(config_read.config, "发送消息") == "当然!")
                {
                    if (server == true && socket.ready == true)
                    {
                        if ((fromGroup == GroupSet2 && Group2_on == true) || (fromGroup == GroupSet3 && Group3_on == true) || fromGroup == GroupSet1)
                        {
                            string play_name = null;
                            if (Mysql_mode == true)
                            {
                                play_name = Mysql.mysql_search(Mysql.Mysql_player, fromQQ.ToString());
                            }
                            else
                            {
                                play_name = XML.read(config_read.player, fromQQ.ToString());
                            }
                            if (play_name != null)
                            {
                                if (Mysql_mode == true)
                                {
                                    if (Mysql.mysql_search(Mysql.Mysql_mute, play_name.ToLower()) == "true")
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    if (XML.read(config_read.mute, play_name.ToLower()) == "true")
                                    {
                                        return;
                                    }
                                }
                                string send;
                                send = XML.read(config_read.config, "发送文本");
                                send = send.Replace("%player%", play_name);
                                msg  = use.remove_pic(msg);
                                if (msg == "")
                                {
                                    return;
                                }
                                msg  = use.get_at(msg);
                                send = send.Replace("%message%", use.remove_pic(msg));
                                socket.Send("群消息" + send, socket.MCserver);
                            }
                        }
                    }
                }
                else if (msg.IndexOf(XML.read(config_read.Event, "发送文本")) == 0 && XML.read(config_read.config, "发送消息") == "不!")
                {
                    if ((fromGroup == GroupSet2 && Group2_on == false) || (fromGroup == GroupSet3 && Group3_on == false))
                    {
                        CQ.SendGroupMessage(fromGroup, "该群没有开启聊天功能");
                    }
                    else if (server == true)
                    {
                        if (socket.ready == true)
                        {
                            string play_name = null;
                            if (Mysql_mode == true)
                            {
                                play_name = Mysql.mysql_search(Mysql.Mysql_player, fromQQ.ToString());
                            }
                            else
                            {
                                play_name = XML.read(config_read.player, fromQQ.ToString());
                            }
                            if (play_name != null && play_name != "")
                            {
                                if (Mysql_mode == true)
                                {
                                    if (Mysql.mysql_search(Mysql.Mysql_mute, play_name.ToLower()) == "true")
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    if (XML.read(config_read.mute, play_name.ToLower()) == "true")
                                    {
                                        return;
                                    }
                                }
                                string send;
                                send = XML.read(config_read.config, "发送文本");
                                send = send.Replace("%player%", play_name);
                                msg  = msg.Replace(XML.read(config_read.Event, "发送文本"), "");
                                msg  = use.remove_pic(msg);
                                if (msg == "")
                                {
                                    return;
                                }
                                msg  = use.get_at(msg);
                                send = send.Replace("%message%", use.remove_pic(msg));
                                socket.Send("群消息" + send, socket.MCserver);
                            }
                            else
                            {
                                CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "检测到你没有绑定服务器ID,发送:" + XML.read(config_read.Event, "绑定文本") + "ID来绑定,如:" +
                                                    "\n" + XML.read(config_read.Event, "绑定文本") + "Color_yr");
                            }
                        }
                        else
                        {
                            CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "发送失败,请稍后尝试");
                        }
                    }
                    else
                    {
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + XML.read(config_read.Event, "服务器维护文本"));
                    }
                }
                if (msg == XML.read(config_read.Event, "在线人数"))
                {
                    if (server == true)
                    {
                        if (socket.ready == true)
                        {
                            if (fromGroup == GroupSet1)
                            {
                                Group = 1;
                            }
                            else if (fromGroup == GroupSet2)
                            {
                                Group = 2;
                            }
                            else if (fromGroup == GroupSet3)
                            {
                                Group = 3;
                            }
                            socket.Send("在线人数", socket.MCserver);
                        }
                        else
                        {
                            CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "发送失败,请稍后尝试");
                        }
                    }
                    else
                    {
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + XML.read(config_read.Event, "服务器维护文本"));
                    }
                }
                if (msg == XML.read(config_read.Event, "服务器状态"))
                {
                    if (server == true)
                    {
                        if (socket.ready == true)
                        {
                            CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "查询中,如果没有回复,则证明服务器未开启");
                            if (fromGroup == GroupSet1)
                            {
                                Group = 1;
                            }
                            else if (fromGroup == GroupSet2)
                            {
                                Group = 2;
                            }
                            else if (fromGroup == GroupSet3)
                            {
                                Group = 3;
                            }
                            socket.Send("服务器状态", socket.MCserver);
                        }
                        else
                        {
                            CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "发送失败,请稍后尝试");
                        }
                    }
                    else
                    {
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + XML.read(config_read.Event, "服务器维护文本"));
                    }
                }
                if (msg.IndexOf(XML.read(config_read.Event, "绑定文本")) == 0)
                {
                    string player = null;
                    if (Mysql_mode == true)
                    {
                        player = Mysql.mysql_search(Mysql.Mysql_player, fromQQ.ToString());
                    }
                    else
                    {
                        player = XML.read(config_read.player, fromQQ.ToString());
                    }
                    if (player == null)
                    {
                        string player_name = msg.Replace(XML.read(config_read.Event, "绑定文本"), "");
                        if (player_name == " " || player_name == "" || use.IsNatural_Number(player_name) == false)
                        {
                            CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "绑定失败,请检查你的ID");
                        }
                        else
                        {
                            player_name = player_name.Trim();
                            if (Mysql_mode == true)
                            {
                                if (Mysql.mysql_search(Mysql.Mysql_notid, player_name.ToLower()) == "notid")
                                {
                                    CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "禁止绑定ID:" + player_name);
                                    return;
                                }
                                Mysql.mysql_add(Mysql.Mysql_player, fromQQ.ToString(), player_name);
                            }
                            else
                            {
                                if (XML.read(config_read.notid, player_name.ToLower()) == "notid")
                                {
                                    CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "禁止绑定ID:" + player_name);
                                    return;
                                }
                                XML.write(config_read.player, fromQQ.ToString(), player_name);
                            }

                            CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "绑定ID:" + player_name + "成功!");

                            string qq_admin = XML.read(config_read.admin, "发送给的人");
                            if (qq_admin != null)
                            {
                                CQ.SendPrivateMessage(long.Parse(qq_admin), "玩家[" + CQ.GetQQName(fromQQ) + "]绑定了ID:[" + player_name + "]");
                            }
                        }
                    }
                    else
                    {
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "你已经绑定ID了,请找腐竹更改");
                    }
                }
                if (msg.IndexOf(XML.read(config_read.Event, "禁言文本")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    string player      = msg.Replace(XML.read(config_read.Event, "禁言文本"), "");
                    string player_name = null;
                    if (player.IndexOf("[CQ") != -1)
                    {
                        player = use.get_string(player, "=", "]");
                        if (Mysql_mode == true)
                        {
                            player_name = Mysql.mysql_search(Mysql.Mysql_player, player);
                        }
                        else
                        {
                            player_name = XML.read(config_read.player, player);
                        }
                    }
                    else
                    {
                        player_name = player;
                    }
                    if (player_name == null)
                    {
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "ID无效");
                    }
                    else
                    {
                        if (Mysql_mode == true)
                        {
                            Mysql.mysql_add(Mysql.Mysql_mute, player_name.ToLower(), "true");
                        }
                        else
                        {
                            XML.write(config_read.mute, player_name.ToLower(), "true");
                        }
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "已禁言:[" + player_name + "]");
                    }
                }
                if (msg.IndexOf(XML.read(config_read.Event, "解禁文本")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    string player      = msg.Replace(XML.read(config_read.Event, "解禁文本"), "");
                    string player_name = null;
                    if (player.IndexOf("[CQ") != -1)
                    {
                        player = use.get_string(player, "=", "]");
                        if (Mysql_mode == true)
                        {
                            player_name = Mysql.mysql_search(Mysql.Mysql_player, player);
                        }
                        else
                        {
                            player_name = XML.read(config_read.player, player);
                        }
                    }
                    else
                    {
                        player_name = player;
                    }
                    if (player_name == null)
                    {
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "ID无效");
                    }
                    else
                    {
                        if (Mysql_mode == true)
                        {
                            Mysql.mysql_add(Mysql.Mysql_mute, player_name.ToLower(), "false");
                        }
                        else
                        {
                            XML.write(config_read.mute, player_name.ToLower(), "false");
                        }
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "已解禁:[" + player_name + "]");
                    }
                }
                if (msg.IndexOf(XML.read(config_read.Event, "查询玩家ID")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    string player = msg.Replace(XML.read(config_read.Event, "查询玩家ID"), "");
                    player = use.get_string(player, "=", "]");
                    string player_name = null;
                    if (Mysql_mode == true)
                    {
                        player_name = Mysql.mysql_search(Mysql.Mysql_player, fromQQ.ToString());
                    }
                    else
                    {
                        player_name = XML.read(player, fromQQ.ToString());
                    }
                    CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "玩家ID:" + player_name);
                }
                if (msg.IndexOf(XML.read(config_read.Event, "修改玩家ID")) == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    string player      = msg.Replace(XML.read(config_read.Event, "修改玩家ID"), "");
                    string player_name = player;
                    player      = use.get_string(player, "=", "]");
                    player_name = use.get_string(player_name, "]");
                    player_name = player_name.Trim();
                    if (Mysql_mode == true)
                    {
                        Mysql.mysql_add(Mysql.Mysql_player, player, player_name);
                    }
                    else
                    {
                        XML.write(player, player, player_name);
                    }

                    CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "已修改玩家[" + player + "]ID为:" + player_name);
                }
                if (msg == XML.read(config_read.Event, "维护文本") && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    if (XML.read(config_read.config, "维护模式") == "关")
                    {
                        XML.write(config_read.config, "维护模式", "开");
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "服务器维护模式已开启");
                        server = false;
                        return;
                    }
                    else
                    {
                        XML.write(config_read.config, "维护模式", "关");
                        CQ.SendGroupMessage(fromGroup, CQ.CQCode_At(fromQQ) + "服务器维护模式已关闭");
                        server = true;
                        return;
                    }
                }
                if (msg.IndexOf("打开菜单") == 0 && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    CQ.SendGroupMessage(fromGroup, "已打开,请前往后台查看");
                    OpenSettingForm();
                }
                if (msg == XML.read(config_read.Event, "机器人功能-重读配置文件") && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    CQ.SendGroupMessage(fromGroup, "开始重读配置文件");
                    config_read.read_config();
                    CQ.SendGroupMessage(fromGroup, "重读完成");
                }
                if (msg == XML.read(config_read.Event, "机器人功能-内存回收") && XML.read(config_read.admin, fromQQ.ToString()) != null)
                {
                    try
                    {
                        GC.Collect();
                        CQ.SendGroupMessage(fromGroup, "内存回收完毕");
                    }
                    catch (Exception exception)
                    { }
                }
            }
        }
예제 #8
0
파일: CQX.cs 프로젝트: ilzozvye1/CSDN_Auto
 //
 // Summary:
 //     获取 @指定QQ 的操作代码。
 //
 // Parameters:
 //   qqNumber:
 //     指定的QQ号码。
 //     当该参数为-1时,操作为 @全部成员。
 //
 // Returns:
 //     CQ @操作代码。
 public static string CQCode_At(long qqNumber)
 {
     return(CQ.CQCode_At(qqNumber));
 }
예제 #9
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) + "已关闭");
             }
         }
     }
 }
예제 #10
0
 /// <summary>
 /// Type=11 群文件上传事件。
 /// </summary>
 /// <param name="subType">子类型,目前固定为1。</param>
 /// <param name="sendTime">发送时间(时间戳)。</param>
 /// <param name="fromGroup">来源群号。</param>
 /// <param name="fromQQ">来源QQ。</param>
 /// <param name="file">上传文件信息。</param>
 public override void GroupUpload(int subType, int sendTime, long fromGroup, long fromQQ, string file)
 {
     // 处理群文件上传事件。
     if (fromGroup == GroupSet1)
     {
         CQ.SendGroupMessage(fromGroup, String.Format("{1}上传了一个文件", CQ.ProxyType, CQ.CQCode_At(fromQQ), file));
     }
 }
예제 #11
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 == GroupSet1)
     {
         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(GroupSet1, "检测到你没有绑定服务器ID,发送“绑定:ID”来绑定,如:绑定:yan_color");
             }
         }
         if (msg.IndexOf("绑定:") == 0)
         {
             if (LinqXML.read(confirm, fromQQ.ToString()) == "")
             {
                 string a = msg.Replace("绑定:", "");
                 msg = a;
                 if (a == " " || a == "")
                 {
                     CQ.SendGroupMessage(GroupSet1, CQ.CQCode_At(fromQQ) + "绑定失败,禁止绑定为空");
                 }
                 else
                 {
                     var sb = new StringBuilder(a);
                     sb.Replace(":", string.Empty);
                     sb.Replace(" ", string.Empty);
                     LinqXML.write(confirm, fromQQ.ToString(), sb.ToString());
                     CQ.SendGroupMessage(GroupSet1, CQ.CQCode_At(fromQQ) + "绑定ID:" + msg.Replace("绑定", "") + "成功!");
                 }
             }
             else
             {
                 CQ.SendGroupMessage(GroupSet1, CQ.CQCode_At(fromQQ) + "你已经绑定过了,想换ID私聊服主去吧");
             }
         }
         if (msg == "在线人数")
         {
             CQ.SendGroupMessage(GroupSet1, "查询中");
             text = "在线人数:";
             g    = 1;
         }
         if (msg == "服务器状态")
         {
             CQ.SendGroupMessage(GroupSet1, "查询中,如果没有回复,则证明服务器未开启");
             text = "服务器状态";
             g    = 1;
         }
         if (msg.IndexOf("功能菜单") == 0)
         {
             CQ.SendGroupMessage(GroupSet1, "输入“绑定:ID”可以绑定你的游戏ID。\r\n输入“在线人数”可以查询服务器在线人数。\r\n输入“服务器状态”可以查询服务器是否在运行。\r\n输入“服务器:【内容】”可以向服务器里发送消息。");
         }
     }
     if (fromGroup == GroupSet2)
     {
         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(GroupSet2, "检测到你没有绑定服务器ID,发送“绑定:ID”来绑定,如:绑定:yan_color");
             }
         }
         if (msg.IndexOf("绑定:") == 0)
         {
             if (LinqXML.read(confirm, fromQQ.ToString()) == "")
             {
                 string a = msg.Replace("绑定:", "");
                 msg = a;
                 if (a == " " || a == "")
                 {
                     CQ.SendGroupMessage(GroupSet2, CQ.CQCode_At(fromQQ) + "绑定失败,禁止绑定为空");
                 }
                 else
                 {
                     var sb = new StringBuilder(a);
                     sb.Replace(":", string.Empty);
                     sb.Replace(" ", string.Empty);
                     LinqXML.write(confirm, fromQQ.ToString(), sb.ToString());
                     CQ.SendGroupMessage(GroupSet2, CQ.CQCode_At(fromQQ) + "绑定ID:" + msg.Replace("绑定:", "") + "成功!");
                 }
             }
             else
             {
                 CQ.SendGroupMessage(GroupSet2, CQ.CQCode_At(fromQQ) + "你已经绑定过了,想换ID私聊服主去吧");
             }
         }
         if (msg == "在线人数")
         {
             CQ.SendGroupMessage(GroupSet2, "查询中");
             text = "在线人数:";
             g    = 2;
         }
         if (msg == "服务器状态")
         {
             CQ.SendGroupMessage(GroupSet2, "查询中,如果没有回复,则证明服务器未开启");
             text = "服务器状态";
             g    = 2;
         }
         if (msg.IndexOf("功能菜单") == 0)
         {
             CQ.SendGroupMessage(GroupSet2, "输入“绑定:ID”可以绑定你的游戏ID。\r\n输入“在线人数”可以查询服务器在线人数。\r\n输入“服务器状态”可以查询服务器是否在运行。\r\n输入“服务器:【内容】”可以向服务器里发送消息。");
         }
     }
 }