private static void ProcessRoomMessage(string json, ListenRunTimeConfig config)
        {
            try
            {
                JObject obj = JObject.Parse(json);
                if ((int)obj["status"] == 200)
                {
                    IEnumerable <JToken> datas = obj.SelectTokens("$.content.data[*]");
                    long     tmpTime           = 0;
                    DateTime msgTime           = new DateTime(1996, 9, 10);

                    foreach (JToken msgs in datas)
                    {
                        //本次消息时间
                        if ((long)msgs["msgTime"] >= tmpTime)
                        {
                            tmpTime = (long)msgs["msgTime"];
                            msgTime = DateTime.Parse(msgs["msgTimeStr"].ToString());
                        }
                        JObject msg = JObject.Parse(msgs["extInfo"].ToString());

                        //长短时切换~
                        DateTime now      = DateTime.Now;
                        TimeSpan interval = now - msgTime;
                        config.Delay = interval.TotalSeconds > PocketSetting.Interval ? config.LongDelay : config.ShortDelay;
                        //首次运行,直接退出循环
                        if (config.First)
                        {
                            break;
                        }

                        //时间戳相等说明已经发过了,直接退出
                        if ((long)msgs["msgTime"] <= config.LastTime)
                        {
                            continue;
                        }

                        //消息分发
                        switch (msg["messageObject"].ToString())
                        {
                        case "deleteMessage":
                            //CQ.SendGroupMessage(qqGroup,"你的小偶像删除了一条口袋房间的消息");
                            break;

                        case "text":
                            if (config.TransmitText)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), msg["text"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                }
                            }
                            break;

                        case "image":
                            JObject img         = JObject.Parse(msgs["bodys"].ToString());
                            string  imgFilename = GetImage(img["url"].ToString());
                            if (imgFilename == "")
                            {
                                continue;
                            }
                            if (config.TransmitImage)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    if (PocketPlugins.CommonCfg.CoolQAir)
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n发送了图片:{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), img["url"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                    }
                                    else
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), CoolQCode.Image(imgFilename), config.IdolName, msgs["msgTimeStr"].ToString()));
                                    }
                                }
                            }
                            break;

                        case "faipaiText":
                            if (config.TransmitFanpai)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    if (msg.Property("fanpaiName") != null)
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{4}\r\n{0} 回复:{1}\r\n来源:{5}房间 发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), "", msg["faipaiContent"].ToString(), config.IdolName));
                                    }
                                    else
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{4}\r\n{0} 回复:{1}\r\n来源:{5}房间 发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), "", msg["faipaiContent"].ToString(), config.IdolName));
                                    }
                                }
                            }
                            break;

                        case "audio":
                            JObject audio         = JObject.Parse(msgs["bodys"].ToString());
                            string  audioFilename = GetAudio(audio["url"].ToString(), audio["ext"].ToString());
                            if (audioFilename == "")
                            {
                                continue;
                            }
                            if (config.TransmitAudio)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    if (PocketPlugins.CommonCfg.CoolQAir)
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n发送了语音:{1} 来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), audio["url"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                    }
                                    else
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}", CoolQCode.ShareRecord(audioFilename)));
                                    }
                                    //PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n{1} 来源:口袋房间", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename)));
                                }
                            }

                            break;

                        case "videoRecord":
                            JObject video = JObject.Parse(msgs["bodys"].ToString());
                            if (config.TransmitVideo)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}发送了一个视频,请点击下面链接查看\r\n地址:{1}", msg["senderName"].ToString(), video["url"].ToString()));
                                }
                            }
                            break;

                        case "jujuLive":
                            if (config.TransmitGift)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), msg["text"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                }
                            }
                            break;

                        case "live":
                            if (config.TransmitLive)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("滴滴滴,你的小偶像{0}开直播辣!\r\n使用口袋PC观看体验更好哦!\r\n或登录网页收看https://h5.48.cn/2017appshare/memberLiveShare/index.html?id={1}", config.IdolName, msg["referenceObjectId"].ToString()));
                                }
                            }
                            break;

                        case "diantai":
                            if (config.TransmitLive)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("滴滴滴,你的小偶像{0}开电台辣!\r\n使用口袋PC观看体验更好哦!\r\n或登录网页收看https://h5.48.cn/2017appshare/memberLiveShare/index.html?id={1}", config.IdolName, msg["referenceObjectId"].ToString()));
                                }
                            }
                            break;

                        case "idolFlip":
                            if (config.TransmitFlip)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    if (int.Parse(msg["idolFlipType"].ToString()) == 3)
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}回答了匿名聚聚的提问:\r\n{1}\r\n回答请进入房间查看", msg["senderName"].ToString(), msg["idolFlipContent"].ToString()));
                                    }
                                    else
                                    {
                                        PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}回答了{2}的提问:\r\n{1}\r\n回答请进入房间查看", msg["senderName"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString()));
                                    }
                                }
                            }
                            break;
                        }
                    }
                    if (tmpTime != 0)
                    {
                        config.LastTime = tmpTime;
                    }
                }
                if (config.First)
                {
                    config.First = false;
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex);
            }
        }
        public void GetRoomMsg(ListenConfig listenConfig)
        {
            try
            {
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri("https://pjuju.48.cn/imsystem/api/im/v1/member/room/message/chat"));
                req.Method    = "POST";
                req.UserAgent = "okhttp/3.4.1";

                JObject rss = new JObject(
                    new JProperty("roomId", listenConfig.KDRoomId),
                    new JProperty("lastTime", 0),
                    new JProperty("limit", 10)
                    );

                string postJson = rss.ToString();
                byte[] bytes    = Encoding.UTF8.GetBytes(postJson);

                req.ContentType   = "application/json";
                req.ContentLength = bytes.Length;

                Stream reqstream = req.GetRequestStream();
                reqstream.Write(bytes, 0, bytes.Length);

                HttpWebResponse response      = (HttpWebResponse)req.GetResponse();
                Stream          streamReceive = response.GetResponseStream();
                Encoding        encoding      = Encoding.UTF8;

                StreamReader streamReader = new StreamReader(streamReceive, encoding);
                string       strResult    = streamReader.ReadToEnd();

                streamReceive.Dispose();
                streamReader.Dispose();


                JObject json = JObject.Parse(strResult);
                if ((int)json["status"] == 200)
                {
                    IEnumerable <JToken> datas = json.SelectTokens("$.content.data[*]");

                    //记录本次最大时间戳
                    long tmpTime = 0;

                    foreach (JToken msgs in datas)
                    {
                        //历史最后时间戳比对
                        if ((long)msgs["msgTime"] > listenConfig.Lasttime)
                        {
                            //本次消息时间
                            if ((long)msgs["msgTime"] > tmpTime)
                            {
                                tmpTime = (long)msgs["msgTime"];
                            }
                            JObject msg = JObject.Parse(msgs["extInfo"].ToString());
                            //首次运行,直接退出循环
                            if (listenConfig.First)
                            {
                                break;
                            }
                            if ((long)msgs["msgTime"] < listenConfig.Lasttime)
                            {
                                break;
                            }
                            switch (msg["messageObject"].ToString())
                            {
                            case "deleteMessage":
                                //CQ.SendGroupMessage(qqGroup,"你的小偶像删除了一条口袋房间的消息");
                                break;

                            case "text":
                                CoolQApi.SendGroupMsg(listenConfig.QQGroup, String.Format("口袋房间:\r\n{0}:{1}\r\n发送时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), msgs["msgTimeStr"].ToString()));
                                break;

                            case "image":
                                JObject img         = JObject.Parse(msgs["bodys"].ToString());
                                string  imgFilename = GetImage(img["url"].ToString());
                                if (imgFilename == "")
                                {
                                    return;
                                }
                                CoolQApi.SendGroupMsg(listenConfig.QQGroup, String.Format("口袋房间:\r\n{0}:\r\n{1}", msg["senderName"].ToString(), CoolQCode.Image(imgFilename)));
                                break;

                            case "faipaiText":
                                CoolQApi.SendGroupMsg(listenConfig.QQGroup, String.Format("口袋房间:\r\n翻牌辣!{3}:{4}\r\n{0} 回复:{1}\r\n被翻牌的大佬不来集资一发吗?" + listenConfig.HitYouText + " \r\n发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), msg["faipaiName"].ToString(), msg["faipaiContent"].ToString()));
                                break;

                            case "audio":
                                JObject audio         = JObject.Parse(msgs["bodys"].ToString());
                                string  audioFilename = GetAudio(audio["url"].ToString(), audio["ext"].ToString());
                                if (audioFilename == "")
                                {
                                    return;
                                }
                                CoolQApi.SendGroupMsg(listenConfig.QQGroup, String.Format("口袋房间:\r\n{0}:\r\n{1}", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename)));
                                break;

                            case "videoRecord":
                                JObject video = JObject.Parse(msgs["bodys"].ToString());
                                CoolQApi.SendGroupMsg(listenConfig.QQGroup, string.Format("{0}发送了一个视频,请点击下面链接查看\r\n地址:{1}", msg["senderName"].ToString(), video["url"].ToString()));
                                break;

                            default:
                                CoolQApi.SendGroupMsg(listenConfig.QQGroup, "你的小偶像有一条新消息,TeemoBot无法支持该类型消息,请打开口袋48查看~~并向开发反馈下~谢谢~");
                                break;
                            }
                        }
                    }
                    if (tmpTime != 0)
                    {
                        listenConfig.Lasttime = tmpTime;
                    }
                }
                if (listenConfig.First)
                {
                    listenConfig.First = false;
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("error.log", DateTime.Now.ToString() + "\r\n" + ex.ToString() + "\r\n" + ex.StackTrace + "\r\n");
            }
        }
        private static void ProcessRoomMessage(string json, ListenRunTimeConfig config)
        {
            try
            {
                JObject obj = JObject.Parse(json);
                if ((int)obj["status"] == 200)
                {
                    IEnumerable <JToken> datas = obj.SelectTokens("$.content.data[*]");
                    long     tmpTime           = 0;
                    DateTime msgTime           = new DateTime(1996, 9, 10);
                    string   totalTempMsg      = "";
                    string   templeMsgTime     = "";
                    int      sort = 1;
                    foreach (JToken msgs in datas)
                    {
                        msgTime = DateTime.Parse(msgs["msgTimeStr"].ToString());
                        //★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                        JObject  msg           = JObject.Parse(msgs["extInfo"].ToString());
                        string[] realtime      = msgs["msgTimeStr"].ToString().Split(' ');
                        string[] idolnamewords = msg["senderName"].ToString().Split('-');
                        string   idolname      = idolnamewords[idolnamewords.Length - 1];
                        string   roomrecentmsg = "";
                        DateTime dt            = new DateTime(1970, 1, 1, 8, 0, 0).AddMilliseconds(((Convert.ToDouble(config.LastTime))));
                        if (sort == 1)                             //处理第一条消息的逻辑
                        {
                            tmpTime       = (long)msgs["msgTime"]; //最后一次的第一条时间
                            templeMsgTime = realtime[1];
                            //首次消息日志开始
                            if (PocketPlugins.CommonCfg.msglog == true)
                            {
                                //PocketPlugins.Api.AddLog(10, CoolQLogLevel.Info, "true");
                                try
                                {
                                    switch (msg["messageObject"].ToString())
                                    {
                                    case "deleteMessage":
                                        roomrecentmsg = "你的小偶像删除了一条消息";
                                        break;

                                    case "text":
                                        if (config.TransmitText)
                                        {
                                            roomrecentmsg = String.Format("{0}:{1}", idolname, msg["text"].ToString());
                                        }
                                        break;

                                    case "image":
                                        JObject img = JObject.Parse(msgs["bodys"].ToString());
                                        if (config.TransmitImage)
                                        {
                                            roomrecentmsg = String.Format("{0}:\r\n发送图片:{1}", idolname, img["url"].ToString());
                                        }
                                        break;

                                    case "faipaiText":
                                        if (config.TransmitFanpai)
                                        {
                                            if (msg.Property("fanpaiName") != null)
                                            {
                                                roomrecentmsg = String.Format("{2} : {3}\r\n{0} 回复 : {1}", idolname, msg["messageText"].ToString(), msg["fanpaiName"].ToString(), msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                            }
                                            else
                                            {
                                                JObject Name = JObject.Parse(GetUserName(msg["faipaiUserId"].ToString()));
                                                roomrecentmsg = String.Format("{2} : {3}\r\n{0} 回复 : {1}", idolname, msg["messageText"].ToString(), Name["nickName"].ToString(), msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                            }
                                        }
                                        break;

                                    case "audio":
                                        JObject audio         = JObject.Parse(msgs["bodys"].ToString());
                                        string  audioFilename = GetAudio(audio["url"].ToString(), audio["ext"].ToString());
                                        if (audioFilename == "")
                                        {
                                            continue;
                                        }
                                        if (config.TransmitAudio)
                                        {
                                            roomrecentmsg = String.Format("{0}:\r\n发送语音:{1}", idolname, audio["url"].ToString());
                                        }
                                        break;

                                    case "videoRecord":
                                        JObject video = JObject.Parse(msgs["bodys"].ToString());
                                        if (config.TransmitVideo)
                                        {
                                            roomrecentmsg = string.Format("{0}发送视频。\r\n地址:{1}\r\n", idolname, video["url"].ToString());
                                        }
                                        break;

                                    case "jujuLive":
                                        if (config.TransmitGift)
                                        {
                                            roomrecentmsg = string.Format("{0}{1}", idolname, msg["text"].ToString());
                                        }
                                        break;

                                    case "live":
                                        roomrecentmsg = string.Format("直播提醒:你的小心肝{0}的直播:{1}!\r\n请打开口袋48观看哟!设置关注词(直播提醒)不错过直播哦!", idolname, msg["referenceContent"].ToString());
                                        break;

                                    case "diantai":
                                        if (config.TransmitLive)
                                        {
                                            roomrecentmsg = string.Format("直播提醒:你的小心肝{0}突然开了个电台:{1}!\r\n快打开口袋48观看哟!设置关注词(直播提醒)不错过直播哦!", idolname, msg["referenceContent"].ToString());
                                        }
                                        break;

                                    case "idolFlip":
                                        if (config.TransmitFlip)
                                        {
                                            //}
                                            if (int.Parse(msg["idolFlipType"].ToString()) == 3)
                                            {
                                                roomrecentmsg = string.Format("{0} {1}:\r\n{2}", idolname, msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString());
                                            }
                                            else
                                            {
                                                roomrecentmsg = string.Format("{0} 回答 {3} 的提问:\r\n{2}", idolname, msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString());
                                            }
                                        }
                                        break;

                                    default:
                                        File.AppendAllText("unknowmsg.log", msgs.ToString() + "\r\n");
                                        roomrecentmsg = "未知类型消息,请检查unknowmsg.log";
                                        break;
                                    }
                                    PocketPlugins.Api.AddLog(10, CoolQLogLevel.Debug, config.LastTime.ToString() + " " + msgs["msgTime"].ToString());
                                    roomrecentmsg = "上次最晚时间:" + dt.ToString() + " 本次最新时间:" + msgs["msgTimeStr"].ToString() + "\r\n" + config.IdolName + "房间:(调试信息,勾选取消可去除本消息。仅供调试测试查看\r\n" + roomrecentmsg;
                                    PocketPlugins.Api.AddLog(10, CoolQLogLevel.Debug, roomrecentmsg);
                                    //panel.textBox_recentmsg.Text = roomrecentmsg;
                                }
                                catch (Exception ex)
                                {
                                    PocketPlugins.Api.AddLog(10, CoolQLogLevel.Debug, ex.ToString());
                                }
                            }
//                            else
//                                PocketPlugins.Api.AddLog(10, CoolQLogLevel.Info, "false");

                            //else
                            //PocketPlugins.Api.AddLog(10, CoolQLogLevel.Info, "false");

                            //首次消息日志结束
                        }
                        sort++;
                        //长短时切换~
                        DateTime now      = DateTime.Now;
                        TimeSpan interval = now - msgTime;
                        config.Delay = interval.TotalSeconds > PocketSetting.Interval ? config.LongDelay : config.ShortDelay;
                        //首次运行,直接退出循环
                        if (config.First)
                        {
                            //PocketPlugins.Api.AddLog(10, CoolQLogLevel.Info, string.Format("[{0}]任务启动", IdolName));
                            config.LastTime = tmpTime;
                            dt = new DateTime(1970, 1, 1, 8, 0, 0).AddMilliseconds(((Convert.ToDouble(config.LastTime))));
                            PocketPlugins.Api.AddLog(10, CoolQLogLevel.Debug, config.IdolName + " 初始化结束,最新一条消息时间为:" + config.LastTime.ToString() + " " + dt.ToString());
                            break;
                        }


                        //时间戳相等说明已经发过了,直接退出
                        if ((long)msgs["msgTime"] <= config.LastTime)
                        {
                            //continue;
                            config.LastTime = tmpTime;
                            break;//一旦小于时间直接终止遍历,赋值最后一次时间。
                        }

                        //消息分发
                        switch (msg["messageObject"].ToString())
                        {
                        case "deleteMessage":
                            totalTempMsg = "你的小偶像删除了一条消息" + "\r\n" + totalTempMsg;
                            //CQ.SendGroupMessage(qqGroup,"你的小偶像删除了一条口袋房间的消息");
                            break;

                        case "text":
                            if (config.TransmitText)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //   PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), msg["text"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //}
                                if (config.IdolName != msg["senderName"].ToString())
                                {
                                    //totalTempMsg = String.Format("{0}:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:{1}", idolname, msg["text"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    //totalTempMsg = String.Format("{0}:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:{1}", idolname, msg["text"].ToString()) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "image":
                            JObject img         = JObject.Parse(msgs["bodys"].ToString());
                            string  imgFilename = GetImage(img["url"].ToString());
                            if (imgFilename == "")
                            {
                                continue;
                            }
                            if (config.TransmitImage)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    if (PocketPlugins.CommonCfg.CoolQAir)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n发送了图片:{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), img["url"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), CoolQCode.Image(imgFilename), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //}
                                if (PocketPlugins.CommonCfg.CoolQAir)
                                {
                                    //totalTempMsg = String.Format("{0}:\r\n发送图片:{1}\r\n时间:{2}", msg["senderName"].ToString(), img["url"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:\r\n发送图片:{1}", idolname, img["url"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    //totalTempMsg = String.Format("{0}:\r\n{1}\r\n时间:{2}", msg["senderName"].ToString(), CoolQCode.Image(imgFilename), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:\r\n{1}", idolname, CoolQCode.Image(imgFilename)) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "faipaiText":
                            if (config.TransmitFanpai)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    if(msg.Property("fanpaiName") != null)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{4}\r\n{0} 回复:{1}\r\n来源:{5}房间 发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), "", msg["faipaiContent"].ToString(), config.IdolName));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{4}\r\n{0} 回复:{1}\r\n来源:{5}房间 发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), "", msg["faipaiContent"].ToString(), config.IdolName));
                                // }
                                JObject Name = JObject.Parse(GetUserName(msg["faipaiUserId"].ToString()));
//                                    PocketPlugins.Api.AddLog(10, CoolQLogLevel.Info, string.Format("[{0}]任务已经存在,退出", IdolName));
                                if (msg.Property("fanpaiName") != null)
                                {
                                    //totalTempMsg = String.Format("{3} : {4}\r\n{0} 回复:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), realtime[1], msg["fanpaiName"].ToString(), msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{2} : {3}\r\n{0} 回复 : {1}", idolname, msg["messageText"].ToString(), msg["fanpaiName"].ToString(), msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    //totalTempMsg = String.Format("{3} : {4}\r\n{0} 回复:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), Name["nickName"], msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{2} : {3}\r\n{0} 回复 : {1}", idolname, msg["messageText"].ToString(), Name["nickName"].ToString(), msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "audio":
                            JObject audio         = JObject.Parse(msgs["bodys"].ToString());
                            string  audioFilename = GetAudio(audio["url"].ToString(), audio["ext"].ToString());
                            if (audioFilename == "")
                            {
                                continue;
                            }
                            if (config.TransmitAudio)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //   if (PocketPlugins.CommonCfg.CoolQAir)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n发送了语音:{1} 来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), audio["url"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}", CoolQCode.ShareRecord(audioFilename)));
                                //        //PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n{1} 来源:口袋房间", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename)));
                                //}
                                if (PocketPlugins.CommonCfg.CoolQAir)
                                {
                                    //totalTempMsg = String.Format("{0}:\r\n发送语音:{1}\r\n时间:{2}", msg["senderName"].ToString(), audio["url"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:\r\n发送语音:{1}", idolname, audio["url"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    //totalTempMsg = String.Format("{0}:\r\n{1}", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename)) + "\r\n" + totalTempMsg;
                                    //totalTempMsg = String.Format("{0}:\r\n{1}\r\n时间:{2}", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:\r\n{1}", idolname, CoolQCode.ShareRecord(audioFilename)) + "\r\n" + totalTempMsg;
                                }
                            }

                            break;

                        case "videoRecord":
                            JObject video = JObject.Parse(msgs["bodys"].ToString());
                            if (config.TransmitVideo)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}发送了一个视频,请点击下面链接查看\r\n地址:{1}", msg["senderName"].ToString(), video["url"].ToString()));
                                //}
                                totalTempMsg = string.Format("{0}发送视频。\r\n地址:{1}\r\n", idolname, video["url"].ToString()) + "\r\n" + totalTempMsg;
                            }
                            break;

                        case "jujuLive":
                            if (config.TransmitGift)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), msg["text"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //}
                                //totalTempMsg = string.Format("{0}{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                totalTempMsg = string.Format("{0}{1}", idolname, msg["text"].ToString()) + "\r\n" + totalTempMsg;
                            }
                            break;

                        case "live":
                            if (config.TransmitLive)
                            {
                                if (config.Atall && !PocketPlugins.CommonCfg.CoolQAir)
                                {
                                    totalTempMsg = string.Format("[CQ:at,qq=all]直播提醒:你的小心肝{0}的直播:{1}!\r\n请打开口袋48观看哟!设置关注词(直播提醒)不错过直播哦!", idolname, msg["referenceContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    totalTempMsg = string.Format("直播提醒:你的小心肝{0}的直播:{1}!\r\n请打开口袋48观看哟!设置关注词(直播提醒)不错过直播哦!", idolname, msg["referenceContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "diantai":
                            if (config.TransmitLive)
                            {
                                if (config.Atall && !PocketPlugins.CommonCfg.CoolQAir)
                                {
                                    totalTempMsg = string.Format("[CQ:at,qq=all]直播提醒:你的小心肝{0}的电台:{1}!\r\n快打开口袋48观看哟!设置关注词(直播提醒)不错过直播哦!", idolname, msg["referenceContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    totalTempMsg = string.Format("直播提醒:你的小心肝{0}的电台:{1}!\r\n快打开口袋48观看哟!设置关注词(直播提醒)不错过直播哦!", idolname, msg["referenceContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "idolFlip":
                            if (config.TransmitFlip)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    if (int.Parse(msg["idolFlipType"].ToString()) == 3)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}回答了匿名聚聚的提问:\r\n{1}\r\n回答请进入房间查看", msg["senderName"].ToString(), msg["idolFlipContent"].ToString()));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}回答了{2}的提问:\r\n{1}\r\n回答请进入房间查看", msg["senderName"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString()));
                                //}

                                if (int.Parse(msg["idolFlipType"].ToString()) == 3)
                                {
                                    //totalTempMsg = string.Format("{0} {1}:\r\n{2}\r\n时间:{3}", msg["senderName"].ToString(), msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = string.Format("{0} {1}:\r\n{2}", idolname, msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    //totalTempMsg = string.Format("{0} 回答 {3} 的提问:\r\n{2}\r\n时间:{4}", msg["senderName"].ToString(), msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString(),realtime[1]) + "\r\n" + totalTempMsg;
                                    totalTempMsg = string.Format("{0} 回答 {3} 的提问:\r\n{2}", idolname, msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString()) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        default:
                            File.AppendAllText("msg.log", msgs.ToString() + "\r\n");
                            break;
                        }
                    }
                    if (totalTempMsg != "")
                    {
                        totalTempMsg = templeMsgTime + "" + config.IdolName + "房间:\r\n" + totalTempMsg;
                        totalTempMsg = totalTempMsg.Substring(0, totalTempMsg.Length - 2);
                        foreach (long qqGroup in config.QQGroups)
                        {
                            Common.sendgroupmsgChose(qqGroup, totalTempMsg);
                        }

                        if (PocketPlugins.Api.GetLoginQQ() == 2893276319)
                        {
                            totalTempMsg = totalTempMsg.Replace("[CQ:at,qq=all]", "");
                            PocketPlugins.Api.SendPrivateMsg(1691686998, totalTempMsg);
                        }
                    }
                }
                if (config.First)
                {
                    config.First = false;
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex);
            }
        }
Exemple #4
0
        private static void ProcessRoomMessage(string json, ListenRunTimeConfig config)
        {
            try
            {
                JObject obj = JObject.Parse(json);
                if ((int)obj["status"] == 200)
                {
                    IEnumerable <JToken> datas = obj.SelectTokens("$.content.data[*]");
                    long     tmpTime           = 0;
                    DateTime msgTime           = new DateTime(1996, 9, 10);
                    string   totalTempMsg      = "";
                    foreach (JToken msgs in datas)
                    {
                        //本次消息时间
                        if ((long)msgs["msgTime"] >= tmpTime)
                        {
                            tmpTime = (long)msgs["msgTime"];
                            msgTime = DateTime.Parse(msgs["msgTimeStr"].ToString());
                        }
                        JObject msg = JObject.Parse(msgs["extInfo"].ToString());

                        //长短时切换~
                        DateTime now      = DateTime.Now;
                        TimeSpan interval = now - msgTime;
                        config.Delay = interval.TotalSeconds > PocketSetting.Interval ? config.LongDelay : config.ShortDelay;
                        //首次运行,直接退出循环
                        if (config.First)
                        {
                            break;
                        }

                        //时间戳相等说明已经发过了,直接退出
                        if ((long)msgs["msgTime"] <= config.LastTime)
                        {
                            continue;
                        }

                        string[] realtime = msgs["msgTimeStr"].ToString().Split(' ');
                        //消息分发
                        switch (msg["messageObject"].ToString())
                        {
                        case "deleteMessage":
                            totalTempMsg = "你的小偶像删除了一条消息" + "\r\n" + totalTempMsg;
                            //CQ.SendGroupMessage(qqGroup,"你的小偶像删除了一条口袋房间的消息");
                            break;

                        case "text":
                            if (config.TransmitText)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //   PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), msg["text"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //}
                                if (config.IdolName != msg["senderName"].ToString())
                                {
                                    totalTempMsg = String.Format("{0}:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    totalTempMsg = String.Format("{0}:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "image":
                            JObject img         = JObject.Parse(msgs["bodys"].ToString());
                            string  imgFilename = GetImage(img["url"].ToString());
                            if (imgFilename == "")
                            {
                                continue;
                            }
                            if (config.TransmitImage)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    if (PocketPlugins.CommonCfg.CoolQAir)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n发送了图片:{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), img["url"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), CoolQCode.Image(imgFilename), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //}
                                if (PocketPlugins.CommonCfg.CoolQAir)
                                {
                                    totalTempMsg = String.Format("{0}:\r\n发送图片:{1}\r\n时间:{2}", msg["senderName"].ToString(), img["url"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    totalTempMsg = String.Format("{0}:\r\n{1}\r\n时间:{2}", msg["senderName"].ToString(), CoolQCode.Image(imgFilename), realtime[1]) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "faipaiText":
                            if (config.TransmitFanpai)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    if(msg.Property("fanpaiName") != null)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{4}\r\n{0} 回复:{1}\r\n来源:{5}房间 发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), "", msg["faipaiContent"].ToString(), config.IdolName));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{4}\r\n{0} 回复:{1}\r\n来源:{5}房间 发送时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), msgs["msgTimeStr"].ToString(), "", msg["faipaiContent"].ToString(), config.IdolName));
                                // }
                                JObject Name = JObject.Parse(GetUserName(msg["faipaiUserId"].ToString()));
//                                    PocketPlugins.Api.AddLog(10, CoolQLogLevel.Info, string.Format("[{0}]任务已经存在,退出", IdolName));
                                if (msg.Property("fanpaiName") != null)
                                {
                                    totalTempMsg = String.Format("{3} : {4}\r\n{0} 回复:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), realtime[1], msg["fanpaiName"].ToString(), msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    totalTempMsg = String.Format("{3} : {4}\r\n{0} 回复:{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["messageText"].ToString(), realtime[1], Name["nickName"], msg["faipaiContent"].ToString()) + "\r\n" + totalTempMsg;
                                }
                            }
                            break;

                        case "audio":
                            JObject audio         = JObject.Parse(msgs["bodys"].ToString());
                            string  audioFilename = GetAudio(audio["url"].ToString(), audio["ext"].ToString());
                            if (audioFilename == "")
                            {
                                continue;
                            }
                            if (config.TransmitAudio)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //   if (PocketPlugins.CommonCfg.CoolQAir)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n发送了语音:{1} 来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), audio["url"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}", CoolQCode.ShareRecord(audioFilename)));
                                //        //PocketPlugins.Api.SendGroupMsg(qqGroup, String.Format("{0}:\r\n{1} 来源:口袋房间", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename)));
                                //}
                                if (PocketPlugins.CommonCfg.CoolQAir)
                                {
                                    totalTempMsg = String.Format("{0}:\r\n发送语音:{1}\r\n时间:{2}", msg["senderName"].ToString(), audio["url"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                                }
                                else
                                {
                                    //totalTempMsg = String.Format("{0}:\r\n{1}", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename)) + "\r\n" + totalTempMsg;
                                    totalTempMsg = String.Format("{0}:\r\n{1}\r\n时间:{2}", msg["senderName"].ToString(), CoolQCode.ShareRecord(audioFilename), realtime[1]) + "\r\n" + totalTempMsg;
                                }
                            }

                            break;

                        case "videoRecord":
                            JObject video = JObject.Parse(msgs["bodys"].ToString());
                            if (config.TransmitVideo)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}发送了一个视频,请点击下面链接查看\r\n地址:{1}", msg["senderName"].ToString(), video["url"].ToString()));
                                //}
                                totalTempMsg = string.Format("{0}发送视频。\r\n地址:{1}\r\n", msg["senderName"].ToString(), video["url"].ToString()) + "\r\n" + totalTempMsg;
                            }
                            break;

                        case "jujuLive":
                            if (config.TransmitGift)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}{1}\r\n来源:{2}房间 发送时间:{3}", msg["senderName"].ToString(), msg["text"].ToString(), config.IdolName, msgs["msgTimeStr"].ToString()));
                                //}
                                totalTempMsg = string.Format("{0}{1}\r\n时间:{2}", msg["senderName"].ToString(), msg["text"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                            }
                            break;

                        case "live":
                            if (config.TransmitLive)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    //PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("直播提醒:你的小心肝{0}突然开了个直播,直播哦不是电台!\r\n请打开口袋48观看哟!设置关键词关注“直播提醒”不错过直播哦!", config.IdolName, msg["referenceObjectId"].ToString()));
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("直播提醒:你的小心肝{0}突然开了个直播,直播哦不是电台!\r\n请打开口袋48观看哟!设置关键词关注“直播提醒”不错过直播哦!", config.IdolName));
                                }
                            }
                            break;

                        case "diantai":
                            if (config.TransmitLive)
                            {
                                foreach (long qqGroup in config.QQGroups)
                                {
                                    //PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("直播提醒:你的小心肝{0}突然开了个电台,电台哦不是直播!\r\n请打开口袋48观看哟!设置关键词关注“直播提醒”不错过直播哦!", config.IdolName, msg["referenceObjectId"].ToString()));
                                    PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("直播提醒:你的小心肝{0}突然开了个电台,电台哦不是直播!\r\n请打开口袋48观看哟!设置关键词关注“直播提醒”不错过直播哦!", config.IdolName));
                                }
                            }
                            break;

                        case "idolFlip":
                            if (config.TransmitFlip)
                            {
                                //foreach (long qqGroup in config.QQGroups)
                                //{
                                //    if (int.Parse(msg["idolFlipType"].ToString()) == 3)
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}回答了匿名聚聚的提问:\r\n{1}\r\n回答请进入房间查看", msg["senderName"].ToString(), msg["idolFlipContent"].ToString()));
                                //    else
                                //        PocketPlugins.Api.SendGroupMsg(qqGroup, string.Format("{0}回答了{2}的提问:\r\n{1}\r\n回答请进入房间查看", msg["senderName"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString()));
                                //}
                            }
                            if (int.Parse(msg["idolFlipType"].ToString()) == 3)
                            {
                                totalTempMsg = string.Format("{0} {1}:\r\n{2}\r\n时间:{3}", msg["senderName"].ToString(), msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                            }
                            else
                            {
                                totalTempMsg = string.Format("{0} 翻牌了 {3} 的问题:\r\n{2}\r\n时间:{4}", msg["senderName"].ToString(), msg["idolFlipTitle"].ToString(), msg["idolFlipContent"].ToString(), msg["idolFlipUserName"].ToString(), realtime[1]) + "\r\n" + totalTempMsg;
                            }
                            break;

                        default:
                            File.AppendAllText("msg.log", msgs.ToString() + "\r\n");
                            break;
                        }
                    }
                    if (totalTempMsg != "")
                    {
                        totalTempMsg = config.IdolName + "口袋房间:\r\n" + totalTempMsg;
                        totalTempMsg = totalTempMsg.Substring(0, totalTempMsg.Length - 2);
                        foreach (long qqGroup in config.QQGroups)
                        {
                            PocketPlugins.Api.SendGroupMsg(qqGroup, totalTempMsg);
                        }

                        if (PocketPlugins.Api.GetLoginQQ() == 2893276319)
                        {
                            PocketPlugins.Api.SendPrivateMsg(1691686998, totalTempMsg);
                        }
                    }
                    if (tmpTime != 0)
                    {
                        config.LastTime = tmpTime;
                    }
                }
                if (config.First)
                {
                    config.First = false;
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex);
            }
        }