async def write_chat_log(channel, author, message): if channel == '#speedrunslive': return # ignore private messages if channel == config['srl_irc_nickname']: return filename = channel + ".log" async with aiofiles.open(config['srl_log_local'] + '/' + filename, "a") as out: await out.write( "\"{timestamp}\" - \"{channel}\" - \"{author}\" - \"{message}\"\n". format(timestamp=datetime.datetime.utcnow(), channel=channel, author=author, message=ircmessage.unstyle(message))) await out.close()
def __init__(self, message, destination, source, message_type=MESSAGE): """ @type message: str @type destination: Destination @param destination: The message destination @type source: Hostmask @param source: The source (user) that sent the message @type message_type: str @param message_type: The message type. Either message, notice or action """ self._log = logging.getLogger("firefly.message") self.raw = message.strip() self.stripped = unstyle(message).strip() self.destination = destination self.source = source self.type = message_type self._command = []
def test_unstyle_nothing(self): message = 'Hello, world!' self.assertEqual(ircmessage.unstyle(message), message)
def test_unstyle_complex(self): message = '\x0308,02\x02\x1fHello, world!\x0F' self.assertEqual(ircmessage.unstyle(message), 'Hello, world!')