-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'testssss' into redis-brain
- Loading branch information
Showing
19 changed files
with
511 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
v1.0.5 | ||
====== | ||
|
||
* Remove infinite loop script to keep things alive - atmos | ||
|
||
v1.0.4 | ||
====== | ||
|
||
* HipChat adapter support - Assaf Arkin <assaf@labnotes.org> | ||
* XMPP adapter support - Andy Fowler <andy@andyfowler.com> | ||
* Twilio adapter fixups - Jesse Newland <jesse@jnewland.com> | ||
* Fixup hubot-scripts.json template examples - Mike Skalnik <mike.skalnik@gmail.com> | ||
|
||
v1.0.3 | ||
====== | ||
|
||
* Fix IRC adapter replies - Scott Moak <scott.moak@gmail.com> | ||
* Ensure people are running node 0.4.x - Corey Donohoe <atmos@atmos.org> | ||
* Doc fixups - Aitor García Rey <aitor@linkingpaths.com> | ||
* Twilio adapter support - Tom Bell <tomb@tombell.org.uk> |
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
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,125 @@ | ||
Robot = require "robot" | ||
HTTPS = require "https" | ||
Wobot = require("wobot").Bot | ||
|
||
class HipChat extends Robot | ||
send: (user, strings...) -> | ||
console.log "Sending" | ||
strings.forEach (str) => | ||
@bot.message user.reply_to, str | ||
|
||
reply: (user, strings...) -> | ||
console.log "Replying" | ||
strings.forEach (str) => | ||
@send user, "@#{user.name} #{str}" | ||
|
||
run: -> | ||
self = @ | ||
@options = | ||
token: process.env.HUBOT_HIPCHAT_TOKEN | ||
jid: process.env.HUBOT_HIPCHAT_JID | ||
name: process.env.HUBOT_HIPCHAT_NAME || "#{self.name} Bot" | ||
password: process.env.HUBOT_HIPCHAT_PASSWORD | ||
rooms: process.env.HUBOT_HIPCHAT_ROOMS || "@All" | ||
|
||
console.log "Options:", @options | ||
bot = new Wobot(jid: @options.jid, name: @options.name, password: @options.password) | ||
mention = new RegExp("@#{@options.name.split(' ')[0]}\\b", "i") | ||
console.log mention | ||
console.log "Bot:", bot | ||
|
||
bot.onConnect => | ||
console.log "Connected to HipChat" | ||
if @options.rooms == "@All" | ||
@get "/v1/rooms/list", (err, response)-> | ||
if response | ||
response.rooms.forEach (room)-> | ||
console.log "Joining #{room.xmpp_jid}" | ||
bot.join room.xmpp_jid | ||
else | ||
console.log "Can't list rooms: #{err}" | ||
else | ||
@options.rooms.split(',').forEach (room_id)-> | ||
console.log "Joining #{room_id}" | ||
bot.join room_id | ||
@get "/v1/users/list", (err, response)-> | ||
if response | ||
response.users.forEach (user)-> | ||
self.userForId user.user_id, user | ||
else | ||
console.log "Can't list rooms: #{err}" | ||
bot.onError (message)-> | ||
# If HipChat sends an error, we get the error message from XMPP. | ||
# Otherwise, we get an Error object from the Node connection. | ||
if message.message | ||
console.log "Error talking to HipChat:", message.message | ||
else | ||
console.log "Received error from HipChat:", message | ||
bot.onMessage (channel, from, message)-> | ||
author = { name: from, reply_to: channel } | ||
hubot_msg = message.replace(mention, "#{self.name}: ") | ||
self.receive new Robot.Message(author, hubot_msg) | ||
bot.onPrivateMessage (from, message)=> | ||
user = self.userForId(from.match(/_(\d+)@/)[1]) | ||
author = { name: user.name, reply_to: from } | ||
self.receive new Robot.TextMessage(author, "#{self.name}: #{message}") | ||
bot.connect() | ||
|
||
@bot = bot | ||
|
||
|
||
# Convenience HTTP Methods for posting on behalf of the token"d user | ||
get: (path, callback) -> | ||
@request "GET", path, null, callback | ||
|
||
post: (path, body, callback) -> | ||
@request "POST", path, body, callback | ||
|
||
request: (method, path, body, callback) -> | ||
console.log method, path, body | ||
headers = { "Host": "api.hipchat.com" } | ||
|
||
options = | ||
"agent" : false | ||
"host" : "api.hipchat.com" | ||
"port" : 443 | ||
"path" : path | ||
"method" : method | ||
"headers": headers | ||
|
||
if method == "POST" | ||
body.auth_token = @options.token | ||
body = JSON.stringify(body) | ||
headers["Content-Type"] = "application/json" | ||
|
||
body = new Buffer(body) | ||
options.headers["Content-Length"] = body.length | ||
else | ||
options.path += "?auth_token=#{@options.token}" | ||
|
||
request = HTTPS.request options, (response) -> | ||
data = "" | ||
response.on "data", (chunk) -> | ||
data += chunk | ||
response.on "end", -> | ||
if response.statusCode >= 400 | ||
console.log "hipchat error: #{response.statusCode}" | ||
|
||
try | ||
callback null, JSON.parse(data) | ||
catch err | ||
callback null, data || { } | ||
response.on "error", (err) -> | ||
callback err, { } | ||
|
||
if method == "POST" | ||
request.end(body, 'binary') | ||
else | ||
request.end() | ||
|
||
request.on "error", (err) -> | ||
console.log err | ||
console.log err.stack | ||
callback err | ||
|
||
exports.HipChat = HipChat |
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 |
---|---|---|
@@ -1,16 +1,24 @@ | ||
# Interacts with the Google Maps API. | ||
# | ||
# map me <query> - Returns a map view of the area returned by `query`. | ||
|
||
module.exports = (robot) -> | ||
robot.hear /(?:(satellite|terrain|hybrid)[- ])?map me (.+)/i, (msg) -> | ||
|
||
robot.respond /(?:(satellite|terrain|hybrid)[- ])?map me (.+)/i, (msg) -> | ||
mapType = msg.match[1] || "roadmap" | ||
location = msg.match[2] | ||
url = "http://maps.google.com/maps/api/staticmap?markers=" + | ||
mapUrl = "http://maps.google.com/maps/api/staticmap?markers=" + | ||
escape(location) + | ||
"&size=400x400&maptype=" + | ||
mapType + | ||
"&sensor=false" + | ||
"&format=png" # So campfire knows it's an image | ||
url = "http://maps.google.com/maps?q=" + | ||
escape(location) + | ||
"&hl=en&sll=37.0625,-95.677068&sspn=73.579623,100.371094&vpsrc=0&hnear=" + | ||
escape(location) + | ||
"&t=m&z=11" | ||
|
||
msg.send mapUrl | ||
msg.send url | ||
|
Oops, something went wrong.