コード例 #1
0
    def mode(self, _, line):
        """Offer an easy to use interface for mode"""
        isupport = self.base.isupport
        modegroups = isupport.get("CHANMODES")
        prefix = prefix_parse(isupport.get("PREFIX"))

        params = line.params[:] if line.command == "MODE" else line.params[1:]

        target = params[0]
        modes = params[1]
        params = params[2:]

        channels = tuple(isupport.get("CHANTYPES"))
        if not target.startswith(channels):
            # TODO - user modes
            return

        gen = mode_parse(modes, params, modegroups, prefix)
        prefix = prefix.mode_to_prefix
        for mode, param, adding in gen:
            if mode in prefix:
                mode_call = "mode_prefix"
            elif mode in modegroups[0]:
                mode_call = "mode_list",
            elif mode in modegroups[1]:
                mode_call = "mode_key",
            elif mode in modegroups[2]:
                mode_call = "mode_param",
            else:
                mode_call = "mode_normal"

            # TODO - aggregation
            mode = Mode(mode, param, adding, None)
            self.call_event("modes", mode_call, line.hostmask, target, mode)
コード例 #2
0
ファイル: usertrack.py プロジェクト: foxkit-us/PyIRC
    def who(self, _, line):
        """Process a WHO response, updating the corresponding user object."""
        if len(line.params) < 8:
            # Some bizarre RFC breaking server
            _logger.warning("Malformed WHO from server")
            return

        channel = line.params[1]
        username = line.params[2]
        host = line.params[3]
        server = line.params[4]
        nick = line.params[5]
        flags = who_flag_parse(line.params[6])
        other = line.params[7]
        # TODO: find something to do with this stuff
        # pylint: disable=unused-variable
        hopcount, _, other = other.partition(' ')

        user = self.get_user(nick)
        if not user:
            return

        isupport = self.base.isupport

        if isupport.get("RFC2812"):
            # IRCNet, for some stupid braindead reason, sends SID here. Why? I
            # don't know. They mentioned it might break clients in the commit
            # log. I really have no idea why it exists, why it's useful to
            # anyone, or anything like that. But honestly, WHO sucks enough...
            sid, _, gecos = other.partition(' ')
        else:
            sid = None
            gecos = other

        if channel != '*':
            # Convert symbols to modes
            prefix = prefix_parse(isupport.get("PREFIX")).prefix_to_mode

            mode = set()
            for char in flags.modes:
                char = prefix.get(char)
                if char is not None:
                    mode.add(char)

            user.channels[channel] = mode

        away = flags.away
        operator = flags.operator

        # NB - these two members aren't guaranteed to exist (yet?)
        user.sid = sid
        user.server = server

        user.username = username
        user.host = host
        user.gecos = gecos
        user.away = away
        user.operator = operator
コード例 #3
0
ファイル: usertrack.py プロジェクト: bethebunny/mircy
    def whox(self, event):
        if len(event.line.params) != 12:
            # Not from us!
            return

        whoxid = event.line.params[1]
        channel = event.line.params[2]
        username = event.line.params[3]
        ip = event.line.params[4]
        host = event.line.params[5]
        server = event.line.params[6]
        nick = event.line.params[7]
        flags = who_flag_parse(event.line.params[8])
        # idle = event.line.params[9]
        account = event.line.params[10]
        gecos = event.line.params[11]

        user = self.get_user(nick)
        if not user:
            return

        if whoxid not in self.whox_send:
            # Not sent by us, weird!
            return

        if channel != '*':
            # Convert symbols to modes
            isupport = self.get_extension("ISupport")
            prefix = prefix_parse(isupport.get("PREFIX")).prefix_to_mode

            mode = set()
            for char in flags.modes:
                char = prefix.get(char)
                if char is not None:
                    mode.add(char)

            user.channels[channel] = mode

        away = flags.away
        operator = flags.operator

        if account == '0':
            # Not logged in
            account = ''

        if ip == '255.255.255.255':
            # Cloaked
            ip = None

        user.username = username
        user.host = host
        user.server = server
        user.gecos = gecos
        user.away = away
        user.operator = operator
        user.account = account
        user.ip = ip
コード例 #4
0
ファイル: usertrack.py プロジェクト: bethebunny/mircy
    def whois_channels(self, event):
        user = self.get_user(event.line.params[1])
        if not user:
            return

        isupport = self.get_extension("ISupport")
        prefix = prefix_parse(isupport.get("PREFIX"))

        for channel in event.line.params[-1].split():
            mode = set()
            mode, channel = status_prefix_parse(channel, prefix)
            user.channels[channel] = mode
コード例 #5
0
ファイル: usertrack.py プロジェクト: foxkit-us/PyIRC
    def whois_channels(self, _, line):
        """Update a user's channel set."""
        user = self.get_user(line.params[1])
        if not user:
            return

        isupport = self.base.isupport
        prefix = prefix_parse(isupport.get("PREFIX"))

        for channel in line.params[-1].split():
            mode = set()
            mode, channel = status_prefix_parse(channel, prefix)
            user.channels[channel] = mode
コード例 #6
0
ファイル: modehandler.py プロジェクト: bethebunny/mircy
    def names(self, event):
        line = event.line
        params = line.params

        target = params[2]

        isupport = self.get_extension("ISupport")
        prefix = prefix_parse(isupport.get("PREFIX"))

        logger.debug("params=%r", params)

        for nick in params[-1].split(' '):
            modes, nick = status_prefix_parse(nick, prefix)

            logger.debug("NAMES: %s", nick)

            for mode in modes:
                # TODO - aggregation
                self.call_event("modes", "mode_prefix", line, line.hostmask,
                                target, True, mode, nick)
