def is_muted(sender, chat_id): user = SESSION.query(Mute).get((str(sender), str(chat_id))) if user: return True else: return False
def update_previous_welcome(chat_id, previous_welcome): row = SESSION.query(Welcome).get(str(chat_id)) row.previous_welcome = previous_welcome SESSION.commit()
def num_blacklist_chat_filters(chat_id): try: return (SESSION.query(BlackListFilters.chat_id).filter( BlackListFilters.chat_id == str(chat_id)).count()) finally: SESSION.close()
def approve(chat_id): adder = PMPermit(str(chat_id)) SESSION.add(adder) SESSION.commit()
def get_welcome(chat_id): try: return SESSION.query(Welcome).get(str(chat_id)) finally: SESSION.close()
def rm_note(chat_id, keyword): note = SESSION.query(Notes).filter(Notes.chat_id == str(chat_id), Notes.keyword == keyword) if note: note.delete() SESSION.commit()
def gmute(sender): adder = GMute(str(sender)) SESSION.add(adder) SESSION.commit()
def num_list_keywords(): try: return SESSION.query(func.count(distinct( PetercordGloballist.keywoard))).scalar() finally: SESSION.close()
def is_in_list(keywoard, group_id): with PETERCORDGLOBALLIST_INSERTION_LOCK: broadcast_group = SESSION.query(PetercordGloballist).get( (keywoard, str(group_id))) return bool(broadcast_group)
def update_previous_rkwelcome(chat_id, previous_rkwelcome): row = SESSION.query(rkwelcome).get(chat_id) row.previous_rkwelcome = previous_rkwelcome # commit the changes to the DB SESSION.commit()
def num_list_keyword(keywoard): try: return (SESSION.query(PetercordGloballist.keywoard).filter( PetercordGloballist.keywoard == keywoard).count()) finally: SESSION.close()
def rm_rkwelcome_setting(chat_id): rem = SESSION.query(rkwelcome).get(chat_id) if rem: SESSION.delete(rem) SESSION.commit()
def unmute(sender, chat_id): rem = SESSION.query(Mute).get((str(sender), str(chat_id))) if rem: SESSION.delete(rem) SESSION.commit()
def mute(sender, chat_id): adder = Mute(str(sender), str(chat_id)) SESSION.add(adder) SESSION.commit()
def remove_chat_gban(chat_id): rem = SESSION.query(GBan).get(str(chat_id)) if rem: SESSION.delete(rem) SESSION.commit()
def del_keyword_list(keywoard): with PETERCORDGLOBALLIST_INSERTION_LOCK: broadcast_group = (SESSION.query(PetercordGloballist.keywoard).filter( PetercordGloballist.keywoard == keywoard).delete()) GLOBALLIST_SQL_.GLOBALLIST_VALUES.pop(keywoard) SESSION.commit()
def get_notes(chat_id): try: return SESSION.query(Notes).filter(Notes.chat_id == str(chat_id)).all() finally: SESSION.close()
def get_list_keywords(): try: chats = SESSION.query(PetercordGloballist.keywoard).distinct().all() return [i[0] for i in chats] finally: SESSION.close()
def rm_all_notes(chat_id): notes = SESSION.query(Notes).filter(Notes.chat_id == str(chat_id)) if notes: notes.delete() SESSION.commit()
def num_list(): try: return SESSION.query(PetercordGloballist).count() finally: SESSION.close()
def ungmute(sender): rem = SESSION.query(GMute).get((str(sender))) if rem: SESSION.delete(rem) SESSION.commit()
def get_note(chat_id, keyword): try: return SESSION.query(Notes).get((str(chat_id), keyword)) finally: SESSION.close()
def dissprove(chat_id): rem = SESSION.query(PMPermit).get(str(chat_id)) if rem: SESSION.delete(rem) SESSION.commit()
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 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_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 else: 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 get_gban(): try: return SESSION.query(GBan) finally: SESSION.close()
def num_blacklist_filters(): try: return SESSION.query(BlackListFilters).count() finally: SESSION.close()
def add_chat_gban(chat_id): adder = GBan(str(chat_id)) SESSION.add(adder) SESSION.commit()
def num_blacklist_filter_chats(): try: return SESSION.query(func.count(distinct( BlackListFilters.chat_id))).scalar() finally: SESSION.close()
def get_filters(chat_id): try: return SESSION.query(Filters).filter( Filters.chat_id == str(chat_id)).all() finally: SESSION.close()