def blacklist_mode(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] msg = update.effective_message # type: Optional[Message] conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": send_message(update.effective_message, "You can do this command in groups, not PM") return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title if args: if args[0].lower() == 'off' or args[0].lower( ) == 'nothing' or args[0].lower() == 'no': settypeblacklist = 'turn off' sql.set_blacklist_strength(chat_id, 0, "0") elif args[0].lower() == 'del' or args[0].lower() == 'delete': settypeblacklist = 'left, the message will be deleted' sql.set_blacklist_strength(chat_id, 1, "0") elif args[0].lower() == 'warn': settypeblacklist = 'warned' sql.set_blacklist_strength(chat_id, 2, "0") elif args[0].lower() == 'mute': settypeblacklist = 'muted' sql.set_blacklist_strength(chat_id, 3, "0") elif args[0].lower() == 'kick': settypeblacklist = 'kicked' sql.set_blacklist_strength(chat_id, 4, "0") elif args[0].lower() == 'ban': settypeblacklist = 'banned' sql.set_blacklist_strength(chat_id, 5, "0") elif args[0].lower() == 'tban': if len(args) == 1: teks = """It looks like you are trying to set a temporary value to blacklist, but has not determined the time; use `/blstickermode tban <timevalue>`. Examples of time values: 4m = 4 minute, 3h = 3 hours, 6d = 6 days, 5w = 5 weeks.""" send_message(update.effective_message, teks, parse_mode="markdown") return settypeblacklist = 'temporary banned for {}'.format(args[1]) sql.set_blacklist_strength(chat_id, 6, str(args[1])) elif args[0].lower() == 'tmute': if len(args) == 1: teks = """It looks like you are trying to set a temporary value to blacklist, but has not determined the time; use `/blstickermode tmute <timevalue>`. Examples of time values: 4m = 4 minute, 3h = 3 hours, 6d = 6 days, 5w = 5 weeks.""" send_message(update.effective_message, teks, parse_mode="markdown") return settypeblacklist = tl(update.effective_message, 'temporary muted for {}').format(args[1]) sql.set_blacklist_strength(chat_id, 7, str(args[1])) else: send_message( update.effective_message, "I only understand off/del/warn/ban/kick/mute/tban/tmute!") return if conn: text = "Blacklist sticker mode changed, will `{}` at *{}*!".format( settypeblacklist, chat_name) else: text = "Blacklist sticker mode changed, will `{}`!".format( settypeblacklist) send_message(update.effective_message, text, parse_mode="markdown") return "<b>{}:</b>\n" \ "<b>Admin:</b> {}\n" \ "Changed sticker blacklist mode. Will {}.".format(html.escape(chat.title), mention_html(user.id, user.first_name), settypeblacklist) else: getmode, getvalue = sql.get_blacklist_setting(chat.id) if getmode == 0: settypeblacklist = "not active" elif getmode == 1: settypeblacklist = "hapus" elif getmode == 2: settypeblacklist = "warn" elif getmode == 3: settypeblacklist = "mute" elif getmode == 4: settypeblacklist = "kick" elif getmode == 5: settypeblacklist = "ban" elif getmode == 6: settypeblacklist = "temporarily banned for {}".format(getvalue) elif getmode == 7: settypeblacklist = "temporarily muted for {}".format(getvalue) if conn: text = "Blacklist sticker mode is currently set to *{}* in *{}*.".format( settypeblacklist, chat_name) else: text = "Blacklist sticker mode is currently set to *{}*.".format( settypeblacklist) send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN) return ""
def blacklist_mode(update: Update, context: CallbackContext): global settypeblacklist chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] msg = update.effective_message # type: Optional[Message] bot, args = context.bot, context.args conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": send_message( update.effective_message, "You can do this command in groups, not PM", ) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title if args: if args[0].lower() in ["off", "nothing", "no"]: settypeblacklist = "turn off" sql.set_blacklist_strength(chat_id, 0, "0") elif args[0].lower() in ["del", "delete"]: settypeblacklist = "left, the message will be deleted" sql.set_blacklist_strength(chat_id, 1, "0") elif args[0].lower() == "warn": settypeblacklist = "warned" sql.set_blacklist_strength(chat_id, 2, "0") elif args[0].lower() == "mute": settypeblacklist = "muted" sql.set_blacklist_strength(chat_id, 3, "0") elif args[0].lower() == "kick": settypeblacklist = "kicked" sql.set_blacklist_strength(chat_id, 4, "0") elif args[0].lower() == "ban": settypeblacklist = "banned" sql.set_blacklist_strength(chat_id, 5, "0") elif args[0].lower() == "tban": if len(args) == 1: teks = """It looks like you are trying to set a temporary value to blacklist, but has not determined the time; use `/blstickermode tban <timevalue>`. Examples of time values: 4m = 4 minute, 3h = 3 hours, 6d = 6 days, 5w = 5 weeks. """ send_message(update.effective_message, teks, parse_mode="markdown") return settypeblacklist = f"temporary banned for {args[1]}" sql.set_blacklist_strength(chat_id, 6, str(args[1])) elif args[0].lower() == "tmute": if len(args) == 1: teks = """It looks like you are trying to set a temporary value to blacklist, but has not determined the time; use `/blstickermode tmute <timevalue>`. Examples of time values: 4m = 4 minute, 3h = 3 hours, 6d = 6 days, 5w = 5 weeks. """ send_message(update.effective_message, teks, parse_mode="markdown") return settypeblacklist = f"temporary muted for {args[1]}" sql.set_blacklist_strength(chat_id, 7, str(args[1])) else: send_message( update.effective_message, "I only understand off/del/warn/ban/kick/mute/tban/tmute!", ) return if conn: text = "Blacklist sticker mode changed, users will be `{}` at *{}*!".format( settypeblacklist, chat_name, ) else: text = "Blacklist sticker mode changed, users will be `{}`!".format( settypeblacklist, ) send_message(update.effective_message, text, parse_mode="markdown") return ("<b>{}:</b>\n" "<b>Admin:</b> {}\n" "Changed sticker blacklist mode. users will be {}.".format( html.escape(chat.title), mention_html(user.id, user.first_name), settypeblacklist, )) else: getmode, getvalue = sql.get_blacklist_setting(chat.id) if getmode == 0: settypeblacklist = "not active" elif getmode == 1: settypeblacklist = "delete" elif getmode == 2: settypeblacklist = "warn" elif getmode == 3: settypeblacklist = "mute" elif getmode == 4: settypeblacklist = "kick" elif getmode == 5: settypeblacklist = "ban" elif getmode == 6: settypeblacklist = f"temporarily banned for {getvalue}" elif getmode == 7: settypeblacklist = f"temporarily muted for {getvalue}" if conn: text = "Blacklist sticker mode is currently set to *{}* in *{}*.".format( settypeblacklist, chat_name, ) else: text = "Blacklist sticker mode is currently set to *{}*.".format( settypeblacklist, ) send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN) return ""