private void LoadMoreMessages() { MessageGetHistoryObject results = D.api.Messages.GetHistory(new MessagesGetHistoryParams() { PeerId = D.Context.ActiveChat.Conv.Peer.Id, Offset = lastMesage }); lastMesage += 20; MsgList.AddRange(results.Messages); foreach (var i in results.Messages) { var tmpitem = new ListViewItem(); var u = UserList.Find(item => item.Id == i.FromId); tmpitem.Text = u.FirstName + " " + u.LastName; ListViewItem.ListViewSubItem t1 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem t2 = new ListViewItem.ListViewSubItem(); t1.Text = i.Text; if (t1.Text == "") { t1.Text = "Вложение"; } t2.Text = DateSince((DateTime)i.Date); tmpitem.SubItems.Add(t1); tmpitem.SubItems.Add(t2); ListViewMsg.Items.Add(tmpitem); } // MessagesListView.Clear(); }
public History(MessageGetHistoryObject dialog, Autorize account, long id) { InitializeComponent(); _account = account; idSendMessage = id; foreach (var s in dialog.Messages) { us = _account.Api.Users.Get(new long[] { long.Parse(s.FromId.ToString()) }).FirstOrDefault(); listBox1.Items.Add(s.Date + " " + us.FirstName); listBox1.Items.Add(s.Text); } }
static void Main(string[] args) { Dictionary <string, int> words = new Dictionary <string, int>(); Dictionary <string, string> keys = new Dictionary <string, string>(); VkNet.VkApi vkApi = new VkNet.VkApi(); vkApi.Authorize(new ApiAuthParams { ApplicationId = 000000, Login = "******", Password = "******", Settings = VkNet.Enums.Filters.Settings.All }); Random r = new Random(); List <User> users = new List <User>(); List <long> aaa = new List <long>(); Test yyyy = Test.Load("msg_sc.json"); Regex rr = new Regex("\\)+"); // yyyy.i -= 101032;//Хомяки //ulong hor = (ulong)vkApi.Messages.GetHistory(new VkNet.Model.RequestParams.MessagesGetHistoryParams { PeerId = 2000000107 }).Messages[0].OutRead; List <Message> msg = new List <Message>(); MessageGetHistoryObject aa = new MessageGetHistoryObject(); while (yyyy.i < 50980) { try { int y = r.Next(21); aa = vkApi.Messages.GetHistory(new VkNet.Model.RequestParams.MessagesGetHistoryParams { PeerId = 2000000168, //для Аколитской флудилки цифра - 148, для студсовета - 168 Count = 180 + y, Offset = yyyy.i, Reversed = true }); yyyy.i += 180 + y; } catch (Exception e) { yyyy.i += 200; continue; } Thread.Sleep(250 + r.Next(750)); msg.AddRange(aa.Messages); } foreach (Message s in msg) { //int day = (((DateTime)s.Date).Year - 2016) * 365 + ((DateTime)s.Date).DayOfYear; if (yyyy.users.ContainsKey((long)s.FromId)) { yyyy.users[(long)s.FromId]++; } else { yyyy.users.Add((long)s.FromId, 1); } if (s.Emoji.HasValue || rr.Match(s.Text).Value == s.Text) { if (yyyy.smiles.ContainsKey((long)s.FromId)) { yyyy.smiles[(long)s.FromId]++; } else { yyyy.smiles.Add((long)s.FromId, 1); } } if (s.Attachments.Count > 0) { if (yyyy.pictures.ContainsKey((long)s.FromId)) { yyyy.pictures[(long)s.FromId]++; } else { yyyy.pictures.Add((long)s.FromId, 1); } } if (s.Attachments.Count > 0 || s.Emoji.HasValue || rr.Match(s.Text).Value == s.Text) { if (yyyy.flood.ContainsKey((long)s.FromId)) { yyyy.flood[(long)s.FromId]++; } else { yyyy.flood.Add((long)s.FromId, 1); } } /*if (yyyy.dates.ContainsKey(day)) * yyyy.dates[day]++; * else yyyy.dates.Add(day, 1);*/ } List <long> a = new List <long>(); foreach (var s in yyyy.users) { a.Add(s.Key); } var gusers = vkApi.Users.Get(a); var lusers = gusers.OrderBy(x => { return(yyyy.users[x.Id]); } ).Reverse(); int tst = 0; int flood = 0; // yyyy.i += 101032; foreach (var s in lusers) { string t = s.FirstName + " " + s.LastName; tst += yyyy.users[s.Id]; if (!yyyy.pictures.ContainsKey(s.Id)) { yyyy.pictures.Add(s.Id, 0); } if (!yyyy.smiles.ContainsKey(s.Id)) { yyyy.smiles.Add(s.Id, 0); } if (!yyyy.flood.ContainsKey(s.Id)) { yyyy.flood.Add(s.Id, 0); } flood += yyyy.flood[s.Id]; Console.WriteLine(t + " нафлудил: " + yyyy.users[s.Id].ToString() + " из них " + yyyy.pictures[s.Id].ToString() + " с картинками, и " + yyyy.smiles[s.Id].ToString() + " со смайлами"); } //Console.WriteLine("Сергей написал " + (ser + seroff).ToString() + " сообщений только из скобочек, из них " + seroff + " не из трех. Злых (><) смайлов было "+serang+". Эл написал "+l+" косящихся глаз."); yyyy.Save("msg_sc.json"); /*using (StreamWriter sw = new StreamWriter("int.txt", false)) * { * foreach (var t in yyyy.dates) * { * sw.Write(t.Value.ToString() + " "); * } * }*/ Console.ReadLine(); }