コード例 #1
0
 def test_news(self):
     call_function = None
     plugin_handler.load('core/plugins', db)
     for i in plugin_handler.plugin_subscriptions:
         if i['name'] == "news":
             call_function = i["function"]
     print (call_function({"command": "Read me the news", "username": "******", "db": db}))
コード例 #2
0
def initialize(db):
    """
    Run the plugin loader

    :param db:
    """
    log.info("Loading plugins")
    plugin_handler.load("core/plugins", db)
コード例 #3
0
 def test_weather(self):
     call_function = None
     plugin_handler.load('core/plugins', db)
     for i in plugin_handler.plugin_subscriptions:
         if i['name'] == "weather":
             call_function = i["function"]
     response = call_function({"command": "Tell me the weather", "username": "******", "db": db})
     logging.info("Weather response is {0}".format(response))
     print (response)
コード例 #4
0
 def test_search(self):
     call_function = None
     plugin_handler.load('core/plugins', db)
     for i in plugin_handler.plugin_subscriptions:
         if i['name'] == "search":
             call_function = i["function"]
     searches = [
         "Who is the queen of england?",
         "How old is putin?",
         "When did napoleon die?",
         "Who invented python?",
         "what day is it",
         "what's 27 times 62",
         "When did bach die?",
         "Who is will beddow?",
         "Who's obama?"
     ]
     def do_search(query, call_function):
         print (plugin_handler.subscriptions().call_plugin(call_function, {
             "command": query, "db": db, "user_table":db['users'].find_one(username="******")}))
     map(lambda x: do_search(x, call_function), searches)
コード例 #5
0
 def test_subscriptions(self):
     plugin_handler.load('core/plugins', db)
     plugin_num = 5
     print plugin_handler.plugin_subscriptions
     self.assertEqual(len(plugin_handler.plugin_subscriptions), plugin_num)