def antiubot_list(chat_id): try: return SESSION.query(AntiUbot).filter( AntiUbot.chat_id == str(chat_id)).order_by( AntiUbot.command.asc()).all() finally: SESSION.close()
def filter_list(chat_id): try: return SESSION.query(Filters).filter( Filters.chat_id == str(chat_id)).order_by( Filters.name.asc()).all() finally: SESSION.close()
def get_disabled(chat_id): try: return SESSION.query(DisableAble).filter( DisableAble.chat_id == str(chat_id)).order_by( DisableAble.command.asc()).all() finally: SESSION.close()
def add_to_gmute(user_id,reason): with CHAT_INSERTION_LOCK: prev = SESSION.query(Gmute).get(user_id) if prev: SESSION.delete(prev) SESSION.commit() gban_filt = Gmute(user_id,reason) SESSION.merge(gban_filt) SESSION.commit()
def add_to_sudo(user_id): with SUDO_INSERTION_LOCK: prev = SESSION.query(Sudo).get(user_id) if prev: SESSION.delete(prev) SESSION.commit() gban_filt = Sudo(user_id) SESSION.merge(gban_filt) SESSION.commit()
def add_to_antiubot(chat_id, command, mode, time): with ANTIUBOT_INSERTION_LOCK: prev = SESSION.query(AntiUbot).get((str(chat_id), command)) if prev: SESSION.delete(prev) SESSION.commit() antiubot_filt = AntiUbot(chat_id, command, mode, time) SESSION.merge(antiubot_filt) SESSION.commit()
def add_to_blacklist(chat_id,trigger,mode,time): with BLACKLIST_INSERTION_LOCK: prev = SESSION.query(Blacklist).get((str(chat_id), trigger)) if prev: SESSION.delete(prev) SESSION.commit() blacklist_filt = Blacklist(chat_id,trigger,mode,time) SESSION.merge(blacklist_filt) SESSION.commit()
def rm_from_gban(user_id): with CHAT_INSERTION_LOCK: curr = SESSION.query(Gmute).get(user_id) if curr: SESSION.delete(curr) SESSION.commit() return True else: SESSION.close() return False
def rm_from_antiubot(chat_id, command): with ANTIUBOT_INSERTION_LOCK: curr = SESSION.query(AntiUbot).get((str(chat_id), command)) if curr: SESSION.delete(curr) SESSION.commit() return True else: SESSION.close() return False
def rm_from_blacklist(chat_id,trigger): with BLACKLIST_INSERTION_LOCK: curr = SESSION.query(Blacklist).get((str(chat_id), trigger)) if curr: SESSION.delete(curr) SESSION.commit() return True else: SESSION.close() return False
def rm_from_sudo(user_id): with SUDO_INSERTION_LOCK: curr = SESSION.query(Sudo).get(user_id) if curr: SESSION.delete(curr) SESSION.commit() return True else: SESSION.close() return False
def rm_from_disableable(chat_id, command): with DISABLEABLE_INSERTION_LOCK: curr = SESSION.query(DisableAble).get((str(chat_id), command)) if curr: SESSION.delete(curr) SESSION.commit() return True else: SESSION.close() return False
def rm_from_filter(chat_id, name): with FILTERS_INSERTION_LOCK: curr = SESSION.query(Filters).get((str(chat_id), name)) if curr: SESSION.delete(curr) SESSION.commit() return True else: SESSION.close() return False
def add_to_filter(chat_id, name, value, document, filter_type, document_type): with FILTERS_INSERTION_LOCK: prev = SESSION.query(Filters).get((str(chat_id), name)) if prev: SESSION.delete(prev) SESSION.commit() filter_filt = Filters(chat_id, name, value, document, filter_type, document_type) SESSION.merge(filter_filt) SESSION.commit()
def check_gban(user_id): try: return SESSION.query(Gban).get(user_id) finally: SESSION.close()
def get_chatlist(): try: return SESSION.query(Chat).all() finally: SESSION.close()
def check_chatlist(chat_id): try: return SESSION.query(Chat).get(str(chat_id)) finally: SESSION.close()
def check_gmute(user_id): try: return SESSION.query(Gmute).get(user_id) finally: SESSION.close()
def sudo_list(): try: return SESSION.query(Sudo).all() finally: SESSION.close()
def check_antiubot(chat_id, command): try: return SESSION.query(AntiUbot).get((str(chat_id), command)) finally: SESSION.close()
def check_disableable(chat_id, command): try: return SESSION.query(DisableAble).get((str(chat_id), command)) finally: SESSION.close()
def blacklist_list(chat_id): try: return SESSION.query(Blacklist).filter(Blacklist.chat_id == str(chat_id)).order_by(Blacklist.trigger.asc()).all() finally: SESSION.close()