<reponame>stijm/jazzjackrabbit2<gh_stars>1-10
from jj2.connection import Lookup
from scripts import play
from scripts.logger import LoggerBot


class RelayBot(LoggerBot):
    msg_prefix = '||||>||| '

    async def log(self, this, *args, sep=' ', **kwargs):
        line = await super().log(this, *args, sep=sep, **kwargs)
        text = line[line.index(')') + 2:]
        for connections in self.connections.values():
            for connection in connections:
                if connection.address != this.address and connection.me:
                    if not text.startswith(this.me.nickname + ':'):
                        text = self.msg_prefix + text.replace('|', '|' * 3, 1)
                        if ':' in text:
                            text = text.replace(':', ':' + '|' * 7, 1)
                        await self.send(connection, text)


if __name__ == '__main__':
    play(RelayBot, nick='R2D2', connect=[Lookup('CDF Server'), Lookup('AleyAsz Alpha')])

from jj2.connection import Lookup
from scripts import play
from scripts.logger import LoggerBot


class RelayBot(LoggerBot):
    msg_prefix = '||||>||| '

    async def log(self, this, *args, sep=' ', **kwargs):
        line = await super().log(this, *args, sep=sep, **kwargs)
        text = line[line.index(')') + 2:]
        for connections in self.connections.values():
            for connection in connections:
                if connection.address != this.address and connection.me:
                    if not text.startswith(this.me.nickname + ':'):
                        text = self.msg_prefix + text.replace('|', '|' * 3, 1)
                        if ':' in text:
                            text = text.replace(':', ':' + '|' * 7, 1)
                        await self.send(connection, text)


if __name__ == '__main__':
    play(RelayBot, nick='R2D2', connect=[Lookup('CDF Server'), Lookup('AleyAsz Alpha')])