Ejemplo n.º 1
0
        public override async Task ExecuteAsync(UserMessage userMessage, string[] args)
        {
            if (userMessage.Attachments.Any())
            {
                await UploadFile(userMessage);

                return;
            }

            var payload = new CountClickPayload(Guid.NewGuid()); // фейковый id, т.к. id сообщения не известен до отправки самого сообщения

            var buttons = new MessageButtonsGrid();

            buttons.AddRow().AddSilentButton("Edit message", "edit", payload);
            buttons.AddRow().AddSilentButton("Simple button handler", "nullArgs");
            buttons.AddRow().AddButton("Button as message");
            buttons.AddRow().AddSilentButton("Get my file!", "fileRequest");

            var syncId = await MessageSender.ReplyTextMessageAsync(userMessage, $"You said: {userMessage.Command.Body}", buttons);

            payload.SyncId = syncId;

            buttons.Rows.First().Buttons.First().ChangePayload(payload);

            await MessageSender.EditMessageAsync(userMessage, syncId, $"You said: {userMessage.Command.Body}", buttons);
        }
Ejemplo n.º 2
0
        private async Task Edit(UserMessage userMessage, CountClickPayload payload)
        {
            payload.Increment();
            var buttons = new MessageButtonsGrid();
            var row     = buttons.AddRow();

            row.AddSilentButton("Increment", "edit", payload);
            await MessageSender.EditMessageAsync(userMessage, payload.SyncId, $"Button pressed {payload.Count} times", buttons);
        }