示例#1
0
    public Task Send(long chatId, string message, CoreKeyboard keyboard = null, IEnumerable <string> attachments = null)
    {
        message = TrimText(message);
        var replyMarkup = KeyboardConverter.FromCoreToTg(keyboard);

        return(_botClient.SendTextMessageAsync(chatId, message, replyMarkup: replyMarkup));
    }
示例#2
0
    private async Task HandleCallback(CallbackQuery query)
    {
        var msg = _mapper.Map <Message>(query);
        await _commandsService.ExecuteCommand(msg, OnAnyResult, OnAnyResult);

        async Task OnAnyResult(IResult res)
        {
            await _botClient.AnswerCallbackQueryAsync(query.Id);

            await _botClient.EditMessageTextAsync(new ChatId(query.From.Id), query.Message.MessageId, res.Message);

            if (res.Keyboard.IsInline)
            {
                await _botClient.EditMessageReplyMarkupAsync(new ChatId(query.From.Id), query.Message.MessageId,
                                                             KeyboardConverter.FromCoreToTg(res.Keyboard) as InlineKeyboardMarkup);
            }
        }
    }