def del_collection(keywoard): to_check = get_collection(keywoard) if not to_check: return False keyword_items = SESSION.query(Cat_GlobalCollection_Json).get(keywoard) SESSION.delete(keyword_items) SESSION.commit() return True
def remove_echo(chat_id, user_id): to_check = is_echo(chat_id, user_id) if not to_check: return False rem = SESSION.query(Echos).get((str(chat_id), str(user_id))) SESSION.delete(rem) SESSION.commit() return True
def remove_filter(chat_id, keyword): to_check = get_filter(chat_id, keyword) if not to_check: return False rem = SESSION.query(Filter).get((str(chat_id), keyword)) SESSION.delete(rem) SESSION.commit() return True
def remove_s( user_id, chat_id ): note = SESSION.query(LydiaAI).get((user_id, chat_id)) if note: SESSION.delete(note) SESSION.commit()
def del_starter_from_db(user_id): to_check = get_starter_details(user_id) if not to_check: return False rem = SESSION.query(Bot_Starters).get(str(user_id)) SESSION.delete(rem) SESSION.commit() return True
def rm_note(keyword): to_check = get_note(keyword) if not to_check: return False rem = SESSION.query(Note).get(keyword) SESSION.delete(rem) SESSION.commit() return True
def rm_note(chat_id, keyword): to_check = get_note(chat_id, keyword) if not to_check: return False rem = SESSION.query(Notes).get((str(chat_id), keyword)) SESSION.delete(rem) SESSION.commit() return True
def add_collection(keywoard, json, njson={}): to_check = get_collection(keywoard) if to_check: keyword_items = SESSION.query(Cat_GlobalCollection_Json).get(keywoard) SESSION.delete(keyword_items) keyword_items = Cat_GlobalCollection_Json(keywoard, json, njson) SESSION.add(keyword_items) SESSION.commit() return True
def init_locks(chat_id, reset=False): curr_restr = SESSION.query(Locks).get(str(chat_id)) if reset: SESSION.delete(curr_restr) SESSION.flush() restr = Locks(str(chat_id)) SESSION.add(restr) SESSION.commit() return restr
def rm_welcome_setting(chat_id): try: rem = SESSION.query(Welcome).get(str(chat_id)) if rem: SESSION.delete(rem) SESSION.commit() return True except BaseException: return False
def ungmute(sender): rem = SESSION.query(GMute).get((str(sender))) if rem: SESSION.delete(rem) SESSION.commit()
def rem_user_from_bl(chat_id: int): """remove the user from the blacklist""" s__ = SESSION.query(Bot_BlackList).get(str(chat_id)) if s__: SESSION.delete(s__) SESSION.commit() return True SESSION.close() return False
def dissprove(chat_id): rem = SESSION.query(PMPermit).get(str(chat_id)) if rem: SESSION.delete(rem) SESSION.commit()
def rm_from_blacklist(chat_id, trigger): with BLACKLIST_FILTER_INSERTION_LOCK: blacklist_filt = SESSION.query(BlackListFilters).get((str(chat_id), trigger)) if blacklist_filt: if trigger in CHAT_BLACKLISTS.get(str(chat_id), set()): # sanity check CHAT_BLACKLISTS.get(str(chat_id), set()).remove(trigger) SESSION.delete(blacklist_filt) SESSION.commit() return True SESSION.close() return False
def add_welcome_setting(chat_id, previous_welcome, reply, f_mesg_id): to_check = get_welcome(chat_id) if not to_check: adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True rem = SESSION.query(Welcome).get(str(chat_id)) SESSION.delete(rem) SESSION.commit() adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id) SESSION.commit() return False
def add_filter(chat_id, keyword, reply, f_mesg_id): to_check = get_filter(chat_id, keyword) if not to_check: adder = Filter(str(chat_id), keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True rem = SESSION.query(Filter).get((str(chat_id), keyword)) SESSION.delete(rem) SESSION.commit() adder = Filter(str(chat_id), keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return False
def add_goodbye_setting(chat_id, previous_goodbye, reply, f_mesg_id): to_check = get_goodbye(chat_id) if not to_check: adder = Goodbye(chat_id, previous_goodbye, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True else: rem = SESSION.query(Goodbye).get(str(chat_id)) SESSION.delete(rem) SESSION.commit() adder = Goodbye(chat_id, previous_goodbye, reply, f_mesg_id) SESSION.commit() return False
def add_note(keyword, reply, f_mesg_id): to_check = get_note(keyword) if not to_check: adder = Note(keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True rem = SESSION.query(Note).get(keyword) SESSION.delete(rem) SESSION.commit() adder = Note(keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return False
def add_snip(keyword, reply, f_mesg_id): to_check = get_snip(keyword) if not to_check: adder = Snips(keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True rem = SESSION.query(Snips).filter(Snips.snip == keyword) SESSION.delete(rem) SESSION.commit() adder = Snips(keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return False
def del_user_from_db(message_id): try: _result = (SESSION.query(Bot_Users).filter( Bot_Users.message_id == str(message_id)).all()) if _result: for rst in _result: rem = SESSION.query(Bot_Users).get( (str(rst.message_id), rst.result_id)) SESSION.delete(rem) SESSION.commit() return True return False finally: SESSION.close()
def add_snip(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference): to_check = get_snip(keyword) if not to_check: adder = Snips(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference) SESSION.add(adder) SESSION.commit() return True else: rem = SESSION.query(Snips).filter(Snips.snip == keyword) SESSION.delete(rem) SESSION.commit() adder = Snips(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference) SESSION.add(adder) SESSION.commit() return False
def rm_from_list(keywoard, group_id): with PETERCORDGLOBALLIST_INSERTION_LOCK: broadcast_group = SESSION.query(PetercordGloballist).get( (keywoard, str(group_id))) if broadcast_group: if str(group_id) in GLOBALLIST_SQL_.GLOBALLIST_VALUES.get( keywoard, set()): GLOBALLIST_SQL_.GLOBALLIST_VALUES.get(keywoard, set()).remove( str(group_id)) SESSION.delete(broadcast_group) SESSION.commit() return True SESSION.close() return False
def rm_from_collectionlist(keywoard, contents): with PETERCORD_GLOBALCOLLECTION: keyword_items = SESSION.query(Petercord_GlobalCollection).get( (keywoard, tuple(contents))) if keyword_items: if tuple(contents) in COLLECTION_SQL_.CONTENTS_LIST.get( keywoard, set()): COLLECTION_SQL_.CONTENTS_LIST.get(keywoard, set()).remove( tuple(contents)) SESSION.delete(keyword_items) SESSION.commit() return True SESSION.close() return False
def add_note(chat_id, keyword, reply, f_mesg_id): to_check = get_note(chat_id, keyword) if not to_check: adder = Notes(str(chat_id), keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True else: rem = SESSION.query(Notes).get((str(chat_id), keyword)) SESSION.delete(rem) SESSION.commit() adder = Notes(str(chat_id), keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return False
def add_user_to_bl(chat_id: int, first_name: str, username: str, reason: str, date: str): """add the user to the blacklist""" to_check = check_is_black_list(chat_id) if not to_check: __user = Bot_BlackList(str(chat_id), first_name, username, reason, date) SESSION.add(__user) SESSION.commit() rem = SESSION.query(Bot_BlackList).get(str(chat_id)) SESSION.delete(rem) SESSION.commit() user = Bot_BlackList(str(chat_id), first_name, username, reason, date) SESSION.add(user) SESSION.commit() return True
def rm_from_broadcastlist(keywoard, group_id): with CATBROADCAST_INSERTION_LOCK: broadcast_group = SESSION.query(CatBroadcast).get( (keywoard, str(group_id))) if broadcast_group: if str(group_id) in BROADCAST_SQL_.BROADCAST_CHANNELS.get( keywoard, set()): BROADCAST_SQL_.BROADCAST_CHANNELS.get(keywoard, set()).remove( str(group_id)) SESSION.delete(broadcast_group) SESSION.commit() return True SESSION.close() return False
def addecho(chat_id, user_id, chat_name, user_name, user_username, chat_type): to_check = is_echo(chat_id, user_id) if not to_check: adder = Echos(str(chat_id), str(user_id), chat_name, user_name, user_username, chat_type) SESSION.add(adder) SESSION.commit() return True rem = SESSION.query(Echos).get((str(chat_id), str(user_id))) SESSION.delete(rem) SESSION.commit() adder = Echos(str(chat_id), str(user_id), chat_name, user_name, user_username, chat_type) SESSION.add(adder) SESSION.commit() return False
def add_filter(chat_id, keyword, reply, snip_type, media_id, media_access_hash, media_file_reference): to_check = get_filter(chat_id, keyword) if not to_check: adder = Filters(str(chat_id), keyword, reply, snip_type, media_id, media_access_hash, media_file_reference) SESSION.add(adder) SESSION.commit() return True else: rem = SESSION.query(Filters).get((str(chat_id), keyword)) SESSION.delete(rem) SESSION.commit() adder = Filters(str(chat_id), keyword, reply, snip_type, media_id, media_access_hash, media_file_reference) SESSION.add(adder) SESSION.commit() return False
def add_starter_to_db( user_id, first_name, date, username, ): to_check = get_starter_details(user_id) if not to_check: user = Bot_Starters(str(user_id), first_name, date, username) SESSION.add(user) SESSION.commit() return True rem = SESSION.query(Bot_Starters).get(str(user_id)) SESSION.delete(rem) SESSION.commit() user = Bot_Starters(str(user_id), first_name, date, username) SESSION.add(user) SESSION.commit() return True
def clear_credentials(user): saved_credentials = SESSION.query(GoogleDriveCreds).get(user) if saved_credentials: SESSION.delete(saved_credentials) SESSION.commit() return True