def __user_info__(user_id, chat_id): is_gbanned = sql.is_user_gbanned(user_id) is_gmuted = sql.is_user_gmuted(user_id) if not user_id in SUDO_USERS: text = tld(chat_id, "Globally banned: <b>{}</b>") if is_gbanned: text = text.format(tld(chat_id, "Yes")) user = sql.get_gbanned_user(user_id) if user.reason: text += tld(chat_id, "\nReason: {}").format(html.escape(user.reason)) else: text = text.format(tld(chat_id, "No")) text += tld(chat_id, "\nGlobally muted: <b>{}</b>") if is_gmuted: text = text.format(tld(chat_id, "Yes")) user = sql.get_gmuted_user(user_id) if user.reason: text += tld(chat_id, "\nReason: {}").format(html.escape(user.reason)) else: text = text.format(tld(chat_id, "No")) return text else: return ""
def check_and_ban(update, user_id, should_message=True): if sql.is_user_gbanned(user_id): update.effective_chat.kick_member(user_id) if should_message: update.effective_message.reply_text( "Germs are Again try Come Here But Cleaned With Dettol Liquid😎!" )
def check_update(self, update): if (isinstance(update, Update) and (update.message or update.edited_message and self.allow_edited)): message = update.message or update.edited_message if sql.is_user_gbanned(update.effective_user.id): return False if message.text and message.text.startswith('/') and len( message.text) > 1: first_word = message.text_html.split(None, 1)[0] if len(first_word) > 1 and first_word.startswith('/'): command = first_word[1:].split('@') command.append( message.bot.username ) # in case the command was sent without a username if not (command[0].lower() in self.command and command[1].lower() == message.bot.username.lower()): return False if self.filters is None: res = True elif isinstance(self.filters, list): res = any(func(message) for func in self.filters) else: res = self.filters(message) return res return False
def check_update(self, update): if isinstance(update, Update) and update.effective_message: message = update.effective_message try: user_id = update.effective_user.id except: user_id = None if user_id: if is_user_gbanned(user_id): return if user_id: if sql.is_user_blacklisted(update.effective_user.id): return False if message.text and len(message.text) > 1: fst_word = message.text.split(None, 1)[0] if len(fst_word) > 1 and any( fst_word.startswith(start) for start in ('/', '!')): args = message.text.split()[1:] command = fst_word[1:].split('@') command.append( message.bot.username ) # in case the command was sent without a username if not (command[0].lower() in self.command and command[1].lower() == message.bot.username.lower()): return None filter_result = self.filters(update) if filter_result: return args, filter_result else: return False
def gban(update, context): message = update.effective_message # type: Optional[Message] banner = update.effective_user bot = context.bot args = context.args user_id, reason = extract_user_and_text(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return if user_id == 1091139479: message.reply_text( "Beyond His Power User Have Mastered•Ultra Instinct!") return if int(user_id) in SUDO_USERS: message.reply_text( "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?" ) return if int(user_id) in SUPPORT_USERS: message.reply_text( "OOOH someone's trying to gban a support user! *grabs popcorn*") return if user_id == bot.id: message.reply_text( "-_- So funny, lets gban myself why don't I? Nice try.") return try: user_chat = bot.get_chat(user_id) except BadRequest as excp: message.reply_text(excp.message) return if user_chat.type != 'private': message.reply_text("That's not a user!") return full_reason = f"{reason} // GBanned by {banner.first_name} id {banner.id}" if sql.is_user_gbanned(user_id): if not reason: message.reply_text( "This user is already gbanned; I'd change the reason, but you haven't given me one..." ) return old_reason = sql.update_gban_reason( user_id, user_chat.username or user_chat.first_name, full_reason) or "None" try: bot.send_message( MESSAGE_DUMP, tld(chat.id, "antispam_logger_update_gban").format( mention_html(banner.id, banner.first_name), mention_html(user_chat.id, user_chat.first_name or "Deleted Account"), user_chat.id, old_reason, full_reason), parse_mode=ParseMode.HTML) except: pass message.reply_text(tld(chat.id, "antispam_reason_updated").format( html.escape(old_reason), html.escape(full_reason)), parse_mode=ParseMode.HTML) return ok123 = mention_html(user_chat.id, user_chat.first_name) text12 = f"He who searches for evil, must first look at his own reflection {ok123} 😉." update.effective_message.reply_text(text12, parse_mode=ParseMode.HTML) # send_to_list(bot, SUDO_USERS + SUPPORT_USERS, # "<b>Global Ban</b>" \ # "\n#GBAN" \ # "\n<b>Status:</b> <code>Enforcing</code>" \ # "\n<b>Sudo Admin:</b> {}" \ # "\n<b>User:</b> {}" \ # "\n<b>ID:</b> <code>{}</code>" \ # "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name), # mention_html(user_chat.id, user_chat.first_name), # user_chat.id, reason or "No reason given"), # html=True) try: bot.send_message(MESSAGE_DUMP, tld(chat.id, "antispam_logger_new_gban").format( mention_html(banner.id, banner.first_name), mention_html(user_chat.id, user_chat.first_name), user_chat.id, full_reason or tld(chat.id, "antispam_no_reason")), parse_mode=ParseMode.HTML) except: print("nut") sql.gban_user(user_id, user_chat.username or user_chat.first_name, full_reason) chats = get_all_chats() for chat in chats: chat_id = chat.chat_id # Check if this group has disabled gbans if not sql.does_chat_gban(chat_id): continue try: bot.kick_chat_member(chat_id, user_id) except BadRequest as excp: if excp.message in GBAN_ERRORS: pass else: message.reply_text("Could not gban due to: {}".format( excp.message)) send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Could not gban due to: {}".format(excp.message)) sql.ungban_user(user_id) return except TelegramError: pass send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "{} has been successfully gbanned!".format( mention_html(user_chat.id, user_chat.first_name)), html=True) text13 = f"Evil {ok123} 99.9% Destroyed Successfully ." update.effective_message.reply_text(text13, parse_mode=ParseMode.HTML)
def ungban(update, context): message = update.effective_message # type: Optional[Message] bot = context.bot args = context.args user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return user_chat = bot.get_chat(user_id) if user_chat.type != 'private': message.reply_text("That's not a user!") return if not sql.is_user_gbanned(user_id): message.reply_text("This user is not gbanned!") return banner = update.effective_user # type: Optional[User] message.reply_text("I'll give {} a second chance, globally.".format( user_chat.first_name)) send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "<b>Regression of Global Ban</b>" \ "\n#UNGBAN" \ "\n<b>Status:</b> <code>Ceased</code>" \ "\n<b>Sudo Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>ID:</b> <code>{}</code>".format(mention_html(banner.id, banner.first_name), mention_html(user_chat.id, user_chat.first_name), user_chat.id), html=True) chats = get_all_chats() for chat in chats: chat_id = chat.chat_id # Check if this group has disabled gbans if not sql.does_chat_gban(chat_id): continue try: member = bot.get_chat_member(chat_id, user_id) if member.status == 'kicked': bot.unban_chat_member(chat_id, user_id) except BadRequest as excp: if excp.message in UNGBAN_ERRORS: pass else: message.reply_text("Could not un-gban due to: {}".format( excp.message)) bot.send_message( OWNER_ID, "Could not un-gban due to: {}".format(excp.message)) return except TelegramError: pass sql.ungban_user(user_id) send_to_list(context.bot, SUDO_USERS + SUPPORT_USERS, "{} has been successfully un-gbanned!".format( mention_html(user_chat.id, user_chat.first_name)), html=True) message.reply_text("Person has been un-gbanned.")