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 get_req(user_id): user = SESSION.query(ReqUsers).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()
async def get_list_costum_theme(): try: list_theme = SESSION.query(CustomThemeSet).all() list_thm = [] for i in list_theme: list_thm.append([i.name, f"cthm-{i.id_theme}"]) return list_thm finally: SESSION.close()
def get_ses(chat_id): autochat = SESSION.query(ChatbotChats).get(str(chat_id)) sesh = "" exp = "" if autochat: sesh = str(autochat.ses_id) exp = str(autochat.expires) SESSION.close() return sesh, exp
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
async def get_name_theme_set(my_id): try: name = SESSION.query(ThemeSet).get(my_id) if name: return f"{name}" else: await set_name_theme_set(Owner, "Nana-Official", False) return "Nana-Official" finally: SESSION.close()
def __load_mychats(): global MY_ALL_CHATS try: MY_ALL_CHATS = {} qall = SESSION.query(MyChats).all() for x in qall: MY_ALL_CHATS[x.chat_id] = { "name": x.chat_name, "username": x.chat_username } 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_all_chats(): try: return SESSION.query(ChatbotChats.chat_id).all() finally: SESSION.close()
def fav_count(): try: return SESSION.query(Favourites).count() finally: SESSION.close()
def get_fav(user_id): try: return (SESSION.query(Favourites).filter( Favourites.user_id == int(user_id)).all()) 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()
def get_sticker_set(my_id): try: return SESSION.query(StickerSet).get(my_id) finally: SESSION.close()
def get_stanim_set(my_id): try: return SESSION.query(StickerAnimationSet).get(my_id) finally: SESSION.close()
def is_chat(chat_id): try: chat = SESSION.query(ChatbotChats).get(str(chat_id)) return bool(chat) finally: SESSION.close()