Ejemplo n.º 1
0
 public static bool NetPost(string url, string param, Action <Stream> onLoad, Action <Exception> onError, string charset = "")
 {
     try
     {
         byte[]         bs      = Encoding.ASCII.GetBytes(param);
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
         request.Method        = "POST";
         request.ContentType   = "application/x-www-form-urlencoded" + charset;
         request.ContentLength = bs.Length;
         using (Stream reqStream = request.GetRequestStream())
         {
             reqStream.Write(bs, 0, bs.Length);
         }
         using (WebResponse wr = request.GetResponse())
         {
             var stream = wr.GetResponseStream();
             onLoad(stream);
             stream.Close();
             stream.Dispose();
             return(true);
         }
     }
     catch (System.Exception e)
     {
         IRQQApi.Api_OutPutLog(e.ToString());
         if (onError != null)
         {
             onError(e);
         }
         return(false);
     }
 }
Ejemplo n.º 2
0
 public static void Broadcast(string text)
 {
     foreach (var kv in DataRunTime.persons)
     {
         IRQQApi.Api_SendMsg(Config.RobotQQ, 2, kv.Key, "", text, -1);
     }
 }
Ejemplo n.º 3
0
 public static bool NetGet(string url, Action <Stream> onLoad, Action <Exception> onError)
 {
     try
     {
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
         request.Method = "GET";
         using (WebResponse wr = request.GetResponse())
         {
             var stream = wr.GetResponseStream();
             onLoad(stream);
             stream.Close();
             stream.Dispose();
             return(true);
         }
     }
     catch (System.Exception e)
     {
         IRQQApi.Api_OutPutLog(e.ToString());
         if (onError != null)
         {
             onError(e);
         }
         return(false);
     }
 }
Ejemplo n.º 4
0
        //private static JavaScriptSerializer js;

        ///// <summary>
        ///// 反序列化JSON字符串为对象,如果用Object装的话就是 Dictionary<String,Object>
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="str"></param>
        ///// <returns></returns>
        //public static T Deserialize<T>(this String str)
        //{
        //    if (js == null)
        //        js = new JavaScriptSerializer();
        //    return js.Deserialize<T>(str);
        //}

        /// <summary>
        /// 替换失效图片
        /// </summary>
        /// <param name="Msg"></param>
        /// <param name="RobotQQ"></param>
        /// <param name="MsgType">私聊为1 群为2</param>
        /// <returns></returns>
        public static String RegexRepleInvalidPic(String Msg, String RobotQQ, int MsgType)
        {
            foreach (Match item in Regex.Matches(Msg, "\\[IR:pic={.*}\\.jpg\\]"))
            {
                Msg = Msg.Replace(item.Value, "[IR:pic=" + IRQQApi.Api_GetPicLink(RobotQQ, MsgType, null, item.Value) + "]");
            }
            return(Msg);
        }
Ejemplo n.º 5
0
 public static string GetName(PersonData person)
 {
     if (person.NickName != "default")
     {
         return(IRQQApi.Api_GetGroupCard(Config.RobotQQ, person.GroupQQ, person.QQ));
     }
     return(person.NickName);
 }
Ejemplo n.º 6
0
        public static void Broadcast(string id, params object[] objs)
        {
            string content = string.Format(GetText(id), objs);

            foreach (var kv in DataRunTime.persons)
            {
                IRQQApi.Api_SendMsg(Config.RobotQQ, 2, kv.Key, "", content, -1);
            }
        }
