示例#1
0
def addsupport(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    user_id = extract_user(message, args)
    user_member = update.effective_chat.get_member(user_id)
    rt = ""
    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'r') as infile:
        data = json.load(infile)
    if user_id in SUDO_USERS:
        rt += ("Demoting status of this Dragon to Demon")
        data['sudos'].remove(user_id)
        SUDO_USERS.remove(user_id)
    if user_id in SUPPORT_USERS:
        message.reply_text("This user is already a Demon ranker.")
        return ""
    if user_id in WHITELIST_USERS:
        rt += ("Promoting Disaster level from Wolf to Demon")
        data['whitelists'].remove(user_id)
        WHITELIST_USERS.remove(user_id)
    data['supports'].append(user_id)
    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'w') as outfile:
        json.dump(data, outfile, indent=4)
    SUPPORT_USERS.append(user_id)
    update.effective_message.reply_text(
        rt + "\n{} was added as a Demon level Disaster!".format(
            user_member.user.first_name))
    return "<b>{}:</b>" \
           "\n#SUPPORT" \
           "\n<b>Admin:</b> {}" \
           "\n<b>User:</b> {}".format(html.escape(update.effective_chat.title),
                                      mention_html(user.id, user.first_name),
                                      mention_html(user_member.user.id, user_member.user.first_name))
