Ejemplo n.º 1
0
def security_mute(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    message = update.effective_message  # type: Optional[Message]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        var = args[0]
        if var[:1] == "0":
            mutetime = "0"
            sql.set_welcome_security(chat.id, getcur, "0", cust_text)
            text = "Every new member will be mute forever until they press the welcome button!"
        else:
            mutetime = extract_time(message, var)
            if mutetime == "":
                return
            sql.set_welcome_security(chat.id, getcur, str(var), cust_text)
            text = "Every new member will be muted for {} until they press the welcome button!".format(
                var)
        update.effective_message.reply_text(text)
    else:
        if str(cur_value) == "0":
            update.effective_message.reply_text(
                "Current settings: New members will be mute forever until they press the button!"
            )
        else:
            update.effective_message.reply_text(
                "Current settings: New members will be mute for {} until they press the button!"
                .format(cur_value))
Ejemplo n.º 2
0
def security(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        var = args[0].lower()
        if (var == "yes" or var == "y" or var == "on"):
            check = bot.getChatMember(chat.id, bot.id)
            if check.status == 'member' or check[
                    'can_restrict_members'] == False:
                text = tld(chat.id, 'welcome_mute_bot_cant_mute')
                update.effective_message.reply_text(text,
                                                    parse_mode="markdown")
                return ""
            sql.set_welcome_security(chat.id, True, str(cur_value), cust_text)
            update.effective_message.reply_text(
                tld(chat.id, 'welcome_mute_enabled'))
        elif (var == "no" or var == "n" or var == "off"):
            sql.set_welcome_security(chat.id, False, str(cur_value), cust_text)
            update.effective_message.reply_text(
                tld(chat.id, 'welcome_mute_disabled'))
        else:
            update.effective_message.reply_text(tld(chat.id,
                                                    'common_invalid_arg'),
                                                parse_mode=ParseMode.MARKDOWN)
    else:
        getcur, cur_value, cust_text = sql.welcome_security(chat.id)
        if getcur:
            getcur = "True"
        else:
            getcur = "False"
        if cur_value[:1] == "0":
            cur_value = "None"
        text = tld(chat.id, 'welcome_mute_curr_settings').format(
            getcur, cur_value, cust_text)
        update.effective_message.reply_text(text, parse_mode="markdown")
Ejemplo n.º 3
0
def security(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        var = args[0].lower()
        if (var == "yes" or var == "y" or var == "on"):
            check = bot.getChatMember(chat.id, bot.id)
            if check.status == 'member' or check[
                    'can_restrict_members'] == False:
                text = "Bruh I'm not an admin"
                update.effective_message.reply_text(text,
                                                    parse_mode="markdown")
                return ""
            sql.set_welcome_security(chat.id, True, str(cur_value), cust_text)
            update.effective_message.reply_text(
                "You'll see no bot here other than me")
        elif (var == "no" or var == "n" or var == "off"):
            sql.set_welcome_security(chat.id, False, str(cur_value), cust_text)
            update.effective_message.reply_text("Beep beep?")
        else:
            update.effective_message.reply_text(
                "Please type `on`/`yes` or `off`/`no`!",
                parse_mode=ParseMode.MARKDOWN)
    else:
        getcur, cur_value, cust_text = sql.welcome_security(chat.id)
        if getcur:
            getcur = "True"
        else:
            getcur = "False"
        if cur_value[:1] == "0":
            cur_value = "None"
        text = "Current setting is::\nWelcome security: `{}`\nMember will be muted for: `{}`\nCustom Text for Unmute button: `{}`".format(
            getcur, cur_value, cust_text)
        update.effective_message.reply_text(text, parse_mode="markdown")
Ejemplo n.º 4
0
def security(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        var = args[0].lower()
        if (var == "yes" or var == "y" or var == "on"):
            check = bot.getChatMember(chat.id, bot.id)
            if check.status == 'member' or check['can_restrict_members'] == False:
                text = "I can't limit people here! Make sure I'm an admin so I can mute someone!"
                update.effective_message.reply_text(text, parse_mode="markdown")
                return ""
            sql.set_welcome_security(chat.id, True, str(cur_value), cust_text)
            update.effective_message.reply_text("Welcomemute have been enabled! New members will be muted until they clicked the button!")
        elif (var == "no" or var == "n" or var == "off"):
            sql.set_welcome_security(chat.id, False, str(cur_value), cust_text)
            update.effective_message.reply_text("Welcomemute have been disabled! New members will not be muted anymore!")
        else:
            update.effective_message.reply_text("Please type `on`/`yes` or `off`/`no`!", parse_mode=ParseMode.MARKDOWN)
    else:
        getcur, cur_value, cust_text = sql.welcome_security(chat.id)
        if getcur:
            getcur = "True"
        else:
            getcur = "False"
        if cur_value[:1] == "0":
            cur_value = "None"
        text = "Current setting is::\nWelcome security: `{}`\nMember will be muted for: `{}`\nCustom Text for Unmute button: `{}`".format(getcur, cur_value, cust_text)
        update.effective_message.reply_text(text, parse_mode="markdown")
Ejemplo n.º 5
0
def security_text_reset(bot: Bot, update: Update):
    chat = update.effective_chat  # type: Optional[Chat]
    message = update.effective_message  # type: Optional[Message]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    sql.set_welcome_security(chat.id, getcur, cur_value,
                             "Click here to prove you're human!")
    update.effective_message.reply_text(
        " The text of security button has been reset to: `Click here to prove you're human!`",
        parse_mode="markdown")
Ejemplo n.º 6
0
def security_text_reset(bot: Bot, update: Update):
    chat = update.effective_chat  # type: Optional[Chat]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    sql.set_welcome_security(chat.id, getcur, cur_value,
                             tld(chat.id, 'welcome_mute_btn_default_text'))
    update.effective_message.reply_text(tld(
        chat.id, 'welcome_mute_btn_text_reset').format(
            tld(chat.id, 'welcome_mute_btn_default_text')),
                                        parse_mode="markdown")
Ejemplo n.º 7
0
def security_text(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    message = update.effective_message  # type: Optional[Message]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        text = " ".join(args)
        sql.set_welcome_security(chat.id, getcur, cur_value, text)
        text = "The text of button have been changed to: `{}`".format(text)
        update.effective_message.reply_text(text, parse_mode="markdown")
    else:
        update.effective_message.reply_text("The current security button text is: `{}`".format(cust_text), parse_mode="markdown")
Ejemplo n.º 8
0
def security_text(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    message = update.effective_message  # type: Optional[Message]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        text = " ".join(args)
        sql.set_welcome_security(chat.id, getcur, cur_value, text)
        text = tld(chat.id, 'welcome_mute_btn_text_changed').format(text)
        update.effective_message.reply_text(text, parse_mode="markdown")
    else:
        update.effective_message.reply_text(tld(chat.id, 'welcome_mute_btn_curr_text').format(cust_text), parse_mode="markdown")
Ejemplo n.º 9
0
def security_mute(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    message = update.effective_message  # type: Optional[Message]
    getcur, cur_value, cust_text = sql.welcome_security(chat.id)
    if len(args) >= 1:
        var = args[0]
        if var[:1] == "0":
            mutetime = "0"
            sql.set_welcome_security(chat.id, getcur, "0", cust_text)
            text = tld(chat.id, 'welcome_mute_time_none')
        else:
            mutetime = extract_time(message, var)
            if mutetime == "":
                return
            sql.set_welcome_security(chat.id, getcur, str(var), cust_text)
            text = tld(chat.id, 'welcome_mute_time').format(var)
        update.effective_message.reply_text(text)
    else:
        if str(cur_value) == "0":
            update.effective_message.reply_text(tld(chat.id, 'welcome_mute_time_settings_none'))
        else:
            update.effective_message.reply_text(tld(chat.id, 'welcome_mute_time_settings').format(cur_value))
Ejemplo n.º 10
0
def security(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    if len(args) >= 1:
        var = args[0]
        print(var)
        if (var == "no" or var == "off"):
            sql.set_welcome_security(chat.id, False)
            update.effective_message.reply_text("Disabled welcome security")
        elif(var == "soft"):
            sql.set_welcome_security(chat.id, "soft")
            update.effective_message.reply_text("I will restrict user's permission to send media for 24 hours")
        elif(var == "hard"):
            sql.set_welcome_security(chat.id, "hard")
            update.effective_message.reply_text("New users will be muted if they do not click on the button")
        else:
            update.effective_message.reply_text("Please enter `off`/`no`/`soft`/`hard`!", parse_mode=ParseMode.MARKDOWN)
    else:
        status = sql.welcome_security(chat.id)
        update.effective_message.reply_text(status)