Ejemplo n.º 1
0
async def waffletour(conn: Connection, room: Optional[str], user: str,
                     arg: str) -> None:
    if room is None or not utils.is_driver(user):
        return

    name = "Super Italian Bros. Brawl"
    rules = [
        "Cancel Mod",
        "Dynamax Clause",
        "Endless Battle Clause",
        "Evasion Moves Clause",
        "HP Percentage Mod",
        "Obtainable Formes",  # to avoid multiple Mega-Evolutions
        "Sleep Clause Mod",
        "Species Clause",
    ]

    await create_tour(conn,
                      room,
                      name=name,
                      autostart=5,
                      autodq=3,
                      forcetimer=True,
                      rules=rules)

    await conn.send_message(room, "!viewfaq sibb", False)
Ejemplo n.º 2
0
async def randpoketour(conn: Connection, room: Optional[str], user: str,
                       arg: str) -> None:
    if room is None or not utils.is_driver(user):
        return

    if arg.strip() == "":
        await conn.send_message(room, "Inserisci almeno un Pokémon")
        return

    formatid = "nationaldex"
    name = "!RANDPOKE TOUR"
    rules = ["Z-Move Clause", "Dynamax Clause"]
    bans = ["All Pokemon"]
    unbans = []
    if "," in arg:
        sep = ","
    else:
        sep = " "
    for item in arg.split(sep):
        unbans.append(item.strip() + "-base")

    rules.extend(["-" + i for i in bans])
    rules.extend(["+" + i for i in unbans])

    await create_tour(conn,
                      room,
                      formatid=formatid,
                      name=name,
                      autostart=12,
                      rules=rules)
Ejemplo n.º 3
0
 def check_no_mods_online(self) -> None:
     if self.no_mods_online:
         return
     for user in self.users:
         if self.users[user]["idle"]:
             continue
         rank = self.users[user]["room_rank"] or self.users[user]["rank"]
         if utils.is_driver(rank):
             return
     self.no_mods_online = time()
Ejemplo n.º 4
0
 def add_user(self, userid: str, rank: str, username: str,
              idle: bool) -> None:
     self.users[userid] = {
         "rank": rank,
         "global_rank": None,
         "room_rank": None,
         "username": username,
         "idle": idle,
     }
     if utils.is_driver(rank):
         if not idle:
             self.no_mods_online = None
         else:
             self.check_no_mods_online()
Ejemplo n.º 5
0
async def removequote(conn: Connection, room: Optional[str], user: str,
                      arg: str) -> None:
    if room is None or not utils.is_driver(user):
        return

    if not arg:
        await conn.send_message(room, "Che quote devo cancellare?")
        return

    db = Database()
    db.executenow("DELETE FROM quotes WHERE message = ? AND roomid = ?",
                  [arg, room])
    if db.connection.total_changes:
        await conn.send_message(room, "Quote cancellata.")
    else:
        await conn.send_message(room, "Quote inesistente.")
Ejemplo n.º 6
0
async def dashboard(conn: Connection, room: Optional[str], user: str, arg: str) -> None:
    userid = utils.to_user_id(user)
    for r in conn.rooms:
        users = Room.get(r).users
        if userid in users and utils.is_driver(users[userid]["rank"]):
            rank = users[userid]["rank"]
            break
    else:
        return

    private_rooms = [r for r in conn.private_rooms if userid in Room.get(r).users]

    token_id = utils.create_token(rank, private_rooms, 1)

    await conn.send_pm(
        user, "{url}?token={token}".format(url=conn.domain, token=token_id)
    )
Ejemplo n.º 7
0
async def addquote(conn: Connection, room: Optional[str], user: str,
                   arg: str) -> None:
    if room is None or not utils.is_driver(user):
        return

    if not arg:
        await conn.send_message(room, "Cosa devo salvare?")
        return

    maxlen = 250  # lower than the message limit to have space for metadata
    if len(arg) > maxlen:
        await conn.send_message(
            room, f"Quote troppo lunga, max {maxlen} caratteri.")
        return

    db = Database()
    sql = "INSERT OR IGNORE INTO quotes (message, roomid, author, date) "
    sql += "VALUES (?, ?, ?, DATE())"
    db.executenow(sql, [arg, room, utils.to_user_id(user)])
    if db.connection.total_changes:
        await conn.send_message(room, "Quote salvata.")
    else:
        await conn.send_message(room, "Quote già esistente.")
Ejemplo n.º 8
0
 def remove_user(self, userid: str) -> None:
     user = self.users.pop(userid, None)
     if user is not None:
         if utils.is_driver(user["rank"]):
             self.check_no_mods_online()
Ejemplo n.º 9
0
 def wrapper() -> str:
     if "rank" not in session or not utils.is_driver(session["rank"]):
         abort(401)
     return func()