示例#2
0
def addsudo(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    banner = update.effective_user
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("Refer a user first....")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text(
            "The specified user is my Husband lol! He already have access to everything !"
        )
        return ""

    if int(user_id) in SUDO_USERS:
        message.reply_text("He is already become my boyfriend.")
        return ""

    with open("sudo_users.txt", "a") as file:
        file.write(str(user_id) + "\n")

    SUDO_USERS.append(user_id)
    message.reply_text("He proposed me !! I'm gonna say yess!")

    return ""
示例#3
0
def rsudo(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("Refer the user first.")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text("LMFAO You wanna remove my husband!")
        return ""

    if user_id not in SUDO_USERS:
        message.reply_text("{} is not a sudo user".format(user_id))
        return ""

    users = [line.rstrip('\n') for line in open("sudo_users.txt")]

    with open("sudo_users.txt", "w") as file:
        for user in users:
            if not int(user) == user_id:
                file.write(str(user) + "\n")

    SUDO_USERS.remove(user_id)
    message.reply_text("Yep Succefully removed from SUDO List!")

    return ""
示例#4
0
def sudopromote(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    banner = update.effective_user
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text(
            "The specified user is my owner! No need add him to SUDO_USERS list!"
        )
        return ""

    if int(user_id) in SUDO_USERS:
        message.reply_text("The user is already a sudo user.")
        return ""

    with open("sudo_users.txt", "a") as file:
        file.write(str(user_id) + "\n")

    SUDO_USERS.append(user_id)
    message.reply_text("Succefully added to SUDO user list!")

    return ""
示例#5
0
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 ""

    if user_id in SUDO_USERS:
        message.reply_text("Requested Eagle Union to demote this user to Civilian")
        SUDO_USERS.remove(user_id)
        sql.remove_royal(user_id)

        log_message = (
            f"#UNSUDO\n"
            f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n"
            f"<b>User:</b> {mention_html(user_member.id, html.escape(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("This user is not a Sudo user!")
        return ""
示例#6
0
def addwhitelist(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    user_id = extract_user(message, args)
    user_member = update.effective_chat.get_member(user_id)
    rt = ""
    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'r') as infile:
        data = json.load(infile)
    if user_id in SUDO_USERS:
        rt += ("This member is a sudo user. Demoting to whitelist.")
        data['sudos'].remove(user_id)
        SUDO_USERS.remove(user_id)
    if user_id in SUPPORT_USERS:
        rt += ("This user is already a support user. Demoting to whitelist.")
        data['supports'].remove(user_id)
        SUPPORT_USERS.remove(user_id)
    if user_id in WHITELIST_USERS:
        message.reply_text("This user is already a whitelisted user.")
        return ""
    data['whitelists'].append(user_id)
    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'w') as outfile:
        json.dump(data, outfile, indent=4)
    WHITELIST_USERS.append(user_id)
    update.effective_message.reply_text(
        rt + "\nSuccessfully set privilege level {} to whitelist!".format(
            user_member.user.first_name))
    return "<b>{}:</b>" \
           "\n#WHITELIST" \
           "\n<b>Admin:</b> {}" \
           "\n<b>User:</b> {}".format(html.escape(update.effective_chat.title),
                                      mention_html(user.id, user.first_name),
                                      mention_html(user_member.user.id, user_member.user.first_name))
示例#7
0
def sudodemote(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text(
            "The specified user is my owner! I won't remove him from SUDO_USERS list!"
        )
        return ""

    if user_id not in SUDO_USERS:
        message.reply_text("{} is not a sudo user".format(user_id))
        return ""

    users = [line.rstrip('\n') for line in open("sudo_users.txt")]

    with open("sudo_users.txt", "w") as file:
        for user in users:
            if not int(user) == user_id:
                file.write(str(user) + "\n")

    SUDO_USERS.remove(user_id)
    message.reply_text("Succefully removed from SUDO user list!")

    return ""
示例#8
0
文件: Sudo.py 项目: aljinpaul/DAKZZ
def adsudo(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    banner = update.effective_user
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("Refer a user first....")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text(
            "The specified user is my owner! No need add him to SUDO_USERS list!"
        )
        return ""

    if int(user_id) in SUDO_USERS:
        message.reply_text("Buddy this user is already a sudo user.")
        return ""

    with open("sudo_users.txt", "a") as file:
        file.write(str(user_id) + "\n")

    SUDO_USERS.append(user_id)
    message.reply_text("Succefully Added To SUDO List!")

    return ""
示例#9
0
def add_to_sudo(user_id, bot):
    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return
    sql.gpromote_user(user_id, user_chat.username or user_chat.first_name)
    SUDO_USERS.append(user_id)
示例#10
0
def addsardegna(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 += "This member is a Sudo user, Demoting to Sardegna."
        data["sudos"].remove(user_id)
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        rt += "This user is already a Support user, Demoting to Sardegna."
        data["supports"].remove(user_id)
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += "This user is already a Whitelist user, Demoting to Sardegna."
        data["whitelists"].remove(user_id)
        WHITELIST_USERS.remove(user_id)

    if user_id in SARDEGNA_USERS:
        message.reply_text("This user is already a Sardegna.")
        return ""

    data["sardegnas"].append(user_id)
    SARDEGNA_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"\nSuccessfully promoted {user_member.first_name} to a Sardegna Nation!"
    )

    log_message = (
        f"#SARDEGNA\n"
        f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))} \n"
        f"<b>User:</b> {mention_html(user_member.id, html.escape(user_member.first_name))}"
    )

    if chat.type != "private":
        log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message

    return log_message
示例#11
0
def addtiger(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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 += "This member is a Dragon Disaster, Demoting to Tiger."
        data['sudos'].remove(user_id)
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        rt += "This user is already a Demon Disaster, Demoting to Tiger."
        data['supports'].remove(user_id)
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += "This user is already a Wolf Disaster, Demoting to Tiger."
        data['whitelists'].remove(user_id)
        WHITELIST_USERS.remove(user_id)

    if user_id in TIGER_USERS:
        message.reply_text("This user is already a Tiger.")
        return ""

    data['tigers'].append(user_id)
    TIGER_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"\nSuccessfully promoted {user_member.first_name} to a Tiger Disaster!"
    )

    log_message = (
        f"#TIGER\n"
        f"<b>Admin:</b> {mention_html(user.id, user.first_name)} \n"
        f"<b>User:</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
示例#12
0
def addsudo(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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("This member is already a Royal Nation")
        return ""

    if user_id in SUPPORT_USERS:
        rt += "Requested HA to promote a Sakura Nation to Royal."
        data["supports"].remove(user_id)
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += "Requested HA to promote a Neptunia Nation to Royal."
        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
        + "\nSuccessfully set Nation level of {} to Royal!".format(
            user_member.first_name
        )
    )

    log_message = (
        f"#SUDO\n"
        f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
        f"<b>User:</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
示例#13
0
def addsupport(
    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 += "Requested Eagle Union to demote this Sudo to Support"
        data["sudos"].remove(user_id)
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        message.reply_text("This user is already a Support user.")
        return ""

    if user_id in WHITELIST_USERS:
        rt += "Requested Eagle Union to promote this Whitelist user to Support"
        data["whitelists"].remove(user_id)
        WHITELIST_USERS.remove(user_id)

    data["supports"].append(user_id)
    SUPPORT_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} was added as a Support user!"
    )

    log_message = (
        f"#SUPPORT\n"
        f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n"
        f"<b>User:</b> {mention_html(user_member.id, html.escape(user_member.first_name))}"
    )

    if chat.type != "private":
        log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message

    return log_message
示例#14
0
def addsudo(bot: Bot, update: Update, args: List[str]) -> str:

    message = update.effective_message
    user = update.effective_user
    user_id = extract_user(message, args)
    user_member = update.effective_chat.get_member(user_id)
    rt, log_message = "", ""

    if not user_id:
        message.reply_text("I can't add a chat to sudo list!")
        return log_message

    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'r') as infile:
        data = json.load(infile)

    if user_id in SUDO_USERS:
        message.reply_text("This member is already a Dragon Disaster")
        return log_message

    if user_id in SUPPORT_USERS:
        rt += (
            "This user is already a Demon Disaster, Promoting to Dragon Disaster."
        )
        data['supports'].remove(user_id)
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += ("This user is already a Wolf, Promoting to Dragon Disaster.")
        data['whitelists'].remove(user_id)
        WHITELIST_USERS.remove(user_id)

    data['sudos'].append(user_id)
    SUDO_USERS.append(user_id)

    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'w') as outfile:
        json.dump(data, outfile, indent=4)

    update.effective_message.reply_text(
        rt + "\nSuccessfully set Disaster level of {} to Dragon!".format(
            user_member.user.first_name))
    log_message += "<b>{}:</b> "\
                   "\n#SUDO "\
                   "\n<b>Admin:</b> {} "\
                   "\n<b>User:</b> {}".format(html.escape(update.effective_chat.title),
                                                mention_html(user.id, user.first_name),
                                                mention_html(user_member.user.id, user_member.user.first_name))

    return log_message
示例#15
0
def addsudo(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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("This member is already my SUDO.")
        return ""

    if user_id in SUPPORT_USERS:
        rt += "This user is already a SUPPORT USER."
        data['supports'].remove(user_id)
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += "This user is already a WHITELIST USER."
        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 + "\nSuccessfully added this user {} to sudo!".format(
            user_member.first_name))

    log_message = (
        f"#SUDO\n"
        f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
        f"<b>User:</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
示例#16
0
def addsupport(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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 += "Demoting status of this SUDO to SUPPORT"
        data['sudos'].remove(user_id)
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        message.reply_text("This user is already a SUDO.")
        return ""

    if user_id in WHITELIST_USERS:
        rt += "Promoting Disaster level from WHITELIST USER to SUPPORT USER"
        data['whitelists'].remove(user_id)
        WHITELIST_USERS.remove(user_id)

    data['supports'].append(user_id)
    SUPPORT_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} was added as a Demon Disaster!")

    log_message = (
        f"#SUPPORT\n"
        f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
        f"<b>User:</b> {mention_html(user_member.id, user_member.first_name)}")

    if chat.type != 'private':
        log_message = "<b>{html.escape(chat.title)}:</b>\n" + log_message

    return log_message
示例#17
0
def addwhitelist(bot: Bot, update: Update, args: List[str]) -> str:

    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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('{}/tg_bot/elevated_users.json'.format(os.getcwd()), 'r') as infile:
        data = json.load(infile)

    if user_id in SUDO_USERS:
        rt += ("This member is a Dragon Disaster, Demoting to Wolf.")
        data['sudos'].remove(user_id)
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        rt += ("This user is already a Demon Disaster, Demoting to Wolf.")
        data['supports'].remove(user_id)
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        message.reply_text("This user is already a Wolf Disaster.")
        return ""

    data['whitelists'].append(user_id)
    WHITELIST_USERS.append(user_id)

    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()), 'w') as outfile:
        json.dump(data, outfile, indent=4)

    update.effective_message.reply_text(rt + "\nSuccessfully promoted {} to a Wolf Disaster!".format(user_member.first_name))

    log_message = "#WHITELIST"\
                  "\n<b>Admin:</b> {} "\
                  "\n<b>User:</b> {}".format(mention_html(user.id, user.first_name),
                                             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
示例#18
0
def addsardegna(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 ""

    if user_id in SUDO_USERS:
        rt += "This member is a Sudo user, Demoting to Sardegna."
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        rt += "This user is already a Support user, Demoting to Sardegna."
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += "This user is already a Whitelist user, Demoting to Sardegna."
        WHITELIST_USERS.remove(user_id)

    if user_id in SARDEGNA_USERS:
        message.reply_text("This user is already a Sardegna.")
        return ""

    sql.set_royal_role(user_id, "sardegnas")
    SARDEGNA_USERS.append(user_id)

    update.effective_message.reply_text(
        rt +
        f"\nSuccessfully promoted {user_member.first_name} to a Sardegna Nation!"
    )

    log_message = (
        f"#SARDEGNA\n"
        f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))} \n"
        f"<b>User:</b> {mention_html(user_member.id, html.escape(user_member.first_name))}"
    )

    if chat.type != "private":
        log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message

    return log_message
