Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arttu Tervo
committed
Oct 31, 2011
1 parent
94dc791
commit 513f2e6
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Robot = require "../robot" | ||
flowdock = require "flowdock" | ||
|
||
class Flowdock extends Robot | ||
send: (user, strings...) -> | ||
strings.forEach (str) => | ||
@bot.chatMessage(user.flow.subdomain, user.flow.name, str) | ||
|
||
reply: (user, strings...) -> | ||
strings.forEach (str) => | ||
@send user, "#{user.name}: #{str}" | ||
|
||
run: -> | ||
self = @ | ||
options = | ||
login_email: process.env.HUBOT_FLOWDOCK_LOGIN_EMAIL | ||
login_password: process.env.HUBOT_FLOWDOCK_LOGIN_PASSWORD | ||
|
||
bot = new flowdock.Session(options.login_email, options.login_password) | ||
bot.fetchFlows((flows) => | ||
flows.forEach (flow) => | ||
bot.fetchUsers(flow.organization.subdomain, flow.slug, (users) => | ||
users.forEach (flow_user) => | ||
return if flow_user.user.disabled == true | ||
user = | ||
id: flow_user.user.id | ||
name: flow_user.user.nick | ||
@userForId(user.id, user) | ||
) | ||
bot.subscribe(flow.organization.subdomain, flow.slug) | ||
) | ||
|
||
bot.on "message", (message) => | ||
return unless message.event == 'message' | ||
flow = bot.flows.filter((flow) -> return flow.name == message.flow)[0] | ||
author = @userForId(message.user) | ||
author.flow = flow | ||
self.receive new Robot.TextMessage(author, message.content) | ||
|
||
@bot = bot | ||
|
||
module.exports = Flowdock |