Ejemplo n.º 1
0
def save_note(user_id,
              note_name,
              note_data,
              msgtype,
              file_id=None,
              file_ref=None):
    global SELF_NOTES
    with INSERTION_LOCK:
        prev = SESSION.query(Notes).get((user_id, note_name))
        if prev:
            SESSION.delete(prev)
        note = Notes(user_id,
                     note_name,
                     note_data,
                     msgtype=int(msgtype),
                     file_id=file_id,
                     file_ref=file_ref)
        SESSION.add(note)
        SESSION.commit()

        if not SELF_NOTES.get(user_id):
            SELF_NOTES[user_id] = {}
        SELF_NOTES[user_id][note_name] = {
            'value': note_data,
            'type': msgtype,
            'file_id': file_id,
            "file_ref": file_ref
        }
Ejemplo n.º 2
0
def gmute(sender):
    global GMUTE_USERS
    with INSERTION_LOCK:
        adder = GMute(sender)
        GMUTE_USERS.append(sender)
        SESSION.add(adder)
        SESSION.commit()
    return
Ejemplo n.º 3
0
def set_afk(afk, reason):
    global MY_AFK
    afk_db = SESSION.query(AFK).get(str(OWNER_ID))
    if afk_db:
        SESSION.delete(afk_db)
    afk_db = AFK(OWNER_ID, afk, reason)
    SESSION.add(afk_db)
    SESSION.commit()
    MY_AFK[OWNER_ID] = {"afk": afk, "reason": reason}
Ejemplo n.º 4
0
def set_credential(chat_id, credential_string):
    with INSERTION_LOCK:
        saved_cred = SESSION.query(gDriveCreds).get(chat_id)
        if not saved_cred:
            saved_cred = gDriveCreds(chat_id)

        saved_cred.credential_string = pickle.dumps(credential_string)

        SESSION.add(saved_cred)
        SESSION.commit()
Ejemplo n.º 5
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