public Message[] GetDialogsIds() { Message[] mas = new Message[Count]; uint count = __MAX_BUFFER_SIZE > mas.Length ? (uint)mas.Length : (uint)__MAX_BUFFER_SIZE; for (uint k = 0, i = 0; i < mas.Length; i += count) { if ((mas.Length - i) < count) { count = (uint)mas.Length - i; } MessagesGetObject dialogs = api.Messages.GetDialogs(new MessagesDialogsGetParams { Count = count, Offset = (int)i }); foreach (Message dialog in dialogs.Messages) { mas[k] = dialog; k++; } } return(mas); }
private void ReceiveMessages(object source, ElapsedEventArgs e) { MessagesGetObject result = api.Messages.Get(new MessagesGetParams { Out = 0, TimeOffset = 5, Count = 5 }); ICollection <Message> messages = result.Messages; if (messages.Count > 0) { foreach (Message msg in messages) { if (msg.ChatId != null) { Parent.ProcessMessage(msg.Body, this, (long)msg.ChatId); } else { Parent.ProcessMessage(msg.Body, this, (long)msg.UserId); } } } }
public Message[] DialogHistory(uint id) { Message[] mas = new Message[api.Messages.GetHistory(new MessagesGetHistoryParams { UserId = id }).TotalCount]; uint count = __MAX_BUFFER_SIZE > mas.Length ? (uint)mas.Length : (uint)__MAX_BUFFER_SIZE; for (uint k = 0, i = 0; i < mas.Length; i += count) { if ((mas.Length - i) < count) { count = (uint)mas.Length - i; } MessagesGetObject dialogHistory = api.Messages.GetHistory(new MessagesGetHistoryParams { UserId = id, Count = count, Offset = (int)i }); foreach (Message dialog in dialogHistory.Messages) { mas[k] = dialog; k++; } } return(mas); }
private static void GetSpotsFromCity(long CheckedUserID, MessagesGetObject dialog) { string city = dialog.Messages[0].Body; List <Spot> spotList = GetSpotListByCity("Томск"); if (spotList == null) { SendMessage(CheckedUserID, "К сожалению в вашем городе уже всё съедено("); return; } //foreach (var spot in spotList) //{ SendSpots(CheckedUserID, spotList); //} }
private string ReturnReques(MessagesGetObject mess) { string forId = ""; if (mess.Messages[0].Body.Contains("vk.com/id")) { forId = mess.Messages[0].Body.Substring(9); mess.Messages[0].Body = "Friends"; } switch (mess.Messages[0].Body) { case "/groups": string textRet = "👇Пиарить только здесь👇"; SearchPostsGrp SrchPstGr = new SearchPostsGrp(_api); for (int i = 0; i < SrchPstGr.groupsWhereNeedMakePosts.Length; i++) { textRet += "\n ✖vk.com/club" + SrchPstGr.groupsWhereNeedMakePosts[i].ToString().Remove(0, 1); } return(textRet); case "/stat": return("Подсчет..."); case "/info": return("информация"); case "Friends": return("Не сделано"); // TODO: доделать int pars = 0; if (Int32.TryParse(forId, out pars)) { return(CheckDidAddFriends(pars)); } else { return("Указывать id в виде 'vk.com/xxxxx'"); } case "/list": return(List(mess.Messages[0].UserId.Value)); default: return(null); } }
private string Get_Key(VkApi api, int idsob) { string newkey; while (true) { #pragma warning disable CS0618 // Тип или член устарел MessagesGetObject getDialogs = api.Messages.GetDialogs(new MessagesDialogsGetParams { Count = 200 }); #pragma warning restore CS0618 // Тип или член устарел Thread.Sleep(500); var curmessage = ""; var state = false; int i; for (i = 0; i < 200; i++) { if (getDialogs.Messages[i].UserId == idsob) { state = (bool)getDialogs.Messages[i].Out; curmessage = getDialogs.Messages[i].Body; break; } } if (curmessage.Length < 13) { continue; } if (curmessage.Substring(0, 13) == "<RSAKeyValue>" && state == false) { newkey = curmessage; break; } } Dispatcher.BeginInvoke(new ThreadStart(delegate { Chat.Document.Blocks.Add(new Paragraph(new Run("Ключ получен"))); })); return(newkey); }
private string Get_Sim_Key(VkApi api, int idsob) { Dispatcher.BeginInvoke(new ThreadStart(delegate { Chat.Document.Blocks.Add(new Paragraph(new Run("Получаем ключ симметричного шифрования..."))); })); string newkey; while (true) { #pragma warning disable CS0618 // Тип или член устарел MessagesGetObject getDialogs = api.Messages.GetDialogs(new MessagesDialogsGetParams { Count = 200 }); #pragma warning restore CS0618 // Тип или член устарел Thread.Sleep(500); var curmessage = ""; var state = false; int i; for (i = 0; i < 200; i++) { if (getDialogs.Messages[i].UserId == idsob) { state = (bool)getDialogs.Messages[i].Out; curmessage = getDialogs.Messages[i].Body; break; } } if (state == false && curmessage.Substring(0, 13) != "<RSAKeyValue>") { newkey = Utils.AsimDecryptor.RSADecryption(curmessage); break; } } Dispatcher.BeginInvoke(new ThreadStart(delegate { Chat.Document.Blocks.Add(new Paragraph(new Run("Ключ получен!!!"))); })); return(newkey); }
private bool Check_Key_Without_GUI(VkApi api, int idsob) { bool pr = true; #pragma warning disable CS0618 // Тип или член устарел MessagesGetObject getDialogs = api.Messages.GetDialogs(new MessagesDialogsGetParams { Count = 200 }); #pragma warning restore CS0618 // Тип или член устарел var curmessage = ""; var state = false; for (var i = 0; i < 200; i++) { if (getDialogs.Messages[i].UserId == idsob) { state = (bool)getDialogs.Messages[i].Out; curmessage = getDialogs.Messages[i].Body; break; } } if (curmessage.Length < 13) { return(false); } if (curmessage.Substring(0, 13) == "<RSAKeyValue>" && state == false) { return(true); } if (pr) { return(false); } return(false); }