public override CommonMessageResponse Message_Received(CommonMessage messageObj) { if (messageObj.MessageType == MessageType.Private) { return(null); } string groupId = messageObj.GroupId ?? messageObj.DiscussId; if (!GroupDic.ContainsKey(groupId)) { GroupDic.GetOrAdd(groupId, new GroupSettings { GroupId = groupId, MessageObj = messageObj }); } //GroupDic[groupId].GroupType = messageObj.GroupId == null ? MessageType.Discuss : MessageType.Group; var imgList = CqCode.GetImageInfo(messageObj.Message); if (imgList == null) { return(null); } foreach (var item in imgList) { if (item.Extension.ToLower() == ".gif") { continue; } if (item.FileInfo.Exists) { GroupDic[groupId].PathQueue.Enqueue(item.FileInfo.FullName); } else { WebRequestUtil.GetImageFromUrl(item.Url, item.Md5, item.Extension); GroupDic[groupId].PathQueue.Enqueue(Path.Combine(Domain.CurrentDirectory, "images", item.Md5 + item.Extension)); } _totalCount++; } if (GroupDic[groupId].Task == null || GroupDic[groupId].Task.IsCompleted || GroupDic[groupId].Task.IsCanceled) { GroupDic[groupId].Task = Task.Run(() => RunDetector(GroupDic[groupId])); Logger.Info("[" + groupId + "] (熊猫) 共 " + _totalCount); } return(null); }
public override CommonMessageResponse Message_Received(CommonMessage messageObj) { if (messageObj.Group == null) { return(null); } //if (user != "2241521134") return null; _user = messageObj.UserId; _group = messageObj.GroupId; _messageId = messageObj.MessageId; var imgList = CqCode.GetImageInfo(messageObj.Message); if (imgList == null) { return(null); } foreach (var item in imgList) { if (item.Extension.ToLower() == ".gif") { continue; } if (item.FileInfo.Exists) { _pathList.Add(item.FileInfo.FullName); } else { WebRequestUtil.GetImageFromUrl(item.Url, item.Md5, item.Extension); _pathList.Add(Path.Combine(Domain.CurrentDirectory, "images", item.Md5 + item.Extension)); } _totalCount++; } _thread = new Thread(RunDetector); _thread.Start(_pathList); Logger.Warn("已经发送了请求,目前队列中共" + _totalCount); return(null); }
public static Bitmap GetStrokeString(string str) { var response = WebRequestUtil.GetImageFromUrl(ApiUrl + "/api/strokestring?str=" + str, Guid.NewGuid().ToString(), "png"); return(new Bitmap(response)); }