 RocketBot.alias = 'bot'
 RocketBot.adapter = new RocketChatAdapter RocketBot
 HubotScripts(RocketBot)
+RocketBot.run()
 
 RocketBot.hear /test/i, (res) ->
 	res.send "Test? TESTING? WE DON'T NEED NO TEST, EVERYTHING WORKS!"


class HubotScripts
	constructor: (robot) ->
		Npm.require('hubot-scripts/src/scripts/hello.coffee')(robot)

		# # load all scripts in scripts/
		# console.log path.resolve '.'

	#
	# Returns nothing
	play: (envelope, strings...) ->
		console.log 'ROCKETCHATADAPTER -> play'.blue

	# Public: Raw method for invoking the bot to run. Extend this.
	#
	# Returns nothing.
	run: ->
		console.log 'ROCKETCHATADAPTER -> run'.blue
		@robot.emit 'connected'
		@robot.brain.mergeData {}
		# @robot.brain.emit 'loaded'

	# Public: Raw method for shutting the bot down. Extend this.
	#
	# Returns nothing.
	close: ->
		console.log 'ROCKETCHATADAPTER -> close'.blue

class RocketBotReceiver
	constructor: (message) ->
		console.log message
		if message.u.username isnt RocketBot.name
			RocketBotUser = new Hubot.User(message.u.username, room: message.rid)
			RocketBotTextMessage = new Hubot.TextMessage(RocketBotUser, message.msg, message._id)
