public static Result <object> editMessageReplyMarkup(long chat_id, long message_id, string inline_message_id = "", InlineKeyboardMarkup keyboard = null) //Can apparently return a bool as well. { EditReplyMarkupRequest ermr = new EditReplyMarkupRequest() { chat_id = chat_id, message_id = message_id, //inline_message_id = inline_message_id, reply_markup = keyboard }; Result <object> result = null; try { result = sendRequest <object>(Method.editMessageReplyMarkup, buildRequest <EditReplyMarkupRequest>(ermr)); return(result); } catch { Logger.LogWarn("Edit Keyboard Failed " + chat_id); } return(null); }
/// <summary> /// Edit a photo caption within a Chat, Group, Channel, or User. Returns the Result<Message> object on success, or Result<bool> if the edited message was the bot's</bool>. /// </summary> /// <param name="chat_id">The Id number of the chat where the message to be edited is. Can be a User, Channel, Or group. Cannot be a bot.</param> /// <param name="message_id">Identifier of the caption to edit. Can be a User, Channel, Or group. Cannot be a bot.</param> /// <param name="inline_message_id">Required if chat_id and message_id are not specified. Identifier of the inline message.</param> /// <param name="caption">The new caption for the Image. Character Limit of 1024.</param> /// <param name="parse_mode">Markdown, HTML, or Empty. Tells telegram how to parse special markdown flags in the text. Markdown by default.</param> /// <param name="keyboard">InlineKeyboardMarkup Object. Pass a built Keyboard object in here to include it in your messages.</param> /// <returns></returns> public static Result <object> editMessageCaption(long chat_id, long message_id, string caption, string parse_mode = "markdown", InlineKeyboardMarkup keyboard = null) //Can apparently return a bool as well. { EditMessageCaptionRequest emr = new EditMessageCaptionRequest() { chat_id = chat_id, message_id = message_id, caption = caption, parse_mode = parse_mode }; if (keyboard != null) { emr.reply_markup = keyboard; } Result <object> result = null; try { result = sendRequest <object>(Method.editMessageCaption, buildRequest <EditMessageCaptionRequest>(emr)); return(result); } catch { Logger.LogWarn("Failed to Parse wrong datatype 1 EditMessageText()"); } return(null); }
public static bool AdminCommand(Message msg) { if (!Configs.RunningConfig.Admins.Contains(msg.from.id) && (Configs.RunningConfig.Owner != msg.from.id)) { return(false); } string[] cmd = msg.text.Split(' '); switch (Utilities.isAdminCommand(cmd[0])) { case "makemenu": { // /makemenu Yes,noop,0|No,noop,1|Back,noop,2|forward,noop,2 InlineKeyboardMarkup kb = new InlineKeyboardMarkup(); msg.text = msg.text.Replace("$makemenu ", ""); string[] buttons = msg.text.Split('|'); foreach (string button in buttons) { string[] bargs = button.Split(','); try { kb.addCallbackButton(bargs[0], bargs[1], Convert.ToInt32(bargs[2])); } catch { Methods.sendReply(msg.chat.id, msg.message_id, "Missing button argument."); return(true); } } Methods.sendMessage(msg.chat.id, "Demo Keyboard", "markdown", kb); return(true); } case "save": { Database.SaveConfig(); Methods.sendReply(msg.chat.id, msg.message_id, "Flushed Database To Disk."); return(true); } case "adminmenu": { if (msg.from.id != Configs.RunningConfig.Owner) { Logger.LogWarn("User attempted to use /adminmenu command: " + msg.from.id); return(true); } Logger.LogAdmin("Admin Menu Called: " + msg.from.id); Result <Message> res = Methods.sendMessage(msg.from.id, "*DreadBot Administration Menu*\n\n`DreadBot Managment`\nUsed to fine tune the bot, plus other senstive, and powerful options.\n\n`DataBase Management`\nConfigure Specific Database options, and backup as needed.\n\n`Plugin Manager`\nAdd, Remove and Configure plugins to give DreadBot its purpose.", "Markdown", Menus.AdminMenu()); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } return(true); } case "admin": { return(true); } case "setdebug": { if (msg.from.id != Configs.RunningConfig.Owner) { Logger.LogWarn("User attempted to use /setdebug command: " + msg.from.id); return(true); } if (msg.chat.type == "private" || msg.chat.type == "channel") { Result <Message> res = Methods.sendReply(msg.chat.id, msg.message_id, "You can only assign a Group or Supergroup to be the Debug Chat.\nIf you want to reset it back to PM, please use the admin menu."); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } return(true); } else { if (msg.chat.id == Configs.RunningConfig.AdminChat) { Result <Message> res = Methods.sendReply(msg.chat.id, msg.message_id, "Debug Chat is already set to this group."); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } return(true); } else { Configs.RunningConfig.AdminChat = msg.chat.id; Database.SaveConfig(); Result <Message> res = Methods.sendReply(msg.chat.id, msg.message_id, "Debug Chat is now set to this group."); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } Logger.LogAdmin("Debug Chat has been set to: " + msg.chat.id); return(true); } } } default: return(false); } }
public static bool AdminCommand(Message msg) { if (!Configs.RunningConfig.Admins.Contains(msg.from.id) && (Configs.RunningConfig.Owner != msg.from.id)) { return(false); } string[] cmd = msg.text.Trim().Split(' '); switch (Utilities.isAdminCommand(cmd[0])) { case "makemenu": { // /makemenu Yes,noop,0|No,noop,1|Back,noop,2|forward,noop,2 InlineKeyboardMarkup kb = new InlineKeyboardMarkup(); msg.text = msg.text.Replace("$makemenu ", ""); string[] buttons = msg.text.Split('|'); foreach (string button in buttons) { string[] bargs = button.Split(','); try { kb.addCallbackButton(bargs[0], bargs[1], Convert.ToInt32(bargs[2])); } catch { Methods.sendReply(msg.chat.id, msg.message_id, "Missing button argument."); return(true); } } Methods.sendMessage(msg.chat.id, "Demo Keyboard", "markdown", kb); return(true); } case "save": { Database.SaveConfig(); Methods.sendReply(msg.chat.id, msg.message_id, "Flushed Database To Disk."); return(true); } case "adminmenu": { if (msg.from.id != Configs.RunningConfig.Owner) { Logger.LogWarn("User attempted to use /adminmenu command: " + msg.from.id); return(true); } Logger.LogAdmin("Admin Menu Called: " + msg.from.id); Menus.PostAdminMenu(msg.from.id); return(true); } case "admintoken": { string token = Utilities.CreateAdminToken(false); Methods.sendMessage(msg.from.id, "Have an admin send this to me to add them to the admin list.\n`/token " + token + "`"); return(true); } case "setdebug": { if (msg.from.id != Configs.RunningConfig.Owner) { Logger.LogWarn("User attempted to use /setdebug command: " + msg.from.id); return(true); } if (msg.chat.type == "private" || msg.chat.type == "channel") { Result <Message> res = Methods.sendReply(msg.chat.id, msg.message_id, "You can only assign a Group or Supergroup to be the Debug Chat.\nIf you want to reset it back to PM, please use the admin menu."); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } return(true); } else { if (msg.chat.id == Configs.RunningConfig.AdminChat) { Result <Message> res = Methods.sendReply(msg.chat.id, msg.message_id, "Debug Chat is already set to this group."); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } return(true); } else { Configs.RunningConfig.AdminChat = msg.chat.id; Database.SaveConfig(); Result <Message> res = Methods.sendReply(msg.chat.id, msg.message_id, "Debug Chat is now set to this group."); if (!res.ok) { Logger.LogError("Error contacting the admin Chat: " + res.description); } Logger.LogAdmin("Debug Chat has been set to: " + msg.chat.id); return(true); } } } default: return(false); } }