コード例 #7
0
    def names(self, _, line):
        """Handle bursting of new users from NAMES."""
        params = line.params

        channel = params[2]

        isupport = self.base.isupport
        prefix = prefix_parse(isupport.get("PREFIX"))

        for hostmask in params[3].split(' '):
            if not hostmask:
                continue

            modes, hostmask = status_prefix_parse(hostmask, prefix)
            hostmask = Hostmask.parse(hostmask)

            modes = [(m, hostmask, True, None) for m in modes]

            scope = Scope(
                hostmask, channel, False, cause=line.hostmask, modes=modes)
            self.call_event("scope", "user_burst", scope)
コード例 #8
0
ファイル: modehandler.py プロジェクト: bethebunny/mircy
    def mode(self, event):
        # Offer an easy to use interface for mode
        isupport = self.get_extension("ISupport")
        modegroups = isupport.get("CHANMODES")
        prefix = prefix_parse(isupport.get("PREFIX"))

        line = event.line
        params = list(line.params)
        if line.command == Numerics.RPL_CHANNELMODEIS.value:
            params.pop(0)

        target = params.pop(0)
        modes = params.pop(0)

        channels = tuple(isupport.get("CHANTYPES"))
        if not target.startswith(channels):
            # TODO - user modes
            return

        gen = mode_parse(modes, params, modegroups, prefix)
        prefix = prefix.mode_to_prefix
        for mode, param, adding in gen:
            if mode in prefix:
                mode_call = "mode_prefix"
            elif mode in modegroups[0]:
                mode_call = "mode_list",
            elif mode in modegroups[1]:
                mode_call = "mode_key",
            elif mode in modegroups[2]:
                mode_call = "mode_param",
            else:
                mode_call = "mode_normal"

            # TODO - aggregation
            self.call_event("modes", mode_call, line, line.hostmask, target,
                            adding, mode, param)
コード例 #9
0
ファイル: usertrack.py プロジェクト: foxkit-us/PyIRC
    def whox(self, _, line):
        """Process a WHOX response, updating the corresponding user object."""
        if len(line.params) != 12:
            # Not from us!
            return

        # Verify the server supports WHOX for real because Bahamut has its own
        # Eldritch abomination we don't support (RWHO... you don't wanna know)
        isupport = self.base.isupport
        if not isupport.get("WHOX"):
            return

        whoxid = line.params[1]
        channel = line.params[2]
        username = line.params[3]
        ip_ = line.params[4]
        host = line.params[5]
        server = line.params[6]
        nick = line.params[7]
        flags = who_flag_parse(line.params[8])
        idle = line.params[9]
        account = line.params[10]
        gecos = line.params[11]

        user = self.get_user(nick)
        if not user:
            return

        if whoxid not in self.whox_send:
            # Not sent by us, weird!
            return

        if channel != '*':
            # Convert symbols to modes
            prefix = prefix_parse(isupport.get("PREFIX")).prefix_to_mode

            mode = set()
            for char in flags.modes:
                char = prefix.get(char)
                if char is not None:
                    mode.add(char)

            user.channels[channel] = mode

        away = flags.away
        operator = flags.operator

        if account == '0':
            # Not logged in
            account = ''

        if ip_ == '255.255.255.255':
            # Cloaked
            ip_ = None

        user.server = server
        user.idle = idle
        user.username = username
        user.host = host
        user.server = server
        user.gecos = gecos
        user.away = away
        user.operator = operator
        user.account = account
        user.ip = ip_
コード例 #10
0
ファイル: usertrack.py プロジェクト: bethebunny/mircy
    def who(self, event):
        if len(event.line.params) < 8:
            # Some bizarre RFC breaking server
            logger.warn("Malformed WHO from server")
            return

        channel = event.line.params[1]
        username = event.line.params[2]
        host = event.line.params[3]
        server = event.line.params[4]
        nick = event.line.params[5]
        flags = who_flag_parse(event.line.params[6])
        other = event.line.params[7]
        hopcount, _, other = other.partition(' ')

        user = self.get_user(nick)
        if not user:
            return

        isupport = self.get_extension("ISupport")

        if isupport.get("RFC2812"):
            # IRCNet, for some stupid braindead reason, sends SID here. Why? I
            # don't know. They mentioned it might break clients in the commit
            # log. I really have no idea why it exists, why it's useful to
            # anyone, or anything like that. But honestly, WHO sucks enough...
            sid, _, realname = other.partition(' ')
        else:
            sid = None
            realname = other

        if channel != '*':
            # Convert symbols to modes
            prefix = prefix_parse(isupport.get("PREFIX")).prefix_to_mode

            mode = set()
            for char in flags.modes:
                char = prefix.get(char)
                if char is not None:
                    mode.add(char)

            user.channels[channel] = mode

        away = flags.away
        operator = flags.operator

        if account == '0':
            # Not logged in
            account = ''

        if ip == '255.255.255.255':
            # Cloaked
            ip = None

        user.username = username
        user.host = host
        user.gecos = gecos
        user.away = away
        user.operator = operator
        user.account = account
        user.ip = ip