Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(44)  |  Call(44)  |  Derive(0)  |  Import(0)

        def _handle_message(user, channel, message):
    if message.startswith(_cbprefix):
        command = message.split()[0].replace(_cbprefix, "")
        func = _callbacks.get(command)
        if func is not None:
            logging.debug(func)
            if func.enabled:
                if ((func.admin_only and is_admin(user))
                        or not func.admin_only):
                    _callbacks[command].func(
                        user,
                        channel,
                        message)
                else:
                    lala.util.msg(channel,
                                    "Sorry %s, you're not allowed to do that" % user)
            else:
                lala.util.msg(channel, "%s is not enabled" % command)
                logging.info("%s is not enabled" % command)
        return

    for regex in _regexes:
        match = regex.search(message)
        if match is not None:
            func = _regexes[regex]
            if func.enabled:
                logging.info("%s matched %s" % (message, regex))
                _regexes[regex].func(
                        user,
                        channel,
                        message,
                        match)
            else:
                logging.info("%s is not enabled" % regex.pattern)
        


src/l/a/lala-0.3/lala/bot.py   lala(Download)
            message = message.decode(config._get("base", "fallback_encoding"))
        logging.debug("%s: %s" % (user, message))
        lala.pluginmanager._handle_message(user, channel, message)
 
    def msg(self, channel, message, log, length=None):

src/l/a/lala-0.3/test/test_pluginmanager.py   lala(Download)
        pluginmanager.disable("command")
        self.assertFalse(pluginmanager._callbacks["command"].enabled)
        pluginmanager._handle_message("user", "channel", "!command")
 
    def test_reenabled_command(self):
        pluginmanager.disable(regex.pattern)
        self.assertFalse(pluginmanager._regexes[regex].enabled)
        pluginmanager._handle_message("user", "channel", "command")
 
    def test_reenabled_regex(self):
    def test_message_called(self):
        mocked_f = mock.Mock(spec=f)
        pluginmanager.register_callback("test", mocked_f)
        pluginmanager._handle_message("user", "channel", "!test")
        mocked_f.assert_called_once_with("user", "channel", "!test")
    def test_regex_called(self):
        mocked_f = mock.Mock(spec=f)
        pluginmanager.register_regex(compile("test"), mocked_f)
        pluginmanager._handle_message("user", "channel", "regex")
        self.assertFalse(mocked_f.called)
        pluginmanager._handle_message("user", "channel", "test foobar")

src/l/a/lala-0.3/test/test_plugins.py   lala(Download)
    def test_fortune(self):
        lala.plugins.fortune.getProcessOutput = _helpers.DeferredHelper(
                                                data="fortune")
        lala.pluginmanager._handle_message("user", "#channel", "!fortune")
        lala.plugins.fortune.getProcessOutput._fire()
    def test_ofortune(self):
        lala.plugins.fortune.getProcessOutput = _helpers.DeferredHelper(
                                                data="ofortune")
        lala.pluginmanager._handle_message("user", "#channel", "!ofortune")
        lala.plugins.fortune.getProcessOutput._fire()
        lala.plugins.fortune.getProcessOutput = _helpers.DeferredHelper(
                                                data="fortune")
        lala.pluginmanager._handle_message("user", "#channel", "!fortune")
        lala.plugins.fortune.getProcessOutput._fire()
        lala.util.msg.assert_called_once_with("#channel", "user: fortune")
    def test_fortune_with_non_default_files(self):
        lala.plugins.fortune.getProcessOutput = _helpers.DeferredHelper(
                                                data="fortune")
        lala.pluginmanager._handle_message("user", "#channel", "!fortune people riddles")
        lala.plugins.fortune.getProcessOutput._fire()
    def test_addadmin(self):
        lala.pluginmanager._handle_message("user", "#channel", "!addadmin user3")
        lala.config._CFG.set.assert_called_once_with("base", "admins",
                                                    "user,user2,user3")