Ejemplo n.º 1
0
        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++;
                }
            }
        }
Ejemplo n.º 2
0
        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,
                });
            });
        }
Ejemplo n.º 3
0
        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;
                }
            });
        }