def banall(update, context: List[int]): args = context.args 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: context.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: spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return 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) or update.effective_message.chat.type == "private": if len(args) >= 1: if args[0] in LOCK_TYPES: # Connection check conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title text = tl( update.effective_message, "Terkunci *{}* pesan untuk semua non-admin pada *{}*!" ).format(args[0], chat_name) else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl( update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM" )) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl( update.effective_message, "Terkunci *{}* pesan untuk semua non-admin!").format( args[0]) sql.update_lock(chat.id, args[0], locked=True) send_message(update.effective_message, text, parse_mode="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: # Connection check conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title text = tl( update.effective_message, "Terkunci *{}* pesan untuk semua non-admin pada *{}*!" ).format(args[0], chat_name) else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl( update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM" )) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl( update.effective_message, "Terkunci *{}* pesan untuk semua non-admin!").format( args[0]) 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) send_message(update.effective_message, text, parse_mode="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: send_message( update.effective_message, tl( update.effective_message, "Apa yang Anda coba untuk kunci...? Coba /locktypes untuk daftar kunci yang dapat dikunci" )) else: send_message( update.effective_message, tl(update.effective_message, "Apa yang Anda ingin kunci...?")) else: send_message( update.effective_message, tl(update.effective_message, "Saya bukan admin, atau tidak punya hak menghapus.")) return ""