示例#1
0
        public void ProcessPrivateMessage(PrivateMessageReceivedContext context)
        {
            if (context.Message.IndexOf("宠物绑定") == 0)
            {
                XmlSolve.del("qq_pet_uin", context.FromQq.ToString());
                XmlSolve.del("qq_pet_skey", context.FromQq.ToString());
                string[] str2;
                int      count_temp = 0;
                str2 = context.Message.Replace("宠物绑定", "").Split('/');
                foreach (string i in str2)
                {
                    if (count_temp == 0)
                    {
                        XmlSolve.insert("qq_pet_uin", context.FromQq.ToString(), i);
                        count_temp++;
                    }
                    else if (count_temp == 1)
                    {
                        XmlSolve.insert("qq_pet_skey", context.FromQq.ToString(), i);
                        count_temp++;
                    }
                }
                _mahuaApi.SendPrivateMessage(context.FromQq).Text("宠物绑定成功!").Done();
            }
            else
            {
                string replay = MessageSolve.GetReplay(context.FromQq, context.Message, _mahuaApi);
                if (replay != "")
                {
                    _mahuaApi.SendPrivateMessage(context.FromQq, replay);
                }
            }


            // 异步发送消息,不能使用 _mahuaApi 实例,需要另外开启Session
            //Task.Factory.StartNew(() =>
            //{
            //    using (var robotSession = MahuaRobotManager.Instance.CreateSession())
            //    {
            //        var api = robotSession.MahuaApi;
            //        api.SendPrivateMessage(context.FromQq, "异步的嘤嘤嘤");
            //    }
            //});
        }
 public void ProcessGroupMemberChanged(GroupMemberChangedContext context)
 {
     if (context.GroupMemberChangedType.ToString() == "Increased") //进群
     {
         _mahuaApi.SendGroupMessage(context.FromGroup, "欢迎" + Tools.At(context.JoinedOrLeftQq) + "进群!请仔细阅读群公告哦~");
     }
     else if (context.GroupMemberChangedType.ToString() == "Decreased")//退群
     {
         if (context.FromGroup == "241464054")
         {
             string player = XmlSolve.xml_get("bind_qq", context.JoinedOrLeftQq);
             if (player != "")
             {
                 _mahuaApi.SendGroupMessage("567145439", "检测到玩家" + player + "已退群,请管理进入游戏,执行\r\n/code " +
                                            MinecraftSolve.DelNewCode(player) + "\r\n命令来删除该玩家的白名单");
                 XmlSolve.del("bind_qq_wait", context.JoinedOrLeftQq);
                 XmlSolve.del("bind_qq", context.JoinedOrLeftQq);
             }
         }
     }
 }