예제 #1
0
def rem_user(user_id):
    with INSERTION_LOCK:
        autochat = SESSION.query(Chatbot).get(int(user_id))
        if autochat:
            SESSION.delete(autochat)

        SESSION.commit()
        __load_userid_list()
예제 #2
0
def is_user(user_id):
    try:
        user = SESSION.query(Chatbot).get(int(user_id))
        if user:
            return True
        else:
            return False
    finally:
        SESSION.close()
예제 #3
0
def get_ses(user_id):
    autochat = SESSION.query(Chatbot).get(int(user_id))
    sesh = ""
    exp = ""
    if autochat:
        sesh = str(autochat.ses_id)
        exp = str(autochat.expires)

    SESSION.close()
    return sesh, exp
예제 #4
0
def set_ses(user_id, ses_id, expires):
    with INSERTION_LOCK:
        autochat = SESSION.query(Chatbot).get(int(user_id))
        if not autochat:
            autochat = Chatbot(int(user_id), str(ses_id), str(expires))
        else:
            autochat.ses_id = str(ses_id)
            autochat.expires = str(expires)

        SESSION.add(autochat)
        SESSION.commit()
        __load_userid_list()
예제 #5
0
def __load_userid_list():
    global USERS
    try:
        USERS = {int(x.user_id) for x in SESSION.query(Chatbot).all()}
    finally:
        SESSION.close()