def irc_PRIVMSG(self, prefix, params):
        """
        Send a (private) message.

        Parameters: <msgtarget> <text to be sent>
        """
        try:
            targetName = params[0]
            if isinstance(targetName, bytes):
                targetName = targetName.decode(self.encoding)
        except UnicodeDecodeError:
            self.sendMessage(
                irc.ERR_NOSUCHNICK, params[0],
                ":No such nick/channel (could not decode your unicode!)")
            return

        messageText = params[-1]
        if targetName.startswith('#'):
            target = self.realm.lookupGroup(targetName[1:])
        else:
            target = self.realm.lookupUser(targetName).addCallback(lambda user: user.mind)

        def cbTarget(targ):
            if targ is not None:
                return self.avatar.send(targ, {"text": messageText})

        def ebTarget(err):
            self.sendMessage(
                irc.ERR_NOSUCHNICK, targetName,
                ":No such nick/channel.")

        target.addCallbacks(cbTarget, ebTarget)

        Send a (private) message.

        Parameters: <msgtarget> <text to be sent>
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/words/service.py