Beispiel #1
0
 def set_vip(user_id: int):
     con, cur = Db.connect()
     try:
         cur.execute("UPDATE public.user SET vip = TRUE WHERE  user_id = {}::text".format(str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #2
0
 def unset_mute(user_id: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "DELETE FROM public.muted WHERE user_id = {}::text and guild_id = {}::text;".format(str(user_id), str(guild_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #3
0
 def unset_level(level: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "DELETE FROM public.roles WHERE level = {} and guild_id = {}::text;".format(level, str(guild_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #4
0
 def update_name(user_id: int, name: str):
     con, cur = Db.connect()
     try:
         cur.execute("UPDATE public.user SET user_name = %s WHERE user_id = %s::text", (
             name,
             str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #5
0
 def set_mute(user_id: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "INSERT INTO public.muted ( guild_id, user_id) VALUES ( {}::text, {}::text );".format(str(guild_id), str(user_id))
         )
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #6
0
 def delete_ignored_chan(guild_id: int, chan_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "DELETE FROM public.rankings_chan WHERE	guild_id = {}::text AND chan_id = {}::text;"
             .format(str(guild_id), str(chan_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #7
0
 def set_ignored_chan(guild_id: int, chan_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "INSERT INTO public.rankings_chan ( guild_id, chan_id) VALUES ({}::text , {}::text );"
             .format(str(guild_id), str(chan_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #8
0
 def delete_from_user(user_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "DELETE FROM public.sanctions WHERE user_id = {}::text;".
             format(str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #9
0
 def get_vips():
     con, cur = Db.connect()
     try:
         cur.execute("SELECT * FROM public.user WHERE vip = TRUE")
     except Exception as err:
         print(err)
         con.rollback()
     rows = cur.fetchall()
     if rows:
         return UserDB.users_from_row(rows)
     return "Error : No VIP"
Beispiel #10
0
 def unset_lover(user_id: int, lover_id: int):
     con, cur = Db.connect()
     try:
         cur.execute("UPDATE public.user SET married = FALSE , lover = %s WHERE  user_id = %s::text", (None,
                                                                                                       str(user_id)))
         cur.execute(
             "UPDATE public.user SET married = FALSE, lover= %s WHERE  user_id = %s::text", (None, str(lover_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #11
0
    def create_user_one(user_id: int, cat_id: int, chan_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "INSERT INTO public.private_users ( cat_id, user_id, chan_id)  VALUES ( {}::text, {}::text, {}::text);"
                .format(str(cat_id), str(user_id), str(chan_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #12
0
    def delete_one(guild_id: int, cat_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "DELETE FROM public.private WHERE guild_id = {}::text and cat_id = {}::text;"
                .format(str(guild_id), str(cat_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #13
0
 def create_ranking(user_id: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "INSERT INTO public.rankings ( guild_id, level, reach, total, user_id, xp) "
             " VALUES ( {}::text, 0, 20, 0, {}::text, 0 );".format(
                 str(guild_id), str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #14
0
    def delete_channel(chan_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "DELETE FROM public.chan_network WHERE chan_id = {}::text;".
                format(str(chan_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #15
0
    def unblock_user(user_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "DELETE FROM public.user_network WHERE user_id = {}::text;".
                format(str(user_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #16
0
 def reset_user(user_id: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "UPDATE public.rankings SET level = 0, reach = 20, total = 0, xp = 0 "
             "WHERE guild_id = {}::text AND user_id = {}::text;".format(
                 str(guild_id), str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #17
0
 def create(user: User):
     con, cur = Db.connect()
     try:
         cur.execute(
             "INSERT INTO public.user ( crew, description, user_id, vip, user_name) "
             "VALUES ( %s, %s, %s::text, %s, %s::text);",
             (user.crew, user.description, str(user.user_id), str(user.vip), user.user_name))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #18
0
    def set_author(user_id: int, guild_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "INSERT INTO public.anon_users ( user_id, guild_id) VALUES ( %s::text, %s::text );",
                (str(user_id), str(guild_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #19
0
    def block_user(user_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "INSERT INTO public.user_network ( user_id) VALUES ( {}::text );"
                .format(str(user_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #20
0
    def unblock_anon(user_id: int, guild_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "UPDATE public.anon_users SET blocked = false WHERE user_id = {}::text AND guild_id = {}::text;"
                .format(str(user_id), str(guild_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #21
0
    def unset_channel(guild_id: int):
        con, cur = Db.connect()

        try:
            cur.execute(
                "DELETE FROM public.anon WHERE guild_id = {}::text;".format(
                    str(guild_id)))
        except Exception as err:
            print(err)
            con.rollback()
        con.commit()
Beispiel #22
0
 def get_one_from_level(level: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "SELECT * FROM public.roles WHERE level = {} and guild_id = {}::text;".format(level, str(guild_id)))
     except Exception as err:
         print(err)
         con.rollback()
     rows = cur.fetchone()
     if rows:
         return rows
Beispiel #23
0
 def get_sanction(sanction_id: int) -> Sanction:
     con, cur = Db.connect()
     try:
         cur.execute(
             "SELECT * FROM public.sanctions WHERE sanction_id = {}::text;".
             format(str(sanction_id)))
     except Exception as err:
         print(err)
         con.rollback()
     rows = cur.fetchone()
     if rows:
         return SanctionsDB.sanction_from_row(rows)
Beispiel #24
0
 def update_user_id(user_id: id, guild_id: id, level: int, reach: int,
                    xp: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "UPDATE public.rankings SET level = {}, reach = {}, xp = {} "
             "WHERE guild_id = {}::text AND user_id = {}::text;".format(
                 level, reach, xp, str(guild_id), str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #25
0
 def set_level(role_id: int, guild_id: int, level: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "INSERT INTO public.roles ( guild_id, role_id, level) VALUES ( {}::text, {}::text, {} );".format(
                 str(guild_id),
                 str(role_id), level)
         )
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #26
0
 def update_user(user_id: int, guild_id: int, ranking: dict):
     con, cur = Db.connect()
     try:
         cur.execute(
             "UPDATE public.rankings SET level = {}, reach = {}, total = {}, xp = {} "
             "WHERE guild_id = {}::text AND user_id = {}::text;".format(
                 ranking['level'], ranking['reach'], ranking['total'],
                 ranking['xp'], str(guild_id), str(user_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()
Beispiel #27
0
 def is_muted(user_id: int, guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "SELECT * FROM public.muted WHERE user_id = {}::text and guild_id = {}::text;".format(str(user_id), str(guild_id)))
     except Exception as err:
         print(err)
         con.rollback()
     rows = cur.fetchone()
     if rows:
         return True
     return False
Beispiel #28
0
 def get_channel(guild_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "SELECT * FROM public.anon WHERE guild_id = {}::text;".format(
                 str(guild_id)))
     except Exception as err:
         print(err)
         con.rollback()
     rows = cur.fetchone()
     if rows:
         return AnonDB.rows_to_dict(rows)
     return None
Beispiel #29
0
 def is_ignored_chan(chan_id: int):
     con, cur = Db.connect()
     try:
         cur.execute(
             "SELECT * FROM public.rankings_chan WHERE chan_id = {}::text;".
             format(str(chan_id)))
     except Exception as err:
         print(err)
         con.rollback()
     rows = cur.fetchone()
     if rows:
         return True
     return False
Beispiel #30
0
 def set_lover(user_id: int, lover_id: int):
     con, cur = Db.connect()
     try:
         cur.execute("UPDATE public.user SET married = TRUE , lover = {}::text WHERE  user_id = {}::text".format(
             str(lover_id),
             str(user_id)))
         cur.execute("UPDATE public.user SET married = TRUE , lover = {}::text WHERE  user_id = {}::text".format(
             str(user_id),
             str(lover_id)))
     except Exception as err:
         print(err)
         con.rollback()
     con.commit()