private async void MessageReceivedHandler(object sender, MessageEventArgs args) { int?replyId; if (args.Message.Chat.Type != ChatType.Private) { replyId = args.Message.From.Id; } else { await _bot.SendChatActionAsync(new ChatId(args.Message.Chat.Id), ChatAction.Typing); replyId = null; } var msgId = $"{_username}/{args.Message.MessageId}"; // ReSharper disable once SwitchStatementMissingSomeCases ReceivedMessage message; if (args.Message.Type == MessageType.Text) { if (args.Message.Text == "/remove_keyboard") { await _bot.SendTextMessageAsync(args.Message.Chat.Id, "А теперь отправьте /repeat", replyMarkup : new ReplyKeyboardRemove()); return; } else { message = new ReceivedMessage { ChatId = new AdventureBot.ChatId(MessengerId, args.Message.Chat.Id), UserId = new UserId(MessengerId, args.Message.From.Id), Text = args.Message.Text, MessengerSpecificData = ReceivedMessageAssociatedData.Reply(replyId), MessageId = msgId }; } } else { return; } OnMessageReceived?.Invoke(message); }
private void CallbackReceivedHandler(object sender, CallbackQueryEventArgs args) { var msgId = $"{_username}/{args.CallbackQuery.Message.Chat.Id}/{args.CallbackQuery.Message.MessageId}"; // ReSharper disable once SwitchStatementMissingSomeCases var message = new ReceivedMessage { ChatId = new AdventureBot.ChatId(MessengerId, args.CallbackQuery.Message.Chat.Id), UserId = new UserId(MessengerId, args.CallbackQuery.From.Id), Text = args.CallbackQuery.Data, MessengerSpecificData = ReceivedMessageAssociatedData.Inline(args.CallbackQuery.Message.Chat.Id, args.CallbackQuery.Message.MessageId), MessageId = msgId, }; OnMessageReceived?.Invoke(message); }