def addfrog(update: Update, context: CallbackContext) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat bot, args = context.bot, context.args user_id = extract_user(message, args) user_member = bot.getChat(user_id) rt = "" reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ELEVATED_USERS_FILE, "r") as infile: data = json.load(infile) if user_id in SUDO_USERS: rt += "Este miembro ya no es un Destroyer, rebajado a Rana Gigante." data["sudos"].remove(user_id) SUDO_USERS.remove(user_id) if user_id in SUPPORT_USERS: rt += "Este usuario ya no es un demonio, rebajado a Rana Gigante." data["supports"].remove(user_id) SUPPORT_USERS.remove(user_id) if user_id in WHITELIST_USERS: rt += "Este usuario ya no es un Sapo Gigante, rebajado a Rana Gigante." data["whitelists"].remove(user_id) WHITELIST_USERS.remove(user_id) if user_id in FROG_USERS: message.reply_text("Este usuario ya es una Rana Gigante.") return "" data["frogs"].append(user_id) FROG_USERS.append(user_id) with open(ELEVATED_USERS_FILE, "w") as outfile: json.dump(data, outfile, indent=4) update.effective_message.reply_text( rt + f"\n{user_member.first_name} ascendió con éxito a Rana Gigante!" ) log_message = ( f"#Rana\n" f"<b>Administrador:</b> {mention_html(user.id, user.first_name)} \n" f"<b>Usuario:</b> {mention_html(user_member.id, user_member.first_name)}" ) if chat.type != "private": log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message return log_message
def addsudo(update: Update, context: CallbackContext) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat bot, args = context.bot, context.args user_id = extract_user(message, args) user_member = bot.getChat(user_id) rt = "" reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ELEVATED_USERS_FILE, "r") as infile: data = json.load(infile) if user_id in SUDO_USERS: message.reply_text("Este miembro ya es un Destroyer") return "" if user_id in SUPPORT_USERS: rt += "Promoví un Demonio a Destroyer." data["supports"].remove(user_id) SUPPORT_USERS.remove(user_id) if user_id in WHITELIST_USERS: rt += "Promoví un Sapo Gigante a Destroyer." data["whitelists"].remove(user_id) WHITELIST_USERS.remove(user_id) data["sudos"].append(user_id) SUDO_USERS.append(user_id) with open(ELEVATED_USERS_FILE, "w") as outfile: json.dump(data, outfile, indent=4) update.effective_message.reply_text( rt + "\nSe estableció correctamente el nivel de {} en Destroyer!".format( user_member.first_name ) ) log_message = ( f"#SuperUsuario\n" f"<b>Administrador:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Usuario:</b> {mention_html(user_member.id, user_member.first_name)}" ) if chat.type != "private": log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message return log_message
def removesudo(update: Update, context: CallbackContext) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat bot, args = context.bot, context.args user_id = extract_user(message, args) user_member = bot.getChat(user_id) reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ELEVATED_USERS_FILE, "r") as infile: data = json.load(infile) if user_id in SUDO_USERS: message.reply_text("Rebajé a este usuario a Humano") SUDO_USERS.remove(user_id) data["sudos"].remove(user_id) with open(ELEVATED_USERS_FILE, "w") as outfile: json.dump(data, outfile, indent=4) log_message = ( f"#QuitaSuperusuario\n" f"<b>Administrador:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Usuario:</b> {mention_html(user_member.id, user_member.first_name)}" ) if chat.type != "private": log_message = "<b>{}:</b>\n".format(html.escape( chat.title)) + log_message return log_message else: message.reply_text("Este usuario no es un Destroyer!") return ""