Ejemplo n.º 7
0
        public static PersonData AddNewPerson(string group_qq, string qq, bool check = true)
        {
            if (check && !IsInited)
            {
                return(null);
            }
            PersonData person = new PersonData();

            person.GroupQQ  = group_qq;
            person.QQ       = qq;
            person.NickName = IRQQApi.Api_GetGroupCard(Config.RobotQQ, group_qq, qq);
            AddNewPerson(person);
            return(person);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 处理机器人列表按钮单击
        /// </summary>
        /// <param name="type"></param>
        private void DealRobotSelect(int type)
        {
            clbRobotList.ItemCheck -= cbList_SelectedIndexChanged;
            clbRobotList.SuspendLayout();
            string[] onlineList = new string[0];
            if (type == 3)
            {
                IntPtr ipOnlineList  = IRQQApi.Api_GetOnLineList();
                string strOnlineList = Marshal.PtrToStringAnsi(ipOnlineList);
                if (!string.IsNullOrWhiteSpace(strOnlineList))
                {
                    strOnlineList = (new Regex("\r\n")).Replace(strOnlineList, ";");
                    MoonLogger.Instance.Info("获取到在线机器人数据:" + strOnlineList + strOnlineList.Length);
                    onlineList = strOnlineList.Split(';');
                    MoonLogger.Instance.Info("获取到在线机器人总数:" + onlineList.Length);
                }
            }

            if (type == 3)
            {
                for (var i = 0; i < clbRobotList.Items.Count; i++)
                {
                    foreach (var item in onlineList)
                    {
                        bool found = clbRobotList.GetItemText(clbRobotList.Items[i]).Equals(item);
                        clbRobotList.SetItemChecked(i, found);
                        if (found)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                for (var i = 0; i < clbRobotList.Items.Count; i++)
                {
                    //选择在线
                    clbRobotList.SetItemChecked(i, type == 0 ? true : (type == 1 ? !clbRobotList.GetItemChecked(i) : false));
                    Application.DoEvents();
                }
            }
            clbRobotList.ResumeLayout();
            //手动触发一次
            cbList_SelectedIndexChanged(null, null);
            clbRobotList.ItemCheck += cbList_SelectedIndexChanged;
        }
Ejemplo n.º 9
0
        public static void NickNameChange(string group_qq, string qq, string newName, bool check = true)
        {
            if (check && !IsInited)
            {
                return;
            }
            var person = GetPerson(group_qq, qq);

            if (person == null)
            {
                person = AddNewPerson(group_qq, qq);
            }
            if (person == null)
            {
                return;
            }
            person.NickName = newName;
            IRQQApi.Api_OutPutLog(string.Format("改名 QQ:{0}", qq));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 初始化机器人列表
        /// </summary>
        private void InitQQList()
        {
            Dictionary <string, object> data = new Dictionary <string, object>();
            IntPtr ipQQList  = IRQQApi.Api_GetQQList();
            string strQQList = Marshal.PtrToStringAnsi(ipQQList);

            if (string.IsNullOrWhiteSpace(strQQList))
            {
                MessageBox.Show("获取已登陆QQ列表失败!");
                return;
            }
            string[] robotList = Regex.Split(strQQList, "\r\n", RegexOptions.IgnoreCase);
            clbRobotList.ItemCheck -= cbList_SelectedIndexChanged;
            clbRobotList.SuspendLayout();
            clbRobotList.Items.AddRange(robotList);
            DealRobotSelect(0);
            clbRobotList.ResumeLayout();
            clbRobotList.ItemCheck += cbList_SelectedIndexChanged;
        }
Ejemplo n.º 11
0
        public static void InitLocalization()
        {
            string path = Config.CachePath + "\\Localization.txt";

            localization = new Dictionary <string, string>();
            if (!File.Exists(path))
            {
                return;
            }
            string[] lines = File.ReadAllLines(path);
            foreach (var line in lines)
            {
                var kv = line.Split(new string[] { "|-zxc-|" }, StringSplitOptions.RemoveEmptyEntries);
                localization.Add(kv[0].Trim(), kv[1].Trim());
            }
            foreach (var kv in localization)
            {
                IRQQApi.Api_OutPutLog(kv.Key + " " + kv.Value);
            }
            IRQQApi.Api_OutPutLog("加载文本" + lines.Length.ToString() + "条");
        }
Ejemplo n.º 12
0
        public static void Response(string groupqq, string qq, string id, params object[] objs)
        {
            string content = string.Format(GetText(id), objs);

            IRQQApi.Api_SendMsg(Config.RobotQQ, 2, groupqq, qq, content, -1);
        }
Ejemplo n.º 13
0
 public static void Response(string groupqq, string qq, string text)
 {
     IRQQApi.Api_SendMsg(Config.RobotQQ, 2, groupqq, qq, text, -1);
 }
Ejemplo n.º 14
0
 public static void ResponseJson(string groupqq, string qq, string json)
 {
     IRQQApi.Api_SendJSON(Config.RobotQQ, 1, 2, groupqq, qq, json);
 }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="RobotQQ">机器人QQ         多Q版用于判定哪个QQ接收到该消息</param>
        /// <param name="MsgType">消息类型         接收到消息类型,该类型可在常量表中查询具体定义,此处仅列举: - 1 未定义事件 1 好友信息 2, 群信息 3, 讨论组信息 4, 群临时会话 5, 讨论组临时会话 6, 财付通转账</param>
        /// <param name="MsgCType">消息子类型      此参数在不同消息类型下,有不同的定义,暂定:接收财付通转账时 1为好友 2为群临时会话 3为讨论组临时会话    有人请求入群时,不良成员这里为1</param>
        /// <param name="MsgFrom">消息来源         此消息的来源,如:群号、讨论组ID、临时会话QQ、好友QQ等</param>
        /// <param name="TigObjF">触发对象_主动    主动发送这条消息的QQ,踢人时为踢人管理员QQ</param>
        /// <param name="TigObjC">触发对象_被动    被动触发的QQ,如某人被踢出群,则此参数为被踢出人QQ</param>
        /// <param name="Msg">消息内容             此参数有多重含义,常见为:对方发送的消息内容,但当IRC_消息类型为 某人申请入群,则为入群申请理由</param>
        /// <param name="MsgNum">消息序号          此参数暂定用于消息回复,消息撤回</param>
        /// <param name="MsgID">消息ID             此参数暂定用于消息撤回</param>
        /// <param name="RawMsg">原始信息          UDP收到的原始信息,特殊情况下会返回JSON结构(收到群验证事件时,这里为该事件seq)</param>
        /// <param name="Json">Json信息            JSON格式转账解析</param>
        /// <param name="pText">信息回传文本指针   此参数用于插件加载拒绝理由  用法:写到内存(“拒绝理由”,IRC_信息回传文本指针_Out)</param>
        /// <returns></returns>
        ///此子程序会分发IRC_机器人QQ接收到的所有:事件,消息;您可在此函数中自行调用所有参数
        public static int IR_Event(string RobotQQ, int MsgType, int MsgCType, string MsgFrom, string TigObjF, string TigObjC, string Msg, string MsgNum, string MsgID, string RawMsg, string Json, int pText)
        {
            if (MsgType == 1)
            {
                //IRQQApi.Api_SendMsg(RobotQQ, 1, "", MsgFrom, "发送的消息为:"+Msg, 0);
                //string sPicLink = IRQQApi.Api_GetPicLink(RobotQQ, 2, "1", Msg);
                //IRQQApi.Api_SendMsg(RobotQQ, 1, "", MsgFrom, "图片链接为:" + sPicLink, 0);
            }
            else if (MsgType == 2)
            {
                if (Msg == "#帮助")
                {
                    IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "#查询 查询你当前的雷币数量\n#查属性+[空格]+[属性名] 查询当前属性(目前仅开放了[幸运]属性)\n" +
                                        "#洗属性+[空格]+[属性名] 花费300雷币重置当前属性(目前仅开放了[幸运]属性)\n" +
                                        "#查技能 查看当前装备的技能\n" +
                                        "#洗技能 花费300雷币重置当前技能数值\n" +
                                        "*[幸运]属性会影响所有的几率事件", -1);
                }
                else if (Msg == "#查询")
                {
                    var oldGold = CurdToDB.SearchGoldFromDB(TigObjF);
                    IRQQUtil.WritePluginLogFile(logfile, "\n查询结果" + oldGold + "," + DateTime.Now);
                    if (oldGold == -1)
                    {
                        //string nickname = IRQQApi.Api_GetGroupCard(RobotQQ, MsgFrom, TigObjF);
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "你没创建人物!随便说一句话就自动创建人物辣!!", -1);
                    }
                    else
                    {
                        //string nickname = IRQQApi.Api_GetGroupCard(RobotQQ, MsgFrom, TigObjF);
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 当前拥有" + oldGold + "个穆雷币!", -1);
                    }
                }
                else if (Msg == "#洗属性 幸运")
                {
                    int iResult;
                    iResult = CurdToDB.SearchGoldFromDB(TigObjF);
                    if (iResult == -1)
                    {
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "没有你的角色!先发言创建角色吧!", -1);
                    }
                    else if (iResult >= 300)
                    {
                        Random rd     = new Random();
                        int    iLucky = rd.Next(1, 101);
                        CurdToDB.UpdateGoldToDB(TigObjF, iResult, -300);
                        CurdToDB.UpdateLuckyToDB(TigObjF, iLucky);
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "洗属性成功!你现在的幸运值为:" + iLucky + "点", -1);
                    }
                    else
                    {
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "你的雷币不够!洗属性需要300雷币,努力发言赚雷币吧", -1);
                    }
                }
                else if (Msg == "#查属性 幸运")
                {
                    int iResult;
                    iResult = CurdToDB.SearchLuckyFromDB(TigObjF);
                    if (iResult != -1)
                    {
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你的幸运值为:" + iResult + "点", -1);
                    }
                    else
                    {
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你没创建人物!随便说一句话就自动创建人物辣!!", -1);
                    }
                }
                else if (Msg == "#轮盘")
                {
                    //int oldGold = CurdToDB.SearchGoldFromDB(TigObjF);
                    //if (oldGold>=50)
                    //{

                    //    string iResult = IRQQMain.StartRollClub(TigObjF, MsgFrom);
                    //    if (iResult == "0")
                    //    {
                    //        //发起了
                    //        CurdToDB.UpdateGoldToDB(TigObjF, oldGold, -50);
                    //        oldGold = oldGold - 50;
                    //        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你花费50雷币 发起了 轮盘游戏!还缺4个人报名!\n你现在剩余"+ oldGold+"雷币!", -1);
                    //    }
                    //    else if (iResult.Length > 2)
                    //    {
                    //        //获胜

                    //        CurdToDB.UpdateGoldToDB(TigObjF, oldGold, -50);
                    //        oldGold = oldGold - 50;
                    //        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你现在剩余" + oldGold + "雷币!\n人满了开始抽奖!", -1);

                    //        int winOldGold = CurdToDB.SearchGoldFromDB(iResult);
                    //        CurdToDB.UpdateGoldToDB(iResult, winOldGold, 250);
                    //        int winGold = winOldGold + 250;
                    //        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + iResult + "]" + " 你中奖啦!!!那4个弟弟的雷币归你了!雷币+250!\n你现在剩余" + winGold + "雷币!", -1);
                    //    }
                    //    else if (iResult != "-1")
                    //    {
                    //        //参加

                    //        CurdToDB.UpdateGoldToDB(TigObjF, oldGold, -50);
                    //        int iplay = 5 - int.Parse(iResult);
                    //        oldGold = oldGold - 50;
                    //        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你花费50雷币 加入了 轮盘游戏!还缺" + iplay + "个人报名!\n你现在剩余" + oldGold + "雷币!", -1);
                    //    }
                    //    else if (iResult=="-1")
                    //    {
                    //        //出错了
                    //        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 不知道为什么轮盘游戏好像出错了!\n找GM吧!", -1);
                    //    }
                    //}
                    //else
                    //{
                    //    //钱不够
                    //    IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你的雷币不够50!", -1);
                    //}
                }
                else if (Msg == "#查技能")
                {
                    SkillThief skillThief = new SkillThief();
                    skillThief = CurdToDB.SearchSkillThiefFromDB(TigObjF);
                    if (skillThief == null)
                    {
                        //没有技能
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "你还不会任何技能!", -1);
                    }
                    else
                    {
                        //有技能
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "偷窃:随机偷取一名玩家随机数量的雷币\n" +
                                            "触发几率:" + skillThief.SkillChance + "%\n" +
                                            "偷窃范围:" + skillThief.EffLower + " - " + skillThief.EffUpper, -1);
                    }
                }
                else if (Msg == "#洗技能")
                {
                    SkillThief skillThief = new SkillThief();
                    skillThief = CurdToDB.SearchSkillThiefFromDB(TigObjF);
                    if (skillThief == null)
                    {
                        //没有技能
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "你还不会任何技能!", -1);
                    }
                    else
                    {
                        var oldGold = CurdToDB.SearchGoldFromDB(TigObjF);
                        IRQQUtil.WritePluginLogFile(logfile, "\n查询结果" + oldGold + "," + DateTime.Now);
                        if (oldGold == -1)
                        {
                            IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "你没创建人物!随便说一句话就自动创建人物辣!!", -1);
                        }
                        else if (oldGold < 300)
                        {
                            IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 当前拥有" + oldGold + "个穆雷币!\n" +
                                                " 洗技能需要300雷币!", -1);
                        }
                        else
                        {
                            CurdToDB.UpdateGoldToDB(TigObjF, oldGold, -300);
                            double luckyAddon = LuckyAddon.GetiLuckyAddon(TigObjF);
                            Random random     = new Random();
                            int    skillChance;
                            int    effLower;
                            int    effUpper;
                            int    effRange;
                            skillChance = random.Next(1, (int)(6 * luckyAddon));
                            effLower    = random.Next(0, (int)(41 * luckyAddon));
                            effRange    = random.Next(1, (int)(41 * luckyAddon));
                            effUpper    = effLower + effRange;
                            bool iBool = CurdToDB.UpdateSkillThiefToDB(TigObjF, skillChance, effLower, effUpper);
                            if (iBool)
                            {
                                IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "洗技能成功!\n" + "偷窃:随机偷取一名玩家随机数量的雷币\n" +
                                                    "触发几率:" + skillChance + "%\n" +
                                                    "偷窃范围:" + effLower + " - " + effUpper, -1);
                            }
                            else
                            {
                                IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + "不知道为什么洗技能失败了,联系GM吧!", -1);
                            }
                        }
                    }
                }
                else if (Msg.Length > 2)
                {
                    int iGold = GetGolds.DefaultGetGold(TigObjF);
                    if (iGold == -1)
                    {
                        return(1);
                    }
                    else if (iGold > 1000)
                    {
                        string nickname = IRQQApi.Api_GetGroupCard(RobotQQ, MsgFrom, TigObjF);
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 你就是天选之人?" + nickname + "击败Boss爆了一个藏宝图,找到了宝藏,共计获得了" + iGold + "个雷币!", -1);
                    }
                    else if (iGold > 100)
                    {
                        //string nickname = IRQQApi.Api_GetGroupCard(RobotQQ, MsgFrom, TigObjF);
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 打怪爆了一个金闪闪的钥匙,打开怪物的保险柜后收获了" + iGold + "个雷币!", -1);
                    }
                    else if (iGold > 10)
                    {
                        //string nickname = IRQQApi.Api_GetGroupCard(RobotQQ, MsgFrom, TigObjF);
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 在村民家的保险箱中摸到了" + iGold + "个雷币!", -1);
                    }
                    //判断是否获得技能
                    SkillThief skillThief = new SkillThief();
                    skillThief = GetGolds.DefaultGetSkill(TigObjF);
                    if (skillThief != null)
                    {
                        IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 击杀了一只稀有精英怪,获得了一本盗贼技能书.\n偷窃:随机偷取一名玩家随机数量的雷币\n" +
                                            "触发几率:" + skillThief.SkillChance + "%\n" +
                                            "偷窃范围:" + skillThief.EffLower + " - " + skillThief.EffUpper, -1);
                    }
                    //释放技能
                    ThiefAttack thiefAttack = new ThiefAttack();
                    thiefAttack = SkillAttack.ThiefSkillAttack(TigObjF);
                    if (thiefAttack != null)
                    {
                        if (TigObjF == thiefAttack.QQid)
                        {
                            IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" + " 幸运的释放了偷窃技能,但不幸的是目标是自己\n" +
                                                "将" + thiefAttack.ThiefGold + "个穆雷币从左口袋放进了右口袋", -1);
                        }
                        else
                        {
                            IRQQApi.Api_SendMsg(RobotQQ, 2, MsgFrom, "", "[IR:at=" + TigObjF + "]" +
                                                " 幸运的释放了偷窃技能,偷走了" +
                                                "[IR:at=" + thiefAttack.QQid + "]" + " " +
                                                thiefAttack.ThiefGold + "个雷币!!", -1);
                        }
                    }
                }

                else
                {
                    return(1);
                }
            }
            else if (MsgType == 3)
            {
            }
            //IRQQApi.Api_SendGroupMsg(RobotQQ,MsgFrom, "♪");
            //发送图片
            //String picPath = AppDomain.CurrentDomain.BaseDirectory + "1.jpg";
            //IRQQApi.Api_SendMsg(RobotQQ, MsgType, MsgFrom, TigObjF, IRQQConst.getPic(picPath), -1);
            return(1);
        }