<commit_before>import random
import re
from twisted.internet import protocol, reactor
from twisted.words.protocols import irc
from twisted.python import log

i = random.randrange(10000)
DEFAULT_NICKNAME = 'automatron%d,automatron%d_,automatron%d__' % (i, i, i)
DEFAULT_REALNAME = 'Automatron %d' % i
USER_RE = re.compile(r'(.*)?!(.*)?@(.*)')


class Client(irc.IRCClient):
    def __init__(self, controller, server, config):
        self.controller = controller
        self.server = server
        self.config = config
        self.nicknames = [
            n.strip()
            for n in self.config.get('nickname', DEFAULT_NICKNAME).split(',')
        ]
        self.nickname = self.nicknames[0]
        self.realname = self.config.get('realname', DEFAULT_REALNAME)

    def logPrefix(self):
        return '%s' % self.server

    def emit(self, event, *args):
        self.controller.plugins.emit(event, self, *args)

    def parse_user(self, user):
        m = USER_RE.match(user)
        if not m:
            return user, None, None
        else:
            return m.groups()

    def alterCollidedNick(self, nickname):
        new_nick = self.nicknames[(self.nicknames.index(nickname) + 1) % len(self.nicknames)]
        log.msg('Nickname %s is taken, trying %s.' % (nickname, new_nick))
        return new_nick

    def connectionMade(self):
        log.msg('Connected')
        irc.IRCClient.connectionMade(self)
        self.emit('connection_made')

    def connectionLost(self, reason):
        log.msg('Connection lost' % self.server)
        irc.IRCClient.connectionLost(self, reason)
        self.emit('connection_lost', reason)

    def receivedMOTD(self, motd):
        log.msg('MOTD:\n%s' % motd)
        self.emit('server_motd', motd)

    def created(self, when):
        log.msg('Created: %s' % when)
        self.emit('server_created', when)

    def yourHost(self, info):
        log.msg('Host: %s' % info)
        self.emit('server_host', info)

    def myInfo(self, servername, version, umodes, cmodes):
        log.msg('Servername: %s, Version: %s, umodes: %s, cmodes: %s' % (
            servername,
            version,
            umodes,
            cmodes
        ))
        self.emit('server_info', servername, version, umodes, cmodes)

    def isupport(self, options):
        log.msg('Supports: %s' % options)
        self.emit('server_support', options)

    def luserClient(self, info):
        log.msg('Clients: %s' % info)
        self.emit('luser_client', info)<commit_msg>Improve logging of MOTD message.<commit_after>import random
import re
from twisted.internet import protocol, reactor
from twisted.words.protocols import irc
from twisted.python import log

i = random.randrange(10000)
DEFAULT_NICKNAME = 'automatron%d,automatron%d_,automatron%d__' % (i, i, i)
DEFAULT_REALNAME = 'Automatron %d' % i
USER_RE = re.compile(r'(.*)?!(.*)?@(.*)')


class Client(irc.IRCClient):
    def __init__(self, controller, server, config):
        self.controller = controller
        self.server = server
        self.config = config
        self.nicknames = [
            n.strip()
            for n in self.config.get('nickname', DEFAULT_NICKNAME).split(',')
        ]
        self.nickname = self.nicknames[0]
        self.realname = self.config.get('realname', DEFAULT_REALNAME)

    def logPrefix(self):
        return '%s' % self.server

    def emit(self, event, *args):
        self.controller.plugins.emit(event, self, *args)

    def parse_user(self, user):
        m = USER_RE.match(user)
        if not m:
            return user, None, None
        else:
            return m.groups()

    def alterCollidedNick(self, nickname):
        new_nick = self.nicknames[(self.nicknames.index(nickname) + 1) % len(self.nicknames)]
        log.msg('Nickname %s is taken, trying %s.' % (nickname, new_nick))
        return new_nick

    def connectionMade(self):
        log.msg('Connected')
        irc.IRCClient.connectionMade(self)
        self.emit('connection_made')

    def connectionLost(self, reason):
        log.msg('Connection lost' % self.server)
        irc.IRCClient.connectionLost(self, reason)
        self.emit('connection_lost', reason)

    def receivedMOTD(self, motd):
        log.msg('MOTD:\n%s' % '\n'.join(motd))
        self.emit('server_motd', motd)

    def created(self, when):
        log.msg('Created: %s' % when)
        self.emit('server_created', when)

    def yourHost(self, info):
        log.msg('Host: %s' % info)
        self.emit('server_host', info)

    def myInfo(self, servername, version, umodes, cmodes):
        log.msg('Servername: %s, Version: %s, umodes: %s, cmodes: %s' % (
            servername,
            version,
            umodes,
            cmodes
        ))
        self.emit('server_info', servername, version, umodes, cmodes)

    def isupport(self, options):
        log.msg('Supports: %s' % options)
        self.emit('server_support', options)

    def luserClient(self, info):
        log.msg('Clients: %s' % info)
        self.emit('luser_client', info)
{'fraction_non_alphanumeric': 0.13548259493670886, 'fraction_numerical': 0.002768987341772152, 'mean_word_length': 2.612142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5152397', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1600, 'n_words': 355}