Beispiel #1
0
/*
 * [禁用]%侦测 @目标:查询目标的属性
 * [禁用]%升级:查看可升级的属性
 * [禁用]%升级 属性id:升级对应属性"*/

        public static SendParam MakeParam(string groupQQ, string qq, string content)
        {
            if (content == "%帮助")
            {
                _S.Response(groupQQ, qq, HELP_TEXT);
                return(null);
            }
            //防止刷屏,滤除短长度的内容
            if (!content.StartsWith("%") && content.Length < 6)
            {
                return(null);
            }
            SendParam param = new SendParam();

            param.GroupQQ = groupQQ;
            param.QQ      = qq;
            param.content = content;
            param.param   = content.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            param.caster  = DataRunTime.GetPerson_Add(groupQQ, qq);
            param.target  = null;
            if (param.param.Length > 1)
            {
                if (param.param[1].Length >= 10)
                {
                    string otherqq = param.param[1].Substring(7);
                    otherqq = otherqq.Substring(0, otherqq.Length - 1);
                    long t;
                    if (long.TryParse(otherqq, out t))
                    {
                        param.target = DataRunTime.GetPerson_Add(param.GroupQQ, otherqq);
                    }
                }
            }
            return(param);
        }
Beispiel #2
0
        public bool WhenParamIn(SendParam param)
        {
            if (param.param[0] == _S.GetText("Command_to_Song") && param.param.Length == 2)
            {
                //新的接口
                //string url = "http://music.163.com/api/search/pc";
                //string p = string.Format("s={0}&type=1&limit=1&offset=0", param.param[1]);
                //_S.NetPost(url, p, (stream) =>
                //{
                //    var sstream = new StreamReader(stream, Encoding.UTF8);
                //    string json = sstream.ReadToEnd();
                //    sstream.Close();
                //    sstream.Dispose();
                //    LitJson.JsonData jsonData = LitJson.JsonMapper.ToObject(json);
                //    if (!jsonData.ContainsKey("result") || !jsonData["result"].ContainsKey("songs")) return;
                //    string sid = jsonData["result"]["songs"][0]["id"].ToString();
                //    var xml = string.Format(CLOUD_MUSIC_XML, sid);
                //    IRQQApi.Api_SendXML(Config.RobotQQ, 1, 2, param.GroupQQ, param.QQ, xml, 2);
                //}, null, ";charset=gb2312");

                //直接用的JSON
                _S.ResponseJson(param.GroupQQ, param.QQ, QQ_MUSIC_JSON_F + param.param[1] + QQ_MUSIC_JSON_B);
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public bool WhenParamIn(SendParam param)
        {
            string p = param.GroupQQ + param.QQ;

            if (GQplusQQ == p)
            {
                RepeatTimes++;
            }
            GQplusQQ = p;
            if (RepeatTimes >= 5)
            {
                DataRunTime.ChaosChange(param.GroupQQ, param.QQ, -3);
                _S.Response(param.GroupQQ, param.QQ, "Response_to_Repeat", param.QQ, 3);
                return(false);
            }
            return(true);
        }
Beispiel #4
0
 public bool WhenParamIn(SendParam param)
 {
     //命令
     if (param.param[0] == _S.GetText("Command_to_Statistics") && param.param.Length == 1)
     {
         StringBuilder builder = new StringBuilder();
         builder.AppendLine(_S.GetText("Response_to_Statistics"));
         var result = DataRunTime.GetTop(param.GroupQQ);
         for (int i = 0; i < Math.Min(5, result.Count); i++)
         {
             builder.AppendLine(_S.GetText("Response_to_Query", result[i].NickName, result[i].ChaosCount, result[i].ExCount));
         }
         builder.AppendLine(_S.GetText("Response_to_Statistics_1"));
         _S.Response(param.GroupQQ, param.QQ, builder.ToString());
     }
     return(true);
 }
Beispiel #5
0
        public bool WhenParamIn(SendParam param)
        {
            //低保
            DataRunTime.ChaosChange(param.GroupQQ, param.QQ, 1);
            //随机
            int rand   = _S.RandomInt(0, 10000);
            int rdCoin = 0;

            if (rand <= 1)
            {
                rdCoin = _S.RandomInt(1000, 3000);
                DataRunTime.ChaosChange(param.GroupQQ, param.QQ, rdCoin);
                _S.Response(param.GroupQQ, param.QQ, "GoodLuck_2", param.caster.QQ, rdCoin);
            }
            else if (rand <= 50)
            {
                rdCoin = _S.RandomInt(50, 150);
                DataRunTime.ChaosChange(param.GroupQQ, param.QQ, rdCoin);
                _S.Response(param.GroupQQ, param.QQ, "GoodLuck_1", param.caster.QQ, rdCoin);
            }
            else if (rand <= 300)
            {
                rdCoin = _S.RandomInt(20, 50);
                DataRunTime.ChaosChange(param.GroupQQ, param.QQ, rdCoin);
                _S.Response(param.GroupQQ, param.QQ, "GoodLuck_0", param.caster.QQ, rdCoin);
            }
            //命令
            if (param.param[0] == _S.GetText("Command_to_Query") && param.target == null)
            {
                _S.Response(param.GroupQQ, param.QQ, "Response_to_Query", param.caster.NickName, param.caster.ChaosCount, param.caster.ExCount);
            }
            if (param.param[0] == _S.GetText("Command_to_Query_Other") && param.target != null)
            {
                _S.Response(param.GroupQQ, param.QQ, "Response_to_Query", param.target.NickName, param.target.ChaosCount, param.target.ExCount);
            }
            //GM
            //if (param.param[0] == _S.GetText("Command_to_GMAdd") && param.QQ == Config.God)
            //{
            //    int count = int.Parse(param.param[1]);
            //    DataRunTime.GMChaos(param.GroupQQ, count);
            //    _S.Response(param.GroupQQ, param.QQ, "Response_to_GMAdd", count);
            //}
            return(true);
        }
Beispiel #6
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)
 {
     //发送图片
     //String picPath = AppDomain.CurrentDomain.BaseDirectory + "1.jpg";
     //IRQQApi.Api_SendMsg(RobotQQ, MsgType, MsgFrom, TigObjF, IRQQConst.getPic(picPath), -1);
     if (MsgType == 2)
     {
         SendParam send = Filter.MakeParam(MsgFrom, TigObjF, Msg);
         if (send == null)
         {
             return(1);
         }
         foreach (var module in modules)
         {
             if (!module.WhenParamIn(send))
             {
                 break;
             }
         }
     }
     return(1);
 }
Beispiel #7
0
        public bool WhenParamIn(SendParam param)
        {
            //混沌打击
            if (param.param[0] == _S.GetText("Command_to_ChaosStrike") && param.target != null)
            {
                int cost = 20;
                if (!_S.Cost(param.caster, cost))
                {
                    return(true);
                }
                int dmg    = _S.RandomInt(1, 20);
                var result = _S.Damage(param.caster, param.target, dmg, true, true);
                _S.Response(param.GroupQQ, param.QQ, "Response_to_ChaosStrike", param.caster.QQ, param.target.QQ, cost, -result[0], result[1]);
                return(false);
            }

            //查询状态
            if (param.param[0] == _S.GetText("Command_to_Detect") && param.target != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(_S.GetText("Response_to_Detect", param.caster.QQ, param.target.QQ));
                for (int i = 0; i < param.target.Properties.Length; i++)
                {
                    var grade = param.target.Properties[i];
                    sb.Append(_S.GetText("Text_Property_" + i.ToString()));
                    sb.Append(_S.GetPropertyText(i, (int)grade));
                    if (i < param.target.Properties.Length - 1)
                    {
                        sb.Append("\n");
                    }
                }
                _S.Response(param.GroupQQ, param.QQ, sb.ToString());
                return(false);
            }

            //升级技能
            if (param.param[0] == _S.GetText("Command_to_LevelUp") && param.param.Length == 1)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < param.caster.Properties.Length; i++)
                {
                    var grade = (int)param.caster.Properties[i];
                    if (_S.IsPropertyNull(i))
                    {
                        continue;
                    }
                    if (grade < 0 || grade >= _S.MAX_PROPERTY_LEVEL)
                    {
                        continue;
                    }
                    sb.Append(_S.GetText("Text_Property_LevelUp_" + i.ToString(),
                                         _S.GetPropertyText(i, grade),
                                         _S.GetPropertyCost(i, grade + 1),
                                         _S.GetPropertyText(i, grade + 1)));
                    if (i < param.caster.Properties.Length - 1)
                    {
                        sb.Append("\n");
                    }
                }
                _S.Response(param.GroupQQ, param.QQ, sb.ToString());
                return(false);
            }
            int pid;

            if (param.param[0] == _S.GetText("Command_to_LevelUp") && param.param.Length == 2 && int.TryParse(param.param[1], out pid))
            {
                if (pid < 0 && pid >= (int)EnumProperty.Max)
                {
                    return(false);
                }
                if (_S.IsPropertyNull(pid))
                {
                    return(false);
                }
                if (param.target.Properties[pid] >= _S.MAX_PROPERTY_LEVEL)
                {
                    return(false);
                }
                int cost = _S.GetPropertyCost(pid, (int)param.caster.Properties[pid]);
                if (param.caster.ExCount >= cost)
                {
                    param.caster.ExCount -= cost;
                    param.caster.Properties[pid]++;
                    _S.Response(param.GroupQQ, param.QQ, "Response_to_LevelUp", "");
                }
                return(false);
            }

            //if (param.param[0] == Support.GetText("Command_to_Syndicate") && param.param.Length == 1)
            //{
            //    //int cost = 100;
            //    //if (param.caster.ChaosCount < cost)
            //    //    return true;
            //    //DataRunTime.ChaosChange(param.caster.GroupQQ, param.caster.QQ, -cost);
            //    //Support.Response(param.GroupQQ, param.QQ, "Response_to_Syndicate", param.caster.QQ, cost);
            //    //var result = DataRunTime.GetTop(param.GroupQQ);
            //    //int allLost = 150;
            //    //int[] losts = new int[Math.Min(3, result.Count)];
            //    //for (int i = 0; i < losts.Length - 1; i++)
            //    //{
            //    //    losts[i] = random.Next(0, allLost);
            //    //    allLost -= losts[i];
            //    //}
            //    //losts[losts.Length - 1] = allLost;
            //    //for (int i = 0; i < losts.Length; i++)
            //    //{
            //    //    PersonData p = result[i];
            //    //    DataRunTime.ChaosChange(p.GroupQQ, p.QQ, -losts[i]);
            //    //    Support.Response(param.GroupQQ, param.QQ, "Response_to_Syndicate_Lost", p.QQ, losts[i]);
            //    //}
            //}
            return(true);
        }
