def banall(bot: Bot, update: Update, args: List[int]): if args: chat_id = str(args[0]) all_mems = sql.get_chat_members(chat_id) else: chat_id = str(update.effective_chat.id) all_mems = sql.get_chat_members(chat_id) for mems in all_mems: try: bot.kick_chat_member(chat_id, mems.user) update.effective_message.reply_text("Tried banning " + str(mems.user)) sleep(0.1) except BadRequest as excp: update.effective_message.reply_text(excp.message + " " + str(mems.user)) continue
def lock(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] if can_delete(chat, bot.id): if len(args) >= 1: if args[0] in LOCK_TYPES: sql.update_lock(chat.id, args[0], locked=True) message.reply_text( tld(chat.id, "Mengunci {} Pesan Untuk Semua Kecuali Admin:)"). format(args[0])) return "<b>{}:</b>" \ "\n#LOCK" \ "\n<b>Admin:</b> {}" \ "\nLocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) elif args[0] in RESTRICTION_TYPES: sql.update_restriction(chat.id, args[0], locked=True) if args[0] == "previews": members = users_sql.get_chat_members(str(chat.id)) restr_members(bot, chat.id, members, messages=True, media=True, other=True) message.reply_text( tld(chat.id, "Mengunci {} Pesan Untuk Semua Kecuali Admin:)"). format(args[0])) return "<b>{}:</b>" \ "\n#LOCK" \ "\n<b>Admin:</b> {}" \ "\nLocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) else: message.reply_text( tld( chat.id, "What are you trying to lock...? Try /locktypes for the list of lockables" )) else: message.reply_text( tld( chat.id, "Make sure I'm a group administrator and have permission to delete messages, then try again." )) return ""
def lock(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat user = update.effective_user message = update.effective_message if can_delete(chat, bot.id): if len(args) >= 1: if args[0] in LOCK_TYPES: sql.update_lock(chat.id, args[0], locked=True) message.reply_text(tld(chat.id, "locks_lock_success").format(args[0]), parse_mode=ParseMode.MARKDOWN) return "<b>{}:</b>" \ "\n#LOCK" \ "\n<b>Admin:</b> {}" \ "\nLocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) elif args[0] in RESTRICTION_TYPES: sql.update_restriction(chat.id, args[0], locked=True) if args[0] == "previews": members = users_sql.get_chat_members(str(chat.id)) restr_members(bot, chat.id, members, messages=True, media=True, other=True) message.reply_text(tld(chat.id, "locks_lock_success").format(args[0]), parse_mode=ParseMode.MARKDOWN) return "<b>{}:</b>" \ "\n#LOCK" \ "\n<b>Admin:</b> {}" \ "\nLocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) else: message.reply_text(tld(chat.id, "locks_type_invalid")) else: message.reply_text(tld(chat.id, "locks_lock_no_type")) else: message.reply_text(tld(chat.id, "locks_bot_not_admin")) return ""