示例#19
0
def revokesudo(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    user_id = extract_user(message, args)
    user_chat = bot.get_chat(user_id)
    if not user_id:
        message.reply_text("No user refered")
        return
    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return
    if user_id not in SUDO_USERS:
        message.reply_text("{} is not a sudo user".format(user_chat.username))
        return
    sql.ungpromote_user(user_id)
    SUDO_USERS.remove(user_id)
    message.reply_text("User no longer have SUDO user rights!")
示例#20
0
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 ""

    if user_id in SUDO_USERS:
        message.reply_text("This member is already a Sudo user")
        return ""

    if user_id in SUPPORT_USERS:
        rt += "Requested Eagle Union to promote a Support user to Sudo."
        SUPPORT_USERS.remove(user_id)

    if user_id in WHITELIST_USERS:
        rt += "Requested Eagle Union to promote a Whitelist user to Sudo."
        WHITELIST_USERS.remove(user_id)

    # will add or update their role
    sql.set_royal_role(user_id, "sudos")
    SUDO_USERS.append(user_id)

    update.effective_message.reply_text(
        rt
        + "\nSuccessfully promoted {} to Sudo!".format(
            user_member.first_name
        )
    )

    log_message = (
        f"#SUDO\n"
        f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n"
        f"<b>User:</b> {mention_html(user_member.id, html.escape(user_member.first_name))}"
    )

    if chat.type != "private":
        log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message

    return log_message
示例#21
0
def addsupport(
    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 ""

    if user_id in SUDO_USERS:
        rt += "Requested Eagle Union to demote this Sudo to Support"
        SUDO_USERS.remove(user_id)

    if user_id in SUPPORT_USERS:
        message.reply_text("This user is already a Support user.")
        return ""

    if user_id in WHITELIST_USERS:
        rt += "Requested Eagle Union to promote this Whitelist user to Support"
        WHITELIST_USERS.remove(user_id)

    sql.set_royal_role(user_id, "supports")
    SUPPORT_USERS.append(user_id)

    update.effective_message.reply_text(
        rt + f"\n{user_member.first_name} was added as a Support user!"
    )

    log_message = (
        f"#SUPPORT\n"
        f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n"
        f"<b>User:</b> {mention_html(user_member.id, html.escape(user_member.first_name))}"
    )

    if chat.type != "private":
        log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message

    return log_message
示例#22
0
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(
            "Requested Eagle Union to demote this user to Civilian")
        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"#UNSUDO\n"
            f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n"
            f"<b>User:</b> {mention_html(user_member.id, html.escape(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("This user is not a Sudo user!")
        return ""
示例#23
0
def removesudo(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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("Demoting to normal user")
        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"#UNSUDO\n"
            f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>User:</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("This user is not a sudo!")
        return ""
示例#24
0
def removesudo(bot: Bot, update: Update, args: List[str]) -> str:

    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat

    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('{}/tg_bot/elevated_users.json'.format(os.getcwd()), 'r') as infile:
        data = json.load(infile)

    if user_id in SUDO_USERS:
        message.reply_text("Demoting to normal user")
        SUDO_USERS.remove(user_id)
        data['sudos'].remove(user_id)

        with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()), 'w') as outfile:
            json.dump(data, outfile, indent=4)

        log_message = "#UNSUDO"\
                      "\n<b>Admin:</b> {} "\
                      "\n<b>User:</b> {}".format(mention_html(user.id, user.first_name),
                                                 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("This user is not a Dragon Disaster!")
        return ""
示例#25
0
def removesudo(bot: Bot, update: Update, args: List[str]) -> str:

    message = update.effective_message
    user = update.effective_user
    user_id = extract_user(message, args)
    user_member = update.effective_chat.get_member(user_id)
    log_message = ""

    if not user_id:
        message.reply_text("I can't remove a chat from sudo list!")
        return log_message

    with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
              'r') as infile:
        data = json.load(infile)

    if user_id in SUDO_USERS:
        message.reply_text("Demoting to normal user")
        SUDO_USERS.remove(user_id)
        data['sudos'].remove(user_id)

        with open('{}/tg_bot/elevated_users.json'.format(os.getcwd()),
                  'w') as outfile:
            json.dump(data, outfile, indent=4)

        log_message += "<b>{}:</b>" \
                       "\n#UNSUDO" \
                       "\n<b>Admin:</b> {}" \
                       "\n<b>User:</b> {}".format(html.escape(update.effective_chat.title),
                                                        mention_html(user.id, user.first_name),
                                                        mention_html(user_member.user.id, user_member.user.first_name))

        return log_message
    else:
        message.reply_text("This user is not a Dragon Disaster!")
        return log_message
示例#26
0
import html
from typing import Optional, List
from telegram import Message, Chat, Update, Bot, User
from telegram import ParseMode
from telegram.error import BadRequest
from telegram.ext import CommandHandler, Filters
from telegram.ext.dispatcher import run_async
from telegram.utils.helpers import escape_markdown, mention_html
from tg_bot.modules.helper_funcs.filters import CustomFilters
from tg_bot.modules.helper_funcs.extraction import extract_user
from tg_bot import dispatcher, SUDO_USERS, OWNER_USERNAME, OWNER_ID
import tg_bot.modules.sql.gpromote_sql as sql

sudo_list = sql.get_sudo_list()
for i in sudo_list:
   SUDO_USERS.append(i)

def add_to_sudo(user_id, bot):
    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return
    sql.gpromote_user(user_id, user_chat.username or user_chat.first_name)
    SUDO_USERS.append(user_id)


@run_async
def promotetosudo(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    banner = update.effective_user
示例#27
0
    if int(user_id) == OWNER_ID:
        message.reply_text("Göstərilən istifadəçi mənim sahibimdir!Onu SUDO_USERS siyahısından çıxarmayacağam!")
        qayıt ""
    
    if user_id not in SUDO_USERS:
        message.reply_text("{}sudo istifadəçisi deyil".format(user_id))
        qayıt ""

    users = [line.rstrip('\n')açıq xətt üçün("sudo_users.txt")]

    with open("sudo_users.txt","w")fayl kimi:
     istifadəçilərdəki istifadəçi üçün:
           if not int(istifadəçi) ==istifadəçi_adı:
                file.write(str(istifadəçi) + "\n")

    SUDO_USERS.remove(istifadəçi_adı)
    message.reply_text("Yep Uğurla SUDO Siyahısından çıxarıldı!")
    
    qayıt ""


__help__ = """
*Bot owner only:*
 - /addsudo: istifadəçini SUDO USER səviyyəsinə yüksəldir
 - /rsudo: istifadəçini SUDO USER-dən aşağı salır
"""

__mod_name__ = "Sudo"

addsudo_HANDLER = CommandHandler("addsudo", addsudo, pass_args=Doğru, filtrlər=Filters.user(OWNER_ID))
rsudo_HANDLER = CommandHandler("rsudo", rsudo, pass_args=Doğru, filtrlər=Filters.user(OWNER_ID))