Skip to content

Commit

Permalink
Fix HubotResponder role and add a debug method
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Bales committed Oct 19, 2012
1 parent 5a7d336 commit 251c7c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "hubot-do",
"version": "0.0.2f",
"version": "0.0.3",
"author": "arbales",
"keywords": "github do do.com hubot adapter",
"description": "A Do adapter for hubot",
Expand Down
21 changes: 12 additions & 9 deletions src/do.coffee
Expand Up @@ -8,6 +8,8 @@ ENV = process.env
Client = require './client'
{PushManager, AccountManager, HubotResponder} = require './roles'

debug = if ENV.DO_HUBOT_DEBUG is 'true' then console.log else (->)

class DoAdapter extends Adapter

# Public: Raw method for sending data back to the chat source. Extend this.
Expand All @@ -17,8 +19,8 @@ class DoAdapter extends Adapter
#
# Returns nothing.
send: (user, strings...) ->
for string in string
@client.send string, user
for string in strings
@client.sendMessage string, user

# Public: Raw method for building a reply and sending it back to the chat
# source. Extend this.
Expand All @@ -45,30 +47,31 @@ class DoAdapter extends Adapter
clientID : ENV.HUBOT_DO_CLIENT_ID
clientSecret : ENV.HUBOT_DO_CLIENT_SECRET

client.on 'authorization:succeess', ->
console.log "Authentication succeeded."
client.on 'authorization:success', ->
debug "Authentication succeeded."
client.fetchAccount()

client.on 'request:complete', ->
console.log "Request Completed."
client.on 'request:complete', (request, response) ->
debug response.text

client.on 'account:create', ->
console.log "Account fetched."
debug "Account fetched."
client.connectPush()

client.on 'push:connect', ->
console.log "Push Connected"
debug "Push Connected"
@emit 'connected'

client.on 'TextMessage', (message) =>
console.log message
debug message.text
unless @robot.name == message.creator.name
@receive new TextMessage(@userForMessage(message), message.text)

client.authenticate
username : ENV.HUBOT_DO_USERNAME
password : ENV.HUBOT_DO_PASSWORD

@client = client

@

Expand Down
3 changes: 1 addition & 2 deletions src/roles.coffee
Expand Up @@ -14,7 +14,7 @@ AccountManager =
HubotResponder =
sendMessage: (message, user) ->
@post("/workspaces/#{user.room.workspace_id}/rooms/#{user.room.id}/chats")
.send({text: string})
.send({text: message})
.end()

receiveMessage: (message) ->
Expand All @@ -39,7 +39,6 @@ PushManager =
# connection manager since there might be a stale session.
incoming: (message, callback) =>
if message.channel == '/meta/subscribe' && !message.successful
# Do.connection.check()
@emit 'message:fail'
callback message

Expand Down

0 comments on commit 251c7c2

Please sign in to comment.