示例#1
0
def get_req(user_id):
    user = SESSION.query(ReqUsers).get(str(user_id))
    rep = ''
    if user:
        rep = str(user.username)

    SESSION.close()
    return rep
示例#2
0
def get_whitelist(user_id):
    user = SESSION.query(WhitelistUsers).get(str(user_id))
    rep = ''
    if user:
        rep = str(user.username)

    SESSION.close()
    return rep
示例#3
0
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()
示例#4
0
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
示例#5
0
def get_fav(user_id):
    try:
        return (
            SESSION.query(
                Favourites,
            ).filter(
                Favourites.user_id == int(user_id),
            ).all()
        )
    finally:
        SESSION.close()
示例#6
0
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()
示例#7
0
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
示例#8
0
def get_all_chats():
    try:
        return SESSION.query(MyChats).all()
    finally:
        SESSION.close()
示例#9
0
def get_stanim_set(my_id):
    try:
        return SESSION.query(StickerAnimationSet).get(my_id)
    finally:
        SESSION.close()
示例#10
0
def get_sticker_set(my_id):
    try:
        return SESSION.query(StickerSet).get(my_id)
    finally:
        SESSION.close()
示例#11
0
def fav_count():
    try:
        return SESSION.query(Favourites).count()
    finally:
        SESSION.close()
示例#12
0
def check_fav(user_id, data):
    try:
        return SESSION.query(Favourites).get((int(user_id), str(data)))
    finally:
        SESSION.close()
示例#13
0
def prev_locale(chat_id):
    try:
        return SESSION.query(Locales).get(str(chat_id))
    finally:
        SESSION.close()