示例#1
0
	def register(self):
		"""Functionality to register the module with the intent & api services."""

		for key, command in self.commands.items():
			isCore = False

			if 'core' in command and command['core']:
				isCore = True

			try:
				fb.intent.service.registerCommand(command['keywords'], getattr(self, command['function']), self.uid + ":command." + key, isCore)
			except:
				log.msg("Error registering %s command %s:" % (self.uid, key), log.ERROR)
				raise

		for key, listener in self.listeners.items():
			try:
				fb.intent.service.registerListener(listener['keywords'], getattr(self, listener['function']), self.uid + ":listener." + key)
			except:
				log.msg("Error registering %s listener %s:" % (self.uid, key), log.ERROR)
				raise

		for path, module in self.apis.items():
			if type(module) == type(()):
				api.registerModule(path, module[0], module[1])
			else:
				api.registerModule(path, module)

		for name, child in self._children.items():
			try:
				child.register()
			except:
				log.msg("Error registering %s child module %s:" % (self.uid, name), log.ERROR)
				raise
示例#2
0
    def register(self):
        """Functionality to register the module with the intent & api services."""

        for key, command in self.commands.items():
            isCore = False

            if 'core' in command and command['core']:
                isCore = True

            try:
                fb.intent.service.registerCommand(
                    command['keywords'], getattr(self, command['function']),
                    self.uid + ":command." + key, isCore)
            except:
                log.msg("Error registering %s command %s:" % (self.uid, key),
                        log.ERROR)
                raise

        for key, listener in self.listeners.items():
            try:
                fb.intent.service.registerListener(
                    listener['keywords'], getattr(self, listener['function']),
                    self.uid + ":listener." + key)
            except:
                log.msg("Error registering %s listener %s:" % (self.uid, key),
                        log.ERROR)
                raise

        for path, module in self.apis.items():
            if type(module) == type(()):
                api.registerModule(path, module[0], module[1])
            else:
                api.registerModule(path, module)

        for name, child in self._children.items():
            try:
                child.register()
            except:
                log.msg(
                    "Error registering %s child module %s:" % (self.uid, name),
                    log.ERROR)
                raise
示例#3
0
	def register(self):
		apimodule = api.registerModule('message')
		apimodule.putChild('room', SimpleFunction(self.room_message))
		apimodule.putChild('user', SimpleFunction(self.user_message))
示例#4
0
文件: api.py 项目: jburgar/Fritbot
	def register(self, parent):
		apimodule = api.registerModule('facts', FactsList())
示例#5
0
	def register(self):
		apimodule = api.registerModule('apitest')
		apimodule.putChild('hello', SimpleFunction(self.hello))