public override CommonMessageResponse Message_Received(CommonMessage messageObj) { BllUserRole bllUserRole = new BllUserRole(); List <TblUserRole> userInfo = bllUserRole.GetUserRoleByQq(long.Parse(messageObj.UserId)); if (userInfo.Count == 0) { return(new CommonMessageResponse(LoliReply.IdNotBound, messageObj, true)); } var id = userInfo[0].UserId.ToString(); List <Beatmapsets> totalList = new List <Beatmapsets>(); Beatmapsets[] tmpArray; int page = 0; const int count = 10; do { string json = WebRequestUtil.GetResponseString( WebRequestUtil.CreateGetHttpResponse( "https://osu.ppy.sh/users/" + id + "/beatmapsets/graveyard?offset=" + page + "&limit=" + count)); Logger.Debug("GET JSON"); tmpArray = JsonConvert.DeserializeObject <Beatmapsets[]>(json); totalList.AddRange(tmpArray); page += count; if (tmpArray.Length != count) { break; } } while (tmpArray.Length != 0); if (totalList.Count == 0) { return(new CommonMessageResponse("惊了,你竟然会没坑!", messageObj, true)); } Random rnd = new Random(); Beatmapsets beatmap = totalList[rnd.Next(totalList.Count)]; var cqMusic = new CustomMusic("https://osu.ppy.sh/s/" + beatmap.Id, $"https://b.ppy.sh/preview/{beatmap.Id}.mp3", beatmap.Title, $"{beatmap.Artist}\r\n({beatmap.FavouriteCount} fav)", $"https://b.ppy.sh/thumb/{beatmap.Id}l.jpg"); return(new CommonMessageResponse(cqMusic.ToString(), messageObj)); }
public static string GetImgFile(string fileName) { string str = null; IDictionary <string, string> parameters = new Dictionary <string, string> { { "fileName", HttpUtility.UrlEncode(fileName) } }; var response = WebRequestUtil.CreatePostHttpResponse(ApiUrl + "/api/imgfile", parameters); if (response != null) { str = WebRequestUtil.GetResponseString(response); } return(str); }
public override CommonMessageResponse Message_Received(CommonMessage messageObj) { // 查黄图 if (messageObj.Group == null || messageObj.GroupId != "133605766") { return(null); } var imgList = CqCode.GetImageInfo(messageObj.Message); if (imgList == null) { return(null); } List <string> urlList = new List <string>(); List <CosObject> cacheList = new List <CosObject>(); foreach (var item in imgList) { if (Md5List.Keys.Contains(item.Md5)) { cacheList.Add(Md5List[item.Md5]); } else if (item.Size > 1000 * 60) //60KB { urlList.Add(item.Url); } } if (urlList.Count == 0 && cacheList.Count == 0) { return(null); } Logger.Warn("发现了" + (urlList.Count + cacheList.Count) + "张图"); CosAnalyzer model = new CosAnalyzer { result_list = new List <CosObject>() }; if (urlList.Count != 0) { string str = Newtonsoft.Json.JsonConvert.SerializeObject(new { appid = "1252749411", url_list = urlList.ToArray() }); var abc = WebRequestUtil.CreatePostHttpResponse( "http://service.image.myqcloud.com/detection/porn_detect", str, authorization: Signature.Get()); var respStr = WebRequestUtil.GetResponseString(abc); model = Newtonsoft.Json.JsonConvert.DeserializeObject <CosAnalyzer>(respStr); } model.result_list.AddRange(cacheList); int i = 0; foreach (var item in model.result_list) { if (i < imgList.Length && !Md5List.Keys.Contains(imgList[i].Md5)) { Md5List.Add(imgList[i].Md5, item); } i++; switch (item.data.result) { case 0 when item.data.normal_score > item.data.hot_score && item.data.normal_score > item.data.porn_score && item.data.confidence > 40: continue; case 1: case 2: CqApi.SetGroupBan(messageObj.GroupId, messageObj.UserId, 24 * 60 * 60); return(new CommonMessageResponse("...", messageObj)); default: break; } if (item.data.porn_score >= item.data.hot_score && item.data.porn_score > 65) { return(AddCount(messageObj)); } if (item.data.hot_score >= item.data.porn_score && item.data.hot_score > item.data.normal_score && item.data.hot_score > 80) { return(AddCount(messageObj)); } break; } return(null); //if (user != "2241521134") return null; }