# Path: halibot/message.py
# class Message():
# 
# 	def __init__(self, **kwargs):
# 		self.log = logging.getLogger(self.__class__.__name__)
# 		self.uuid = uuid.uuid4()
# 		self.sync = False
# 
# 		self.body = kwargs.get('body', None)
# 		self.type = kwargs.get('type', 'simple')
# 		self.author = kwargs.get('author', None)
# 		self.identity = kwargs.get('identity', None)
# 		self.origin = kwargs.get('origin', None)
# 		self.misc = kwargs.get('misc', jsdict())
# 		self.target = kwargs.get('target', '')
# 
# 	def whom(self):
# 		return '/'.join(self.target.split('/')[1:])
# 
# 	def __repr__(self):
# 		return "halibot.Message(body='{}', type='{}', author='{}', identity='{}', origin='{}', misc='{}', target='{}')".format(self.body, self.type, self.author, self.identity, self.origin, self.misc, self.target)
# 
# 	def __str__(self):
# 		return "body='{}' type='{}' author='{}' origin='{}' target='{}'".format(self.body, self.type, self.author, self.origin, self.target)
# 
# Path: halibot/commandmodule.py
# class CommandModule(HalModule):
# 
# 	# Subclasses should implement a commands table like the following.
# 	#   Note, the "values" should be methods on the CommandModule-derived class
# 	#   Forgoing this is inadvisable (e.g. loss of _hal reference)
# 	#     "command" -> func(self, string, msg=msg)
# 	#   string: by default, will be the message not split into arguments
# 	#     use the annotation AsArgs above to override this
# 	#   msg: not needed in all commands, the message object as received
# 
# 	def __init__(self, hal, conf={}):
# 		super().__init__(hal, conf=conf)
# 
# 		self.commands = {}
# 		# Get the command prefix if defined, otherwise use "!" as default
# 		self.prefix = self._hal.config.get("command_prefix", "!")
# 
# 	# Override only if you know what you are doing!
# 	def receive(self, msg):
# 		self._cmd_receive(msg)
# 
# 	# Actually does the command handling logic. Separate callable so multi-inheritance
# 	#  can work nicely (maybe)
# 	def _cmd_receive(self, msg):
# 		body = msg.body.split(" ", 1)
# 		if body and not body[0].startswith(self.prefix):
# 			self.default(msg)
# 			return
# 
# 		# Ugly fix for commands without args
# 		if len(body) == 1:
# 			body.append("")
# 
# 		# This maybe should prevent a empty string as a key...
# 		func = self.commands.get(body[0][1:])
# 
# 		if func:
# 			func(body[1], msg=msg)
# 		else:
# 			self.default(msg)
# 
# 	# Override this to provide some functionality if there is no match in the table
# 	def default(self, msg):
# 		pass


from halibot import CommandModule, Message
				text += line + '\n'
				c = 2
				line = '  '
				first = True

			if first:
				first = False
			else:
				line += ', '
				c += 2

			line += t
			c += len(t)

		# Append final line
		if line.strip() != '':
			text += line + '\n'

		return text

	def command(self, args, msg=None):
		# TODO When containers/routes become more integrated, just look at the
		#      container the message was sent to, which shoudl work for the
		#      default container as well.
		target = self.config.get('target', self._hal.objects.modules.keys())
		target = [t for t in target if t.split('/')[0] != self.name] # Can't sync send to this module

		if args == '':
			self.reply(msg, body=self.general_help(target))
		else:

# Path: halibot/message.py
# class Message():
# 
# 	def __init__(self, **kwargs):
# 		self.log = logging.getLogger(self.__class__.__name__)
# 		self.uuid = uuid.uuid4()
# 		self.sync = False
# 
# 		self.body = kwargs.get('body', None)
# 		self.type = kwargs.get('type', 'simple')
# 		self.author = kwargs.get('author', None)
# 		self.identity = kwargs.get('identity', None)
# 		self.origin = kwargs.get('origin', None)
# 		self.misc = kwargs.get('misc', jsdict())
# 		self.target = kwargs.get('target', '')
# 
# 	def whom(self):
# 		return '/'.join(self.target.split('/')[1:])
# 
# 	def __repr__(self):
# 		return "halibot.Message(body='{}', type='{}', author='{}', identity='{}', origin='{}', misc='{}', target='{}')".format(self.body, self.type, self.author, self.identity, self.origin, self.misc, self.target)
# 
# 	def __str__(self):
# 		return "body='{}' type='{}' author='{}' origin='{}' target='{}'".format(self.body, self.type, self.author, self.origin, self.target)
# 
# Path: halibot/commandmodule.py
# class CommandModule(HalModule):
# 
# 	# Subclasses should implement a commands table like the following.
# 	#   Note, the "values" should be methods on the CommandModule-derived class
# 	#   Forgoing this is inadvisable (e.g. loss of _hal reference)
# 	#     "command" -> func(self, string, msg=msg)
# 	#   string: by default, will be the message not split into arguments
# 	#     use the annotation AsArgs above to override this
# 	#   msg: not needed in all commands, the message object as received
# 
# 	def __init__(self, hal, conf={}):
# 		super().__init__(hal, conf=conf)
# 
# 		self.commands = {}
# 		# Get the command prefix if defined, otherwise use "!" as default
# 		self.prefix = self._hal.config.get("command_prefix", "!")
# 
# 	# Override only if you know what you are doing!
# 	def receive(self, msg):
# 		self._cmd_receive(msg)
# 
# 	# Actually does the command handling logic. Separate callable so multi-inheritance
# 	#  can work nicely (maybe)
# 	def _cmd_receive(self, msg):
# 		body = msg.body.split(" ", 1)
# 		if body and not body[0].startswith(self.prefix):
# 			self.default(msg)
# 			return
# 
# 		# Ugly fix for commands without args
# 		if len(body) == 1:
# 			body.append("")
# 
# 		# This maybe should prevent a empty string as a key...
# 		func = self.commands.get(body[0][1:])
# 
# 		if func:
# 			func(body[1], msg=msg)
# 		else:
# 			self.default(msg)
# 
# 	# Override this to provide some functionality if there is no match in the table
# 	def default(self, msg):
# 		pass


# Path: packages/core/help.py
from halibot import CommandModule, Message

				text += line + '\n'
				c = 2
				line = '  '
				first = True

			if first:
				first = False
			else:
				line += ', '
				c += 2

			line += t
			c += len(t)

		# Append final line
		if line.strip() != '':
			text += line + '\n'

		return text

	def command(self, args, msg=None):
		# TODO When containers/routes become more integrated, just look at the
		#      container the message was sent to, which shoudl work for the
		#      default container as well.
		target = self.config.get('target', self._hal.objects.modules.keys())
		target = [t for t in target if t.split('/')[0] != self.name] # Can't sync send to this module

		if args == '':
			self.reply(msg, body=self.general_help(target))
		else:

			hmsg = Message(body=args.split(' '), type='help', origin=self.name)