예제 #1
0
def get_whitelist(user_id):
    user = SESSION.query(PMTable).get(user_id)
    rep = ""
    if user:
        rep = str(user.boolvalue)
    SESSION.close()
    return rep
예제 #2
0
def get_msg_id(user_id):
    try:
        user = SESSION.query(MsgID).get(user_id)
        msg_id = None
        if user:
            msg_id = user.msg_id
            return msg_id
    finally:
        SESSION.close()
예제 #3
0
def del_whitelist(user_id):
    with INSERTION_LOCK:
        user = SESSION.query(PMTable).get(user_id)
        try:
            if user:
                SESSION.delete(user)
                SESSION.commit()
        finally:
            SESSION.close()
        return False
예제 #4
0
def rm_note(user_id, note_name):
    global SELF_NOTES
    with INSERTION_LOCK:
        note = SESSION.query(Notes).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
예제 #5
0
def set_last_msg_id(user_id, msg_id):
    with INSERTION_LOCK:
        try:
            user = SESSION.query(MsgID).get(user_id)
            if not user:
                user = MsgID(user_id, msg_id)
            else:
                user.msg_id = msg_id
            SESSION.merge(user)
            SESSION.commit()
        finally:
            SESSION.close()
예제 #6
0
def set_whitelist(user_id, boolvalue):
    with INSERTION_LOCK:
        user = SESSION.query(PMTable).get(user_id)
        try:
            if not user:
                user = PMTable(user_id, boolvalue)
            else:
                user.boolvalue = str(boolvalue)
            SESSION.add(user)
            SESSION.commit()
        finally:
            SESSION.close()
    return user_id