示例#1
0
    def activate(self):
        super().activate()
        self.connection = MockConnection(self)
        self.dispatcher = self.plugins.command_dispatcher
        self.prefix = self.config.get_plugin_config(
            "command_dispatcher")["command_prefix"]
        self.server = self.config.get_plugin_config(self.name)["server"]
        self.channel = self.config.get_plugin_config(self.name)["channel"]
        self.username = self.config.get_plugin_config(self.name)["username"]
        self.sc = self.config.get_plugin_config(self.name)["strip_colors"]

        self.bot = irc3.IrcBot(nick=self.username,
                               autojoins=[self.channel],
                               host=self.server)
        self.bot.log = self.logger

        self.bot.include("irc3.plugins.core")
        self.bot.include("irc3.plugins.userlist")

        x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
        x.compile(None)
        y = irc3.event(r"^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)",
                       self.name_check)
        y.compile(None)
        self.bot.attach_events(x)
        self.bot.attach_events(y)
        self.bot.create_connection()

        self.ops = set()
        asyncio.ensure_future(self.update_ops())
示例#2
0
    def activate(self):
        super().activate()
        self.connection = MockConnection(self)
        self.dispatcher = self.plugins.command_dispatcher
        self.prefix = self.config.get_plugin_config("command_dispatcher")[
            "command_prefix"]
        self.server = self.config.get_plugin_config(self.name)["server"]
        self.channel = self.config.get_plugin_config(self.name)["channel"]
        self.username = self.config.get_plugin_config(self.name)["username"]
        self.sc = self.config.get_plugin_config(self.name)["strip_colors"]

        self.bot = irc3.IrcBot(nick=self.username,
                               autojoins=[self.channel],
                               host=self.server)
        self.bot.log = self.logger

        self.bot.include("irc3.plugins.core")
        self.bot.include("irc3.plugins.userlist")

        x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
        x.compile(None)
        y = irc3.event(r"^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)",
                       self.name_check)
        y.compile(None)
        self.bot.attach_events(x)
        self.bot.attach_events(y)
        self.bot.create_connection()

        self.ops = set()
        asyncio.ensure_future(self.update_ops())
示例#3
0
文件: sasl.py 项目: adongy/irc3
 def __init__(self, bot):
     self.bot = bot
     self.events = [
         irc3.event(r'^:\S+ CAP \S+ LS :(?P<data>.*)', self.cap_ls),
         irc3.event(r'^:\S+ CAP \S+ ACK :.*sasl.*', self.cap_ack),
         irc3.event(r'AUTHENTICATE +', self.authenticate),
         irc3.event(r'^:\S+ 903 \S+ :SASL authentication successful',
                    self.cap_end),
     ]
示例#4
0
 def __init__(self, bot):
     self.bot = bot
     self.events = [
         irc3.event(r'^:\S+ CAP \S+ LS :(?P<data>.*)', self.cap_ls),
         irc3.event(r'^:\S+ CAP \S+ ACK :.*sasl.*', self.cap_ack),
         irc3.event(r'AUTHENTICATE +', self.authenticate),
         irc3.event(r'^:\S+ 903 \S+ :SASL authentication successful',
                    self.cap_end),
     ]
示例#5
0
 def __init__(self, bot):
     self.bot = bot
     self.timeout = int(self.bot.config.get('timeout'))
     self.max_lag = int(self.bot.config.get('max_lag'))
     self.reconn_handle = None
     self.ping_handle = None
     self.before_connect_events = [
         event(rfc.CONNECTED, self.connected),
         event(r"^:\S+ 005 \S+ (?P<data>.+) :\S+.*", self.set_config),
     ]
示例#6
0
文件: core.py 项目: pypingou/irc3
 def __init__(self, bot):
     self.bot = bot
     self.timeout = int(self.bot.config.get('timeout'))
     self.max_lag = int(self.bot.config.get('max_lag'))
     self.reconn_handle = None
     self.ping_handle = None
     self.before_connect_events = [
         event(rfc.CONNECTED, self.connected),
         event(r"^:\S+ 005 \S+ (?P<data>.+) :\S+.*",
               self.set_config),
     ]
示例#7
0
文件: ctcp.py 项目: Harmon758/irc3
 def __init__(self, bot):
     maxsize = int(bot.config.get('ctcp_max_replies', 3))
     self.queue = Queue(loop=bot.loop, maxsize=maxsize)
     self.handle = None
     self.event = irc3.event(irc3.rfc.CTCP, self.on_ctcp)
     bot.attach_events(self.event)
     self.bot = bot
示例#8
0
 def __init__(self, bot):
     maxsize = int(bot.config.get('ctcp_max_replies', 3))
     self.queue = Queue(loop=bot.loop, maxsize=maxsize)
     self.handle = None
     self.event = irc3.event(irc3.rfc.CTCP, self.on_ctcp)
     bot.attach_events(self.event)
     self.bot = bot
示例#9
0
 def activate(self):
     super().activate()
     self.protocol = MockProtocol(self)
     self.bot = irc3.IrcBot(nick=temp_username, autojoins=[temp_channel],
                            host=temp_server)
     self.bot.log = self.logger
     self.bot.include('irc3.plugins.core')
     self.bot.include('irc3.plugins.userlist')
     x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
     x.compile(None)
     y = irc3.event(r'^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)',
                    self.name_check)
     y.compile(None)
     self.bot.add_event(x)
     self.bot.add_event(y)
     self.bot.create_connection()
     self.ops = set()
     asyncio.Task(self.update_ops())
示例#10
0
    def activate(self):
        self.enabled = self.config.get_plugin_config(self.name)["enabled"]
        if not self.enabled:
            return
        super().activate()
        self.dispatcher = self.plugins.command_dispatcher
        self.prefix = self.config.get_plugin_config("command_dispatcher")[
            "command_prefix"]
        self.command_prefix = self.config.get_plugin_config(self.name)[
            "command_prefix"]
        self.server = self.config.get_plugin_config(self.name)["server"]
        self.channel = self.config.get_plugin_config(self.name)["channel"]
        self.username = self.config.get_plugin_config(self.name)["username"]
        self.sc = self.config.get_plugin_config(self.name)["strip_colors"]

        self.bot = irc3.IrcBot(nick=self.username,
                               autojoins=[self.channel],
                               host=self.server)
        self.bot.log = self.logger

        self.bot.include("irc3.plugins.core")
        self.bot.include("irc3.plugins.userlist")

        x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
        x.compile(None)
        y = irc3.event(r"^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)",
                       self.name_check)
        y.compile(None)
        z = irc3.event(irc3.rfc.JOIN_PART_QUIT, self.announce_irc_join)
        z.compile(None)
        self.bot.attach_events(x)
        self.bot.attach_events(y)
        self.bot.attach_events(z)
        self.bot.create_connection()

        self.discord_active = link_plugin_if_available(self, 'discord_bot')
        if self.discord_active:
            self.discord = self.plugins['discord_bot']
        if link_plugin_if_available(self, "chat_manager"):
            self.chat_manager = self.plugins['chat_manager']

        self.ops = set()
        self.connection = MockConnection(self)
        asyncio.ensure_future(self.update_ops())
示例#11
0
    def activate(self):
        self.enabled = self.config.get_plugin_config(self.name)["enabled"]
        if not self.enabled:
            return
        super().activate()
        self.dispatcher = self.plugins.command_dispatcher
        self.prefix = self.config.get_plugin_config("command_dispatcher")[
            "command_prefix"]
        self.command_prefix = self.config.get_plugin_config(self.name)[
            "command_prefix"]
        self.server = self.config.get_plugin_config(self.name)["server"]
        self.channel = self.config.get_plugin_config(self.name)["channel"]
        self.username = self.config.get_plugin_config(self.name)["username"]
        self.sc = self.config.get_plugin_config(self.name)["strip_colors"]

        self.bot = irc3.IrcBot(nick=self.username,
                               autojoins=[self.channel],
                               host=self.server)
        self.bot.log = self.logger

        self.bot.include("irc3.plugins.core")
        self.bot.include("irc3.plugins.userlist")

        x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
        x.compile(None)
        y = irc3.event(r"^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)",
                       self.name_check)
        y.compile(None)
        z = irc3.event(irc3.rfc.JOIN_PART_QUIT, self.announce_irc_join)
        z.compile(None)
        self.bot.attach_events(x)
        self.bot.attach_events(y)
        self.bot.attach_events(z)
        self.bot.create_connection()

        self.discord_active = link_plugin_if_available(self, 'discord_bot')
        if self.discord_active:
            self.discord = self.plugins['discord_bot']
        if link_plugin_if_available(self, "chat_manager"):
            self.chat_manager = self.plugins['chat_manager']

        self.ops = set()
        self.connection = MockConnection(self)
        asyncio.ensure_future(self.update_ops())
示例#12
0
 def activate(self):
     super().activate()
     self.protocol = MockProtocol(self)
     self.bot = irc3.IrcBot(nick=temp_username,
                            autojoins=[temp_channel],
                            host=temp_server)
     self.bot.log = self.logger
     self.bot.include('irc3.plugins.core')
     self.bot.include('irc3.plugins.userlist')
     x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
     x.compile(None)
     y = irc3.event(r'^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)',
                    self.name_check)
     y.compile(None)
     self.bot.add_event(x)
     self.bot.add_event(y)
     self.bot.create_connection()
     self.ops = set()
     asyncio.Task(self.update_ops())
示例#13
0
    def test_async_event(self):
        loop = asyncio.new_event_loop()
        future = asyncio.Future(loop=loop)

        @asyncio.coroutine
        def e(ctx, **kwargs):
            ctx.privmsg('#irc3', 'async')
            future.set_result(ctx)

        bot = self.callFTU(loop=loop)

        e = irc3.utils.wraps_with_context(e, bot)
        bot.attach_events(irc3.event(irc3.rfc.PRIVMSG, e))

        bot.dispatch(':g!g@g PRIVMSG #irc3 :async')

        loop.run_until_complete(future)
        assert future.result() is bot
示例#14
0
    def test_async_event(self):
        loop = asyncio.new_event_loop()
        future = asyncio.Future(loop=loop)

        @asyncio.coroutine
        def e(ctx, **kwargs):
            ctx.privmsg('#irc3', 'async')
            future.set_result(ctx)

        bot = self.callFTU(loop=loop)

        e = irc3.utils.wraps_with_context(e, bot)
        bot.attach_events(irc3.event(irc3.rfc.PRIVMSG, e))

        bot.dispatch(':g!g@g PRIVMSG #irc3 :async')

        loop.run_until_complete(future)
        assert future.result() is bot
示例#15
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__)
示例#16
0
def privmsg(rule):
    p = r'^(@(?P<tags>\S+) )?:(?P<mask>\S+!\S+@\S+) PRIVMSG (?P<target>\S+) :'
    return irc3.event(p + rule)