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_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 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_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_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 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_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 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 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 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 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()