def get_req(user_id): user = SESSION.query(ReqUsers).get(str(user_id)) rep = '' if user: rep = str(user.username) SESSION.close() return rep
def get_whitelist(user_id): user = SESSION.query(WhitelistUsers).get(str(user_id)) rep = '' if user: rep = str(user.username) SESSION.close() return rep
def __load_afk(): global MY_AFK try: MY_AFK = {} qall = SESSION.query(AFK).all() for x in qall: MY_AFK[int(x.user_id)] = {'afk': x.is_afk, 'reason': x.reason} finally: SESSION.close()
def del_whitelist(user_id): with INSERTION_LOCK: user = SESSION.query(WhitelistUsers).get(str(user_id)) if user: SESSION.delete(user) SESSION.commit() else: SESSION.close() return False
def get_fav(user_id): try: return ( SESSION.query( Favourites, ).filter( Favourites.user_id == int(user_id), ).all() ) finally: SESSION.close()
def __load_mychats(): global MY_ALL_CHATS try: qall = SESSION.query(MyChats).all() MY_ALL_CHATS = { x.chat_id: { 'name': x.chat_name, 'username': x.chat_username, } for x in qall } finally: SESSION.close()
def rm_selfnote(user_id, note_name): global SELF_NOTES with INSERTION_LOCK: note = SESSION.query(SelfNotes).get((user_id, note_name)) if note: SESSION.delete(note) SESSION.commit() SELF_NOTES[user_id].pop(note_name) return True else: SESSION.close() return False
def get_all_chats(): try: return SESSION.query(MyChats).all() finally: SESSION.close()
def get_stanim_set(my_id): try: return SESSION.query(StickerAnimationSet).get(my_id) finally: SESSION.close()
def get_sticker_set(my_id): try: return SESSION.query(StickerSet).get(my_id) finally: SESSION.close()
def fav_count(): try: return SESSION.query(Favourites).count() finally: SESSION.close()
def check_fav(user_id, data): try: return SESSION.query(Favourites).get((int(user_id), str(data))) finally: SESSION.close()
def prev_locale(chat_id): try: return SESSION.query(Locales).get(str(chat_id)) finally: SESSION.close()