def stop_filter(update, context): chat = update.effective_chat user = update.effective_user args = update.effective_message.text.split(None, 1) conn = connected(context.bot, update, chat, user.id) if not conn is False: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": chat_name = "Local filters" else: chat_name = chat.title if len(args) < 2: send_message(update.effective_message, "What should i stop?") return chat_filters = sql.get_chat_triggers(chat_id) if not chat_filters: send_message(update.effective_message, "No filters active here!") return for keyword in chat_filters: if keyword == args[1]: sql.remove_filter(chat_id, args[1]) send_message( update.effective_message, "Okay, I'll stop replying to that filter in *{}*.".format( chat_name), parse_mode=telegram.ParseMode.MARKDOWN, ) raise DispatcherHandlerStop send_message( update.effective_message, "That's not a filter - Click: /filters to get currently active filters.", )
def rmall_callback(update, context): query = update.callback_query chat = update.effective_chat msg = update.effective_message member = chat.get_member(query.from_user.id) if query.data == 'filters_rmall': if member.status == "creator" or query.from_user.id in DRAGONS: allfilters = sql.get_chat_triggers(chat.id) if not allfilters: msg.edit_text("No filters in this chat, nothing to stop!") return count = 0 filterlist = [] for x in allfilters: count += 1 filterlist.append(x) for i in filterlist: sql.remove_filter(chat.id, i) msg.edit_text(f"Cleaned {count} filters in {chat.title}") if member.status == "administrator": query.answer("Only owner of the chat can do this.") if member.status == "member": query.answer("You need to be admin to do this.") elif query.data == 'filters_cancel': if member.status == "creator" or query.from_user.id in DRAGONS: msg.edit_text("Clearing of all filters has been cancelled.") return if member.status == "administrator": query.answer("Only owner of the chat can do this.") if member.status == "member": query.answer("You need to be admin to do this.")