Пример #1
0
    def setup_private_channel(self, channel):
        """
        Configures a private IRC channel by setting modes and adding all members to ACL if it is a team channel
        """
        logger.debug("Inside setup_private_channel() for %s" % channel)

        # basic private channel modes
        self.bot.privmsg(settings.IRCBOT_CHANSERV_MASK,
                         "SET %s mlock +inpst" % channel)
        self.bot.privmsg(settings.IRCBOT_CHANSERV_MASK,
                         "SET %s SECURE on" % channel)
        self.bot.privmsg(settings.IRCBOT_CHANSERV_MASK,
                         "SET %s RESTRICTED on" % channel)

        # add the bot to the ACL
        self.bot.add_user_to_channel_acl(username=settings.IRCBOT_NICK,
                                         channel=channel,
                                         invite=True)

        team = get_team_from_irc_channel(channel)
        if team:
            # this is a team channel, add team members to channel ACL
            self.bot.add_team_members_to_channel_acl(team)
            # make sure private_irc_channel_fix_needed is set to False and save
            team.private_irc_channel_fix_needed = False
            team.save()
Пример #2
0
    def setup_public_channel(self, channel):
        """
        Configures a public IRC channel by setting modes and giving all team members +oO if it is a team channel
        """
        logger.debug("Inside setup_public_channel() for %s" % channel)

        # basic private channel modes
        self.bot.privmsg(settings.IRCBOT_CHANSERV_MASK, "SET %s mlock +nt-lk" % channel)
        self.bot.privmsg(settings.IRCBOT_CHANSERV_MASK, "SET %s SECURE off" % channel)
        self.bot.privmsg(
            settings.IRCBOT_CHANSERV_MASK, "SET %s RESTRICTED off" % channel
        )

        team = get_team_from_irc_channel(channel)
        if team:
            # add members to ACL
            self.bot.add_team_members_to_channel_acl(team)
            # make sure public_irc_channel_fix_needed is set to False and save
            team.public_irc_channel_fix_needed = False
            team.save()
Пример #3
0
    def handle_chanserv_privmsg(self, **kwargs):
        """
        Handle messages from ChanServ on networks with Services.
        """
        logger.debug("Got a message from ChanServ")

        ###############################################
        # handle "Channel \x02#example\x02 is not registered." message
        ###############################################
        match = re.compile(
            "Channel (#[a-zA-Z0-9-]+) is not registered.").match(
                kwargs['data'].replace("\x02", ""))
        if match:
            # the irc channel is not registered
            channel = match.group(1)
            # get a list of the channels we are supposed to be managing
            if channel in self.bot.get_managed_team_channels(
            ) or channel == settings.IRCBOT_VOLUNTEER_CHANNEL:
                # we want to register this channel! though we can only do so if we have a @ in the channel
                if self.bot.nick in self.bot.channels[channel].modes['@']:
                    logger.debug(
                        "ChanServ says channel %s is not registered, bot is supposed to be managing this channel, registering it with chanserv"
                        % channel)
                    self.bot.privmsg(settings.IRCBOT_CHANSERV_MASK,
                                     "register %s" % channel)
                else:
                    logger.debug(
                        "ChanServ says channel %s is not registered, bot is supposed to be managing this channel, but the bot cannot register without @ in the channel"
                        % channel)
                    self.bot.privmsg(
                        channel,
                        "I need @ before I can register this channel with ChanServ"
                    )
            return

        ###############################################
        # handle "\x02#example\x02 is now registered to \x02tykbhdev\x02" message
        ###############################################
        match = re.compile(
            "(#[a-zA-Z0-9-]+) is now registered to ([a-zA-Z0-9-]+)\\.").match(
                kwargs['data'].replace("\x02", ""))
        if match:
            # the irc channel is now registered
            channel = match.group(1)
            botnick = match.group(2)
            logger.debug(
                "Channel %s was registered with ChanServ, looking up Team..." %
                channel)

            team = get_team_from_irc_channel(channel)
            if team:
                if team.private_irc_channel_name == channel:
                    # set private channel modes, +I and ACL
                    self.bot.setup_private_channel(channel)
                else:
                    # set public channel modes and +oO for all members
                    self.bot.setup_public_channel(channel)
                return
            logger.debug("Unable to find Team matching IRC channel %s" %
                         channel)

            # check if this channel is the volunteer channel
            if channel == settings.IRCBOT_VOLUNTEER_CHANNEL:
                logger.debug("%s is the volunteer channel, setting up" %
                             channel)
                self.bot.setup_private_channel(channel)
                # lets handle the volunteer channels initial ACL manually..
                return

        logger.debug("Unhandled ChanServ message: %s" % kwargs['data'])