public override CommonMessageResponse Message_Received(CommonMessage messageObj) { string id; string uname; if (OsuId == null) { BllUserRole bllUserRole = new BllUserRole(); List <TblUserRole> userInfo = bllUserRole.GetUserRoleByQq(long.Parse(messageObj.UserId)); if (userInfo.Count == 0) { return(new CommonMessageResponse(LoliReply.IdNotBound, messageObj, true)); } id = userInfo[0].UserId.ToString(); uname = userInfo[0].CurrentUname; } else { int userNum = OldSiteApi.GetUser(OsuId, out var userObj); if (userNum == 0) { return(new CommonMessageResponse(LoliReply.IdNotFound, messageObj, true)); } if (userNum > 1) { // ignored } id = userObj.user_id; uname = userObj.username; } List <KudosuInfo> totalList = new List <KudosuInfo>(); List <KudosuInfo> tmpList; int page = 0; const int count = 20; do { string json = HttpClientUtil.HttpGet("https://osu.ppy.sh/users/" + id + "/kudosu?offset=" + page + "&limit=" + count); Logger.Debug("GET JSON"); tmpList = JsonConvert.DeserializeObject <List <KudosuInfo> >(json); totalList.AddRange(tmpList); page += count; if (totalList.Count != 0) { continue; } return(new CommonMessageResponse("此人一张图都没摸过……", messageObj, true)); } while (tmpList.Count != 0); List <KdInfo> kdInfoList = new List <KdInfo>(); int pastMonth = -1; KdInfo info = null; totalList.Reverse(); foreach (var item in totalList) { if (item.Created_At.Month != pastMonth) { if (pastMonth != -1) { kdInfoList.Add(info); } info = new KdInfo { Time = item.Created_At }; pastMonth = item.Created_At.Month; } if (info != null) { info.Count++; } } if (info != null) { kdInfoList.Add(info); } var cqImg = new FileImage(Draw(kdInfoList, uname)).ToString(); return(new CommonMessageResponse(cqImg, messageObj)); }
public override CoolQRouteMessage OnMessageReceived(CoolQScopeEventArgs scope) { var routeMsg = scope.RouteMessage; string id; string uname; OldSiteApiClient client = new OldSiteApiClient(); if (UserName == null) { BllUserRole bllUserRole = new BllUserRole(); List <TableUserRole> userInfo = bllUserRole.GetUserRoleByQq(long.Parse(routeMsg.UserId)); if (userInfo.Count == 0) { return(routeMsg.ToSource(DefaultReply.IdNotBound, true)); } id = userInfo[0].UserId.ToString(); uname = userInfo[0].CurrentUname; } else { int userNum = client.GetUser(UserComponent.FromUserName(UserName), out var userObj); if (userNum == 0) { return(routeMsg.ToSource(DefaultReply.IdNotFound, true)); } if (userNum > 1) { // ignored } id = userObj.UserId.ToString(); uname = userObj.UserName; } List <KudosuInfo> totalList = new List <KudosuInfo>(); List <KudosuInfo> tmpList; int page = 0; const int count = 20; do { string json = HttpClient.HttpGet("https://osu.ppy.sh/users/" + id + "/kudosu?offset=" + page + "&limit=" + count); Logger.Debug("GET JSON"); tmpList = JsonConvert.DeserializeObject <List <KudosuInfo> >(json); totalList.AddRange(tmpList); page += count; if (totalList.Count != 0) { continue; } return(routeMsg.ToSource("此人一张图都没摸过……", true)); } while (tmpList.Count != 0); List <KdInfo> kdInfoList = new List <KdInfo>(); int pastMonth = -1; KdInfo info = null; totalList.Reverse(); foreach (var item in totalList) { if (item.Created_At.Month != pastMonth) { if (pastMonth != -1) { kdInfoList.Add(info); } info = new KdInfo { Time = item.Created_At }; pastMonth = item.Created_At.Month; } if (info != null) { info.Count++; } } if (info != null) { kdInfoList.Add(info); } var cqImg = new FileImage(Draw(kdInfoList, uname)).ToString(); return(routeMsg.ToSource(cqImg)); }