~liberachat/curite

ref: c9456147e4571cd75d7d5bf73a37eaa05eabe814 curite/curite/__init__.py -rw-r--r-- 729 bytes
c9456147 — Jess Porter travis mypy (#3) 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from random    import randint
from irctokens import Line
from ircrobots import Bot as BaseBot
from ircrobots import Server as BaseServer

class Server(BaseServer):
    async def handshake(self):
        nickname = self.params.realname
        while "#" in nickname:
            onerand  = str(randint(0, 9))
            nickname = nickname.replace("#", onerand, 1)

        self.params.nickname = nickname
        self.params.username = nickname
        await super().handshake()

    def line_preread(self, line: Line):
        print(f"< {line.format()}")
    def line_presend(self, line: Line):
        print(f"> {line.format()}")

class Bot(BaseBot):
    def create_server(self, name: str):
        return Server(self, name)