void LoopGroup(VkApi _GroupApi, LongPollServerResponse _poolGroupGetResponse) { TPLConsole.ConsoleWrite("GroupPool loop started >" + _GroupApi.UserId); int processed = 0; while (true) { var pool = _GroupApi.Groups.GetBotsLongPollHistory( new BotsLongPollHistoryParams() { Server = _poolGroupGetResponse.Server, Ts = _poolGroupGetResponse.Ts, Key = _poolGroupGetResponse.Key, Wait = 25 }); if (pool?.Updates == null) { continue; } for (int i = processed; i < pool.Updates.Count(); i++) { MessagesHandler.ReadMessage(pool.Updates.ElementAt(i)); processed++; } } }
public static void WallNew(GroupUpdate message) { Task.Run(() => { TPLConsole.ConsoleWrite("Post process"); var attachments = new List <MediaAttachment> { (Wall)message.WallPost }; GroupApi.Messages.Send(new MessagesSendParams { RandomId = new Random().Next(2 ^ 32), PeerId = 2000000001, //с59 Attachments = attachments, }); }); }
public static void ReadMessage(GroupUpdate message) { Task.Run(() => { switch (message.Type.ToString()) { default: TPLConsole.ConsoleWrite(message.Type.ToString(), ConsoleColor.Red); break; case "message_new": CheckMessage.ProcessMessage(message); break; case "wall_post_new": TPLConsole.ConsoleWrite(message.Type.ToString(), ConsoleColor.Blue); ProcessWall.WallNew(message); break; } }); }