public static Telegram.Models.SendMessage CreateTelegramReplay(this SecretSantaBot.Message tlgMsg) { var mes = new Telegram.Models.SendMessage(); mes.chat_id = tlgMsg.Room; mes.text = tlgMsg.Text; mes.disable_notification = tlgMsg.DisableNotification; mes.reply_to_message_id = tlgMsg.reply_to_message_id.GetValueOrDefault(); if (tlgMsg.keybord != null && tlgMsg.keybord.Inline == false) { mes.reply_markup = tlgMsg.keybord.CreateKeyboard(); } if (tlgMsg.keybord != null && tlgMsg.keybord.Inline == true) { mes.reply_markup = tlgMsg.keybord.CreateInlineKeyboard(); } if (tlgMsg.RemoveKeyboard) { mes.reply_markup = new ReplyKeyboardRemove(); } if (tlgMsg.ForceReplay) { mes.reply_markup = new ForceReply(); } return(mes); }
public static SecretSantaBot.Message CreateBotMessage(this Telegram.Models.Message tlgMsg) { var mes = new SecretSantaBot.Message(); mes.User = new User() { id = tlgMsg.from.id, name = $"{tlgMsg.from.username} {tlgMsg.from.first_name}" //todo исправить на чтото более удобное }; mes.msgId = tlgMsg.message_id; mes.Room = tlgMsg.chat.id; mes.RoomType = tlgMsg.chat.type; mes.Text = tlgMsg.text; mes.reply_to_message_id = tlgMsg.reply_to_message?.message_id; return(mes); }
public static SecretSantaBot.Message CreateBotMessage(this Telegram.Models.CallbackQuery tlgMsg) { var mes = new SecretSantaBot.Message(); mes.msgId = tlgMsg.message.message_id; mes.User = new User() { id = tlgMsg.from.id, name = $"{tlgMsg.from.username} {tlgMsg.from.first_name}" }; mes.Room = tlgMsg.message.chat.id; mes.RoomType = tlgMsg.message.chat.type; mes.Text = tlgMsg.message.text; mes.reply_to_message_id = tlgMsg.message.reply_to_message?.message_id; mes.CommandId = tlgMsg.id; mes.Command = tlgMsg.data; return(mes); }
public bool SendResponse(SecretSantaBot.Message response) { try { if (response.callback_query_id == null) { var message = response.CreateTelegramReplay(); var result = _telegram.SendMessage(message); return(result != null); } else { var mes = response.CreateTelegramCallbackQueryReplay(); var result = _telegram.SendAnswerCalbackQuery(mes); return(result != null); } } catch (Exception exception) { throw new Exception("can't connect to telegram server."); } }
public static Telegram.Models.answerCallbackQuery CreateTelegramCallbackQueryReplay(this SecretSantaBot.Message tlgMsg) { var mes = new Telegram.Models.answerCallbackQuery() { callback_query_id = tlgMsg.callback_query_id, show_alert = tlgMsg.show_alert, text = tlgMsg.Text }; return(mes); }