Permalink
Browse files

Merge remote-tracking branch 'origin/master' into cmdline

Conflicts:
	bin/hubot
  • Loading branch information...
2 parents 31e3906 + 463dea0 commit 3a941322ba0ce01c76660abc1120b719550f77b0 @atmos atmos committed Nov 1, 2011
View
@@ -1,3 +1,22 @@
+v1.1.9
+======
+* Add a google talk adapter - Arlo Carreon <arlo.carreon@gmail.com>
+
+v1.1.8
+======
+* Fix a bug in robot.respond that allowed regexes to be constructed that
+ could be triggered without prefixing with the robot's name - atmos
+* Fixup rarely triggered response stuff that uses an undefined variable
+
+v1.1.7
+======
+* Fix username issues where campfire names weren't updated - atmos
+* Allow help files to parse from raw js - Jason Ford <jason@jason-ford.com>
+* Talkerapp bug fix ups - Charles Barbier <unixcharles@gmail.com>, Magnus Bergmark <magnus.bergmark@gmail.com>
+* Preserve ordering in campfire message sending - Sean Cribbs <sean@basho.com>
+* Flowdock adapter - Arttu Tervo <arttu.tervo@nodeta.fi>
+
+
v1.1.5
======
* Add a talkerapp adapter - Victor Castell <victorcoder@gmail.com>
View
@@ -13,7 +13,8 @@ Creator = require '../src/creator'
OptParse = require 'optparse'
PortNumber = parseInt(process.env.PORT) || 8080
-Adapters = ["irc", "campfire", "hipchat", "twilio", "xmpp", "groupme", "talker", "twitter", "cli"]
+Adapters = ["irc", "campfire", "hipchat", "twilio", "xmpp", "groupme", "talker", "twitter", "flowdock", "gtalk", "cli"]
+
Switches = [
[ "-h", "--help", "Display the help information"],
[ "-a", "--adapter ADAPTER", "The Adapter to use"],
View
@@ -1,6 +1,6 @@
{
"name": "hubot",
- "version": "1.1.4",
+ "version": "1.1.9",
"author": "hubot",
"keywords": "github hubot campfire bot",
"description": "A simple helpful Robot for your Company",
@@ -23,7 +23,8 @@
"irc": "0.2",
"node-xmpp": ">=0.2.6",
"wobot": "0.3.0",
- "imap": "0.2.5"
+ "imap": "0.2.5",
+ "flowdock": "0.2.x"
},
"main": "./index",
View
@@ -4,12 +4,13 @@ EventEmitter = require("events").EventEmitter
class Campfire extends Robot
send: (user, strings...) ->
- for str in strings
- @bot.Room(user.room).speak str, (err, data) ->
+ if strings.length > 0
+ @bot.Room(user.room).speak strings.shift(), (err, data) =>
console.log "campfire error: #{err}" if err
+ @send user, strings...
reply: (user, strings...) ->
- @send user, "#{user.name}: #{str}" for str in strings
+ @send user, strings.map((str) -> "#{user.name}: #{str}")...
run: ->
self = @
@@ -24,6 +25,8 @@ class Campfire extends Robot
bot.User user, (err, userData) ->
if userData.user
author = self.userForId(userData.user.id, userData.user)
+ self.brain.data.users[userData.user.id].name = userData.user.name
+ self.brain.data.users[userData.user.id].email_address = userData.user.email_address
author.room = room
callback id, created, room, user, body, author
@@ -187,7 +190,7 @@ class CampfireStreaming extends EventEmitter
if response.statusCode >= 400
switch response.statusCode
when 401 then throw new Error("Invalid access token provided, campfire refused the authentication")
- else console.log "campfire error: #{err}"
+ else console.log "campfire error: #{response.statusCode}"
try
View
@@ -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
View
@@ -0,0 +1,80 @@
+Robot = require '../robot'
+Xmpp = require 'node-xmpp'
+
+class Gtalkbot extends Robot
+ run: ->
+
+ # Client Options
+ options =
+ jid: process.env.HUBOT_GTALK_USERNAME
+ password: process.env.HUBOT_GTALK_PASSWORD
+ host: 'talk.google.com'
+ port: 5222
+ keepaliveInterval: 30000 # ms interval to send whitespace to xmpp server
+
+ # Connect to gtalk servers
+ @client = new Xmpp.Client options
+
+ # Events
+ @client.on 'online', @.online
+ @client.on 'stanza', @.read
+ @client.on 'error', @.error
+
+ # Log options
+ console.log options
+
+ # Share the optionss
+ @options = options
+
+ online: =>
+ @client.send new Xmpp.Element('presence')
+
+ # send raw whitespace for keepalive
+ setInterval =>
+ @client.send ' '
+ , @options.keepaliveInterval
+
+ # He is alive!
+ console.log @name + ' is online, talk.google.com!'
+
+ read: (stanza) =>
+ if stanza.attrs.type is 'error'
+ console.error '[xmpp error] - ' + stanza
+ return
+
+ # Make sure we have a message
+ return if !stanza.is 'message' or stanza.attrs.type not in ['groupchat', 'direct', 'chat']
+
+ # Strip the from attribute to get who this is from
+ [from, room] = stanza.attrs.from.split '/'
+ # ignore empty bodies (i.e., topic changes -- maybe watch these someday)
+ body = stanza.getChild 'body'
+ return unless body
+
+ message = body.getText()
+
+ # Pad the message with robot name just incase it was not provided.
+ message = if !message.match(new RegExp("^"+@name+":?","i")) then @name+" "+message else message
+
+ # Send the message to the robot
+ @receive new Robot.TextMessage from, message
+
+ send: (user, strings...) ->
+ for str in strings
+ message = new Xmpp.Element('message',
+ from: @options.username
+ to: user
+ type: 'chat'
+ ).
+ c('body').t(str)
+ # Send it off
+ @client.send message
+
+ reply: (user, strings...) ->
+ for str in strings
+ @send user, "#{str}"
+
+ error: (err) =>
+ console.error err
+
+module.exports = Gtalkbot
View
@@ -4,18 +4,16 @@ Irc = require "irc"
class IrcBot extends Robot
send: (user, strings...) ->
for str in strings
- do (str) ->
- if user.room
- console.log "#{user.room} #{str}"
- @bot.say(user.room, str)
- else
- console.log "#{user.name} #{str}"
- @bot.say(user.name, str)
+ if user.room
+ console.log "#{user.room} #{str}"
+ @bot.say(user.room, str)
+ else
+ console.log "#{user.name} #{str}"
+ @bot.say(user.name, str)
reply: (user, strings...) ->
for str in strings
- do (str) ->
- @send user, "#{user.name}: #{str}"
+ @send user, "#{user.name}: #{str}"
join: (channel) ->
self = @
@@ -44,6 +42,7 @@ class IrcBot extends Robot
debug: true,
port: options.port,
stripColors: true,
+ secure: if options.port is "6697" then true else false,
}
unless options.nickpass
@@ -60,8 +59,7 @@ class IrcBot extends Robot
bot.say 'NickServ', "identify #{options.nickpass}"
else if options.nickpass and from is 'NickServ' and text.indexOf('now identified') isnt -1
for room in options.rooms
- do (room) ->
- @join room
+ @join room
bot.addListener 'message', (from, to, message) ->
console.log "From #{from} to #{to}: #{message}"
@@ -65,10 +65,10 @@ getCode = (language,languages) ->
return code if lang.toLowerCase() is language.toLowerCase()
module.exports = (robot) ->
- robot.respond /(translate)( me)?(( from) ([a-z]*))?(( (in)?to) ([a-z]*))? (.*)/i, (msg) ->
- term = "\"#{msg.match[10]}\""
- origin = if msg.match[5] isnt undefined then getCode(msg.match[5], languages) else 'auto'
- target = if msg.match[9] isnt undefined then getCode(msg.match[9], languages) else 'en'
+ robot.respond /(?:translate)(?: me)?(?:(?: from) ([a-z]*))?(?:(?: (?:in)?to) ([a-z]*))? (.*)/i, (msg) ->
+ term = "\"#{msg.match[3]}\""
+ origin = if msg.match[1] isnt undefined then getCode(msg.match[1], languages) else 'auto'
+ target = if msg.match[2] isnt undefined then getCode(msg.match[2], languages) else 'en'
msg.http("http://translate.google.com/translate_a/t")
.query({
@@ -90,7 +90,7 @@ module.exports = (robot) ->
language =languages[parsed[2]]
parsed = parsed[0] && parsed[0][0] && parsed[0][0][0]
if parsed
- if msg.match[9] is undefined
+ if msg.match[2] is undefined
msg.send "#{term} is #{language} for #{parsed}"
else
msg.send "The #{language} #{term} translates as #{parsed} in #{languages[target]}"
Oops, something went wrong.

0 comments on commit 3a94132

Please sign in to comment.