Example #1
0
    def cycle(self, channel):
        """ Rejoin channel. """
        if not self.in_channel(channel):
            raise NotInChannel(channel)

        password = self.channels[channel]['password']
        self.part(channel)
        self.join(channel, password)
Example #2
0
    def set_mode(self, target, *modes):
        """
        Set mode on target.
        Users should only rely on the mode actually being changed when receiving an on_{channel,user}_mode_change callback.
        """
        if self.is_channel(target) and not self.in_channel(target):
            raise NotInChannel(target)

        self.rawmsg('MODE', target, *modes)
Example #3
0
    def kick(self, channel, target, reason=None):
        """ Kick user from channel. """
        if not self.in_channel(channel):
            raise NotInChannel(channel)

        if reason:
            self.rawmsg('KICK', channel, target, reason)
        else:
            self.rawmsg('KICK', channel, target)
Example #4
0
    def part(self, channel, message=None):
        """ Leave channel, optionally with message. """
        if not self.in_channel(channel):
            raise NotInChannel(channel)

        # Message seems to be an extension to the spec.
        if message:
            self.rawmsg('PART', channel, message)
        else:
            self.rawmsg('PART', channel)
Example #5
0
    def set_topic(self, channel, topic):
        """
        Set topic on channel.
        Users should only rely on the topic actually being changed when receiving an on_topic_change callback.
        """
        if not self.is_channel(channel):
            raise ValueError('Not a channel: {}'.format(channel))
        elif not self.in_channel(channel):
            raise NotInChannel(channel)

        self.rawmsg('TOPIC', channel, topic)