'own_nick is the bot\'s nick, needed to correctly parse sender.
line is the full line from the server.'

def __init__(self, own_nick, line):

    line = line.strip(u'\r')
    self.line = line
    self.tags = {}
    if line.startswith(u'@'):
        (tagstring, line) = line.split(u'    ', 1)
        for tag in tagstring[1:].split(u';'):
            tag = tag.split(u'=', 1)
            if (len(tag) > 1):
                self.tags[tag[0]] = tag[1]
            else:
                self.tags[tag[0]] = None
    self.time = datetime.datetime.utcnow()
    if (u'time' in self.tags):
        try:
            self.time = datetime.datetime.strptime(self.tags[u'time'], u'%Y-%m-%dT%H:%M:%S.%fZ')
        except ValueError:
            pass
    if line.startswith(u':'):
        (self.hostmask, line) = line[1:].split(u'    ', 1)
    else:
        self.hostmask = None
    if (u'    :' in line):
        (argstr, text) = line.split(u'    :', 1)
        self.args = argstr.split(u'    ')
        self.args.append(text)
    else:
        self.args = line.split(u'    ')
        self.text = self.args[(-1)]
    self.event = self.args[0]
    self.args = self.args[1:]
    components = PreTrigger.component_regex.match((self.hostmask or u'')).groups()
    (self.nick, self.user, self.host) = components
    self.nick = sopel.tools.Identifier(self.nick)
    if (self.args and (self.event != u'QUIT')):
        target = sopel.tools.Identifier(self.args[0])
    else:
        target = None
    if (target and (target.lower() == own_nick.lower())):
        target = self.nick
    self.sender = target
    if ((self.event == u'PRIVMSG') or (self.event == u'NOTICE')):
        intent_match = PreTrigger.intent_regex.match(self.args[(-1)])
        if intent_match:
            (intent, message) = intent_match.groups()
            self.tags[u'intent'] = intent
            self.args[(-1)] = (message or u'')
    if ((self.event == u'JOIN') and (len(self.args) == 3)):
        self.tags[u'account'] = self.args[1]