Beispiel #8
0
        public bool WhenParamIn(SendParam param)
        {
            //if (!done) return true;
            var taxrate = GetTax(param.caster);

            if (param.param[0] == _S.GetText("Command_to_QueryStock") && param.param.Length == 1)
            {
                _S.Response(param.GroupQQ, param.QQ, "Response_to_QueryStockPerson", curExPrice, param.QQ, (int)(taxrate * 100));
                //_S.Response(param.GroupQQ, param.QQ, intro);
                return(false);
            }
            int opCnt;
            int realCost;

            if (param.param[0] == _S.GetText("Command_to_Buy") && param.param.Length == 1)
            {
                opCnt = (int)Math.Floor(param.caster.ChaosCount / (curExPrice * (1 + taxrate)));
                if (opCnt == 0)
                {
                    return(false);
                }
                realCost = (int)Math.Ceiling(opCnt * curExPrice * (1 + taxrate));
                if (_S.Cost(param.caster, realCost))
                {
                    DataRunTime.ExChange(param.GroupQQ, param.QQ, opCnt);
                    ExStockChange(opCnt);
                    TaxAdd(param.caster);
                    _S.Response(param.GroupQQ, param.QQ, "Response_to_StockOp", param.caster.QQ, param.caster.ChaosCount, param.caster.ExCount);
                }
                return(false);
            }
            if (param.param[0] == _S.GetText("Command_to_Buy") && param.param.Length == 2 && int.TryParse(param.param[1], out opCnt))
            {
                if (opCnt <= 0)
                {
                    return(false);
                }
                realCost = (int)Math.Ceiling(opCnt * curExPrice * (1 + taxrate));
                if (_S.Cost(param.caster, realCost))
                {
                    DataRunTime.ExChange(param.GroupQQ, param.QQ, opCnt);
                    ExStockChange(opCnt);
                    TaxAdd(param.caster);
                    _S.Response(param.GroupQQ, param.QQ, "Response_to_StockOp", param.caster.QQ, param.caster.ChaosCount, param.caster.ExCount);
                }
                return(false);
            }
            if (param.param[0] == _S.GetText("Command_to_Sell") && param.param.Length == 1)
            {
                opCnt = param.caster.ExCount;
                if (opCnt == 0)
                {
                    return(false);
                }
                opCnt    = -opCnt;
                realCost = Math.Abs((int)Math.Floor(opCnt * curExPrice * (1 - taxrate)));
                DataRunTime.ExChange(param.GroupQQ, param.QQ, opCnt);
                DataRunTime.ChaosChange(param.GroupQQ, param.QQ, realCost);
                ExStockChange(opCnt);
                TaxAdd(param.caster);
                _S.Response(param.GroupQQ, param.QQ, "Response_to_StockOp", param.caster.QQ, param.caster.ChaosCount, param.caster.ExCount);
                return(false);
            }
            if (param.param[0] == _S.GetText("Command_to_Sell") && param.param.Length == 2 && int.TryParse(param.param[1], out opCnt))
            {
                if (opCnt <= 0)
                {
                    return(false);
                }
                if (opCnt > param.caster.ExCount)
                {
                    return(false);
                }
                opCnt    = -opCnt;
                realCost = Math.Abs((int)Math.Floor(opCnt * curExPrice * (1 - taxrate)));
                DataRunTime.ExChange(param.GroupQQ, param.QQ, opCnt);
                DataRunTime.ChaosChange(param.GroupQQ, param.QQ, realCost);
                ExStockChange(opCnt);
                TaxAdd(param.caster);
                _S.Response(param.GroupQQ, param.QQ, "Response_to_StockOp", param.caster.QQ, param.caster.ChaosCount, param.caster.ExCount);
                return(false);
            }
            return(true);
        }