/// <summary> /// 处理好友已添加事件(此事件监听不到) /// </summary> /// <param name="subType">事件类型。固定为1</param> /// <param name="sendTime">事件发生时间的时间戳</param> /// <param name="fromQq">事件来源QQ</param> /// <returns></returns> public override int ProcessFriendsAdded(int subType, int sendTime, long fromQq) { mainForm.displayMsg2("处理好友已添加事件:" + subType + "," + sendTime + "," + fromQq); //给用户回复的信息日志 MyLogUtil.WriteQQDialogueLogOfMe(fromQq, SystemConfig.MsgWhenFriendsAdded); CoolQApi.SendPrivateMsg(fromQq, SystemConfig.MsgWhenFriendsAdded); return(base.ProcessFriendsAdded(subType, sendTime, fromQq)); }
/// <summary> /// 监听私聊事件 /// </summary> /// <param name="subType"></param> /// <param name="sendTime"></param> /// <param name="fromQQ"></param> /// <param name="msg"></param> /// <param name="font"></param> /// <returns></returns> public override int ProcessPrivateMessage(int subType, int sendTime, long fromQQ, string msg, int font) { try { mainForm.displayMsg2("处理私聊消息:" + subType + "," + sendTime + "," + msg + "," + font); MemberService memberService = new MemberService(); //用户发来的消息日志 MyLogUtil.WriteQQDialogueLog(fromQQ, msg); //获取的消息 mainForm.displayMsg(msg); //说明用户回复的是指定的关键词 Hashtable keywords = SystemConfig.keywords; string keywordsValue = (string)keywords[msg]; if (!string.IsNullOrWhiteSpace(keywordsValue)) { //给用户回复的信息日志 MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, keywordsValue); //发送消息 CoolQApi.SendPrivateMsg(fromQQ, keywordsValue); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } //判断用户是否是想搜取 if (msg.StartsWith("搜")) { Member member = memberService.GetMemberDate(fromQQ); if (member.Type == 3)// 1不是会员 2 会员过期 3 正常会员 { String url = ""; try { string searchContent = msg.Substring(1); if (string.IsNullOrWhiteSpace(searchContent)) { CoolQApi.SendPrivateMsg(fromQQ, "请输入要搜索的内容,例如:搜黑豹"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else { CoolQApi.SendPrivateMsg(fromQQ, "正在寻找资源,请稍等..."); List <KunyunInfo> list = KuYunSearch.Search(searchContent); if (list == null || list.Count == 0) { CoolQApi.SendPrivateMsg(fromQQ, "暂时未找到此资源"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else if (list.Count == 1)//说明找到了具体电影的链接 { StringBuilder sb = new StringBuilder("我找到了以下资源(电影含多个链接对应不同清晰度,电视剧不同集):"); foreach (KunyunInfo k in list) { sb.Append("《" + k.name + "》 "); foreach (string res in k.url) { if (k.resourceTYpe == 1)//m3u8 { sb.Append(MyLinkCoverter.CovertUrlInSuoIm(res, true) + " \r\n"); } else//直接观看链接 { sb.Append(MyLinkCoverter.CovertUrlInSuoIm(res, false) + " \r\n"); } } } CoolQApi.SendPrivateMsg(fromQQ, sb.ToString()); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else//说明找到了相关的好几个电影 { StringBuilder sb = new StringBuilder("我找到了多个相关资源,请聊天回复以下具体某个资源获取观影链接: \r\n"); foreach (KunyunInfo k in list) { sb.Append("搜" + k.name + " \r\n"); } CoolQApi.SendPrivateMsg(fromQQ, sb.ToString()); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } } catch (Exception e2) { CoolQApi.SendPrivateMsg(fromQQ, "小喵出现问题,请过会再来尝试"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } else if (member.Type == 2) { CoolQApi.SendPrivateMsg(fromQQ, "你的会员已过期,会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包)"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else { CoolQApi.SendPrivateMsg(fromQQ, "你还不是会员,会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包)"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } //判断是否是指定的视频平台链接 if (MyLinkCoverter.JugePlatform(msg)) { MyResponse <MovieInfo> myResponse = MyLinkCoverter.CovertInSuoIm(msg); if (myResponse.Code == 0)//获取成功了 { //给用户回复的信息日志 MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, myResponse.Msg.MovieName + " " + myResponse.Msg.Url); CoolQApi.SendPrivateMsg(fromQQ, "主人,这是你的观影地址:" + " " + myResponse.Msg.Url + ",由于需要加载影片,请耐心等待,如果不能播放,请刷新或换浏览器,更多好玩的电影跟班,关注微信公众号[电影信封]"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else { //给用户回复的信息日志 MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, SystemConfig.NoConvertPlatform); CoolQApi.SendPrivateMsg(fromQQ, SystemConfig.NoConvertPlatform); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } //判断是否收到转账 //充值会员 if (!string.IsNullOrWhiteSpace(msg) && msg.Contains("[转账]") && (msg.Contains("元已转账成功,请使用手机QQ查看。") || msg.Contains("元转账需收款,请使用手机QQ查看。"))) { try { string value = msg.Replace("[转账]", ""); value = value.Replace("元已转账成功,请使用手机QQ查看。", ""); value = value.Replace("元转账需收款,请使用手机QQ查看。", ""); value = value.Trim(); double money = Convert.ToDouble(value); if (money == SystemConfig.MoneyForWeekPay || money == SystemConfig.MoneyForMonthPay) { Member member = memberService.Recharge(money, fromQQ); MyLogUtil.WriteZhuanZhangLog(fromQQ, "用户充值" + money); CoolQApi.SendPrivateMsg(fromQQ, "充值成功,会员到期时间:" + member.DateDesp + ",QQ回复“会员”,查看会员到期日"); MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, "充值成功,会员到期时间:" + member.DateDesp + ",QQ回复“会员”,查看会员到期日"); CoolQApi.SendPrivateMsg(fromQQ, "QQ回复“会员”或微信关注[电影信封],获得观看会员资源"); MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, "QQ回复“会员”或微信关注[电影信封],获得观看会员资源"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else { MyLogUtil.WriteZhuanZhangLog(fromQQ, "用户转账额度不符合," + money); MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, "用户转账额度不符合," + money); CoolQApi.SendPrivateMsg(fromQQ, "主人,目前只支持" + SystemConfig.MoneyForWeekPay + "、" + SystemConfig.MoneyForMonthPay + "元的充值金额,更多好玩的电影跟班,关注微信公众号[电影信封]"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } catch (Exception e) { //解析转账出现问题 MyLogUtil.ErrToLog(fromQQ, "转账失败,原因:" + e); MyLogUtil.WriteZhuanZhangLog(fromQQ, "转账失败" + e); MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, "主人,不好意思,我现在生病啦,不能为你提供资源链接,转账金额1天后自动退还,更多好玩的电影跟班,关注微信公众号[电影信封]"); CoolQApi.SendPrivateMsg(fromQQ, "主人,不好意思,我现在生病啦,不能为你提供资源链接,转账金额1天后自动退还,更多好玩的电影跟班,关注微信公众号[电影信封]"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } //会员到期日 if ("会员".Equals(msg)) { Member member = memberService.GetMemberDate(fromQQ); if (member.Type == 3)// 1不是会员 2 会员过期 3 正常会员 { CoolQApi.SendPrivateMsg(fromQQ, "会员过期时间:" + member.DateDesp + " \r\n常见命令:" + systemConfigJson.Command); CoolQApi.SendPrivateMsg(fromQQ, "会员价格:会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包,不支持其他金额)"); } else if (member.Type == 2) { CoolQApi.SendPrivateMsg(fromQQ, "你的会员已过期," + member.DateDesp + ",会员价格:会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包)"); } else { CoolQApi.SendPrivateMsg(fromQQ, "你还不是会员,会员价格:会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包)"); CoolQApi.SendPrivateMsg(fromQQ, "会员常见命令:" + systemConfigJson.Command); } return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } //资源列表 if ("资源".Equals(msg)) { //付费电影资源列表 CoolQApi.SendPrivateMsg(fromQQ, "查看所有资源资源码:" + systemConfigJson.ResourceUrl); CoolQApi.SendPrivateMsg(fromQQ, "也可以搜索指定电影哦,命令:搜+电影名,举例:搜黑豹"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } //解析分享过来的是不是指定平台的链接(拦截形如xxxhttp://www.baidu.comxxx,但是有些新闻也是这种格式的) MyResponse <string> sharedUrl = null; sharedUrl = MyLinkCoverter.ParsePlatform(msg); if (sharedUrl.Code == 0)//正常链接 { sharedUrl.Msg = MyLinkCoverter.CovertUrlInSuoIm(sharedUrl.Msg, true); //给用户回复的信息日志 MyLogUtil.WriteQQDialogueLogOfMe(fromQQ, "主人,这是你的观影地址:" + " " + sharedUrl.Msg + ",由于需要加载影片,请耐心等待,如果不能播放,请刷新或换浏览器,更多好玩的电影跟班,关注微信公众号[电影信封]"); CoolQApi.SendPrivateMsg(fromQQ, "主人,这是你的观影地址:" + " " + sharedUrl.Msg + ",由于需要加载影片,请耐心等待,如果不能播放,请刷新或换浏览器,更多好玩的电影跟班,关注微信公众号[电影信封]"); CoolQApi.SendPrivateMsg(fromQQ, "请确保发送给我的是主流视频平台的http或https链接,不要带其他信息,否则不能正常观看呦"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } //付费资源KeyNotFoundException //目前资源识别是4位数字 ResourceInfo resourceInfo = null; try { resourceInfo = (ResourceInfo)systemConfigJson.ResourceKl[msg]; } catch (KeyNotFoundException ke) { resourceInfo = null; } if (resourceInfo != null) { Member member = memberService.GetMemberDate(fromQQ); if (member.Type == 3)// 1不是会员 2 会员过期 3 正常会员 { String url = ""; try { if (resourceInfo.Type == 2)////资源类型 1 链接直接使用 2 需使用优酷转vip的接口 { url = SystemConfig.ResourceApi + resourceInfo.Url; } else { url = resourceInfo.Url; } url = MyLinkCoverter.CovertUrlInSuoIm(url); CoolQApi.SendPrivateMsg(fromQQ, "《" + resourceInfo.Name + "》" + " " + MyLinkCoverter.CovertUrlInSuoIm(resourceInfo.Url)); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } catch (Exception e2) { CoolQApi.SendPrivateMsg(fromQQ, "小喵出现问题,请过会再来尝试"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } else if (member.Type == 2) { CoolQApi.SendPrivateMsg(fromQQ, "你的会员已过期,会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包)"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } else { CoolQApi.SendPrivateMsg(fromQQ, "你还不是会员,会员价格:" + SystemConfig.MoneyForWeekPay + "元-7天," + SystemConfig.MoneyForMonthPay + "元30天,请转账给此QQ,进行充值(不收红包)"); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } else { //查看信息是否是4位数字 try { if (msg.Length == 4) { //如果是四位数字 int kl = Convert.ToInt32(msg); CoolQApi.SendPrivateMsg(fromQQ, "此口令资源不存在,更多资源电影码:" + systemConfigJson.ResourceUrl); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } catch (Exception e)//如果是4位非数字 { CoolQApi.SendPrivateMsg(fromQQ, "此口令资源不存在,更多资源电影码:" + systemConfigJson.ResourceUrl); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } } //以上所有资源都不匹配 // return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } catch (Exception e) { MyLogUtil.ErrToLog(fromQQ, "发生不被期待的异常:" + e); return(base.ProcessPrivateMessage(subType, sendTime, fromQQ, msg, font)); } }