Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents c29a191 + 48f2513 commit 06d8d143a407ce64bff86b8b73e4e145e6ec39ba @atmos atmos committed Dec 7, 2011
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/adapters/campfire.coffee
@@ -15,6 +15,10 @@ class Campfire extends Adapter
reply: (user, strings...) ->
@send user, strings.map((str) -> "#{user.name}: #{str}")...
+ topic: (user, strings...) ->
+ @bot.Room(user.room).topic strings.join(" / "), (err, data) =>
+ @robot.logger.error "Campfire error: #{err}" if err?
+
run: ->
self = @
@@ -108,6 +112,10 @@ class CampfireStreaming extends EventEmitter
paste: (text, callback) ->
@message text, "PasteMessage", callback
+ topic: (text, callback) ->
+ body = {room: {topic: text}}
+ self.put "/room/#{id}", body, callback
+
sound: (text, callback) ->
@message text, "SoundMessage", callback
@@ -184,7 +192,12 @@ class CampfireStreaming extends EventEmitter
post: (path, body, callback) ->
@request "POST", path, body, callback
+ put: (path, body, callback) ->
+ @request "PUT", path, body, callback
+
request: (method, path, body, callback) ->
+ logger = @robot.logger
+
headers =
"Authorization" : @authorization
"Host" : @domain
@@ -198,7 +211,7 @@ class CampfireStreaming extends EventEmitter
"method" : method
"headers": headers
- if method is "POST"
+ if method is "POST" || method is "PUT"
if typeof(body) isnt "string"
body = JSON.stringify body
@@ -228,7 +241,7 @@ class CampfireStreaming extends EventEmitter
logger.error "Campfire response error: #{err}"
callback err, { }
- if method is "POST"
+ if method is "POST" || method is "PUT"
request.end(body, 'binary')
else
request.end()

0 comments on commit 06d8d14

Please sign in to comment.