Example #1
0
def un_dban_user(dynasty_id, user_id):
    with DYNASTY_LOCK:
        r = SESSION.query(BansD).all()
        for I in r:
            if I.dynasty_id == dynasty_id:
                if int(I.user_id) == int(user_id):
                    SESSION.delete(I)
        try:
            SESSION.commit()
        except:
            SESSION.rollback()
            return False
        finally:
            SESSION.commit()
        __load_all_dynasties_banned()
        return I
Example #2
0
def dban_user(dynasty_id, user_id, first_name, last_name, user_name, reason,
              time):
    with DYNASTY_LOCK:
        r = SESSION.query(BansD).all()
        for I in r:
            if I.dynasty_id == dynasty_id:
                if int(I.user_id) == int(user_id):
                    SESSION.delete(I)

        r = BansD(str(dynasty_id), str(user_id), first_name, last_name,
                  user_name, reason, time)

        SESSION.add(r)
        try:
            SESSION.commit()
        except:
            SESSION.rollback()
            return False
        finally:
            SESSION.commit()
        __load_all_dynasties_banned()
        return r
Example #3
0
def multi_dban_user(multi_dynasty_id, multi_user_id, multi_first_name,
                    multi_last_name, multi_user_name, multi_reason):
    if True:  # with DYNASTY_LOCK:
        counter = 0
        time = 0
        for x in range(len(multi_dynasty_id)):
            dynasty_id = multi_dynasty_id[x]
            user_id = multi_user_id[x]
            first_name = multi_first_name[x]
            last_name = multi_last_name[x]
            user_name = multi_user_name[x]
            reason = multi_reason[x]
            r = SESSION.query(BansD).all()
            for I in r:
                if I.dynasty_id == dynasty_id:
                    if int(I.user_id) == int(user_id):
                        SESSION.delete(I)

            r = BansD(str(dynasty_id), str(user_id), first_name, last_name,
                      user_name, reason, time)

            SESSION.add(r)
            counter += 1
            if str(str(counter)[-2:]) == "00":
                print(user_id)
                print(first_name)
                print(reason)
                print(counter)
        try:
            SESSION.commit()
        except:
            SESSION.rollback()
            return False
        finally:
            SESSION.commit()
        __load_all_dynasties_banned()
        print("Done")
        return counter