Ejemplo n.º 1
0
Archivo: core.py Proyecto: Mika64/irc3
 def autojoin(self, **kw):
     """autojoin at the end of MOTD"""
     self.bot.config['nick'] = kw['me']
     self.bot.recompile()
     channels = utils.as_list(self.bot.config.get('autojoins', []))
     for channel in channels:
         channel = utils.as_channel(channel)
         self.bot.log.info('Trying to join %s', channel)
         self.bot.join(channel)
Ejemplo n.º 2
0
Archivo: core.py Proyecto: jpcw/irc3
 def autojoin(self, **kw):
     """autojoin at the end of MOTD"""
     self.bot.config['nick'] = kw['me']
     self.bot.recompile()
     channels = utils.as_list(self.bot.config.get('autojoins', []))
     for channel in channels:
         channel = utils.as_channel(channel)
         self.bot.log.info('Trying to join %s', channel)
         self.bot.join(channel)
Ejemplo n.º 3
0
 def join(self, channel=None):
     if channel is None:
         channels = self.channels
     else:
         channels = [channel]
     for channel in channels:
         channel = utils.as_channel(channel)
         if channel in self.handles:
             timeout, handle = self.handles[channel]
             self.bot.log.info('Re-trying to join %s after %ss', channel,
                               timeout)
         else:
             self.bot.log.info('Trying to join %s', channel)
         self.bot.join(channel)
Ejemplo n.º 4
0
 def join(self, channel=None):
     if channel is None:
         channels = self.channels
     else:
         channels = [channel]
     for channel in channels:
         channel = utils.as_channel(channel)
         if channel in self.handles:
             timeout, handle = self.handles[channel]
             self.bot.log.info('Re-trying to join %s after %ss',
                               channel, timeout)
         else:
             self.bot.log.info('Trying to join %s', channel)
         self.bot.join(channel)
Ejemplo n.º 5
0
    def __init__(self, bot):
        self.bot = bot
        self.reader = None

        self.log = logging.getLogger('irc3.%s' % __name__)
        self.log_parser = LogParser(self.log)

        self.config = dict(DEFAULT_CONFIG)
        self.config.update(bot.config.get(self.__class__.__module__, {}))
        self.log.debug('config: %r', self.config)

        autojoins = self.bot.config.get('autojoins')
        self.channels = [
            as_channel(c)
            for c in as_list(
                self.config.get('channels', autojoins)
            )
        ]

        self.actions = {}

        for act_type in DEFAULT_FORWARDING:
            config = dict(DEFAULT_FORWARDING[act_type])
            config.update(self.bot.config.get(
                '%s.%s-forwarding' % (self.__class__.__module__, act_type)))
            self.actions[act_type] = config

        self.log.debug('actions: %r', self.actions)

        # on_quit needs to be executed before the userlist plugin sees
        # the QUIT event so that we can check which channels the user
        # was in
        self.bot.attach_events(
            irc3.event(irc3.rfc.QUIT, self.on_quit),
            insert=True
        )
        self.log.info('FactoIRC %s loaded.' % __version__)
Ejemplo n.º 6
0
 def part(self, channel):
     channel = utils.as_channel(channel)
     self.bot.log.info('Leaving channel %s', channel)
     self.bot.part(channel)
     if channel in self.joined:  # pragma: no cover
         self.joined.remove(channel)