public void UTGroupWC() { try { // && s.GroupId == 566040141 var speakerLists = speakerServices.Query(s => s.Uid == 1069430666); if (speakerLists.Any()) { var builder = string.Join(",", speakerLists.Select(s => s.RawText)) .Replace(",", ""); var seg = new JiebaSegmenter(); var freqs = new Counter <string>(seg.Cut(builder)); var filterFreqs = freqs.Count >= 20 ? freqs?.MostCommon(20) : freqs?.MostCommon(freqs.Count - 1); var WordCloudGen = new WordCloudSharp.WordCloud(300, 300, true); var images = WordCloudGen .Draw(filterFreqs.Select(s => s.Key).ToList(), filterFreqs.Select(s => s.Value).ToList()); var imgName = $"{Environment.CurrentDirectory}\\Images\\{Guid.NewGuid()}.png"; images.Save(imgName, ImageFormat.Png); //delete img //Task.Delay(10); //File.Delete(imgName); } } catch (Exception c) { Console.WriteLine(c.Message); } }
public async ValueTask GroupRecallParse(object sender, GroupRecallEventArgs groupMessage) { try { var r = new Random().Next(5, 9); if (r is 6) { var msg = _speakerServices.Query(s => s.MsgId == groupMessage.MessageId).First(); var user = _userServices.Query(s => s.QNumber == groupMessage.MessageSender.Id.ObjToString()).First(); await groupMessage.SourceGroup.SendGroupMessage($"[有人撤回了消息,但我要说]\r\n[时间:{msg.CreateTime:HH:mm:ss}]\r\n[昵称:{user.NickName}]\r\n[ID:{user.QNumber}]\r\n以下消息正文\r\n{msg.RawText}"); } else { await groupMessage.SourceGroup.SendGroupMessage($"怀孕了就说啊,撤回干嘛,大家都会负责的"); } } catch (Exception) { await groupMessage.SourceGroup.SendGroupMessage($"我感觉他撤回的是图片,我懒得弄,下次一定"); } }