id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 00e5bf306fe1287a182fb8ef3b9511f429024340 | 661 | https://github.com/hipchat/hubot-hipchat/blob/00e5bf306fe1287a182fb8ef3b9511f429024340/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 00e5bf306fe1287a182fb8ef3b9511f429024340 | 661 | https://github.com/hipchat/hubot-hipchat/blob/00e5bf306fe1287a182fb8ef3b9511f429024340/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 00e5bf306fe1287a182fb8ef3b9511f429024340 | 661 | https://github.com/hipchat/hubot-hipchat/blob/00e5bf306fe1287a182fb8ef3b9511f429024340/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | host: @options.host
)
console.log "Wobot object:", bot
bot.onConnect =>
console.log "Connected to HipChat as @#{bot.mention_name}!"
# Provide our name to Hubot
self.robot.name = bot.mention_name
# Tell Hubot we're connected so it can load scripts
self.emit "connected"
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 00e5bf306fe1287a182fb8ef3b9511f429024340 | 661 | https://github.com/hipchat/hubot-hipchat/blob/00e5bf306fe1287a182fb8ef3b9511f429024340/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | bot.join room_jid
# Fetch user info
bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error,... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c3bef7111a595710b35609ac658b4711d95bc3c1 | 661 | https://github.com/hipchat/hubot-hipchat/blob/c3bef7111a595710b35609ac658b4711d95bc3c1/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | bot.join room_jid
# Fetch user info
bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error,... | self.receive new TextMessage(author, hubot_msg)
bot.onPrivateMessage (from, message) ->
author = self.userForId(self.userIdFromJid(from))
author.reply_to = from
self.receive new TextMessage(author, "#{bot.mention_name}: #{message}")
# Join rooms automatically when invited
bot.onInvite (r... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c3bef7111a595710b35609ac658b4711d95bc3c1 | 661 | https://github.com/hipchat/hubot-hipchat/blob/c3bef7111a595710b35609ac658b4711d95bc3c1/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | return jid.match(/^\d+_(.+)@conf\./)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
# 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, c... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c3bef7111a595710b35609ac658b4711d95bc3c1 | 661 | https://github.com/hipchat/hubot-hipchat/blob/c3bef7111a595710b35609ac658b4711d95bc3c1/src/hipchat.coffee | 107 | 156 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | return jid.match(/^\d+_(.+)@conf\./)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
# 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, c... | "path" : path
"method" : method
"headers": headers
if method is "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
option... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c3bef7111a595710b35609ac658b4711d95bc3c1 | 661 | https://github.com/hipchat/hubot-hipchat/blob/c3bef7111a595710b35609ac658b4711d95bc3c1/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:raw_corpus | raw_corpus | callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary')
else
request.end()
request.on "error", (err) ->
console.log err
console.log err.stack
callback err | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c3bef7111a595710b35609ac658b4711d95bc3c1 | 661 | https://github.com/hipchat/hubot-hipchat/blob/c3bef7111a595710b35609ac658b4711d95bc3c1/src/hipchat.coffee | 157 | 169 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:4:completion | completion | callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary') | else
request.end()
request.on "error", (err) ->
console.log err
console.log err.stack
callback err | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c3bef7111a595710b35609ac658b4711d95bc3c1 | 661 | https://github.com/hipchat/hubot-hipchat/blob/c3bef7111a595710b35609ac658b4711d95bc3c1/src/hipchat.coffee | 157 | 169 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | bot.join room_jid
# Fetch user info
bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error,... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | bot.join room_jid
# Fetch user info
bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error,... | self.receive new TextMessage(author, hubot_msg)
bot.onPrivateMessage (from, message) ->
author = self.userForId(self.userIdFromJid(from))
author.reply_to = from
author.room = self.roomNameFromJid(from)
self.receive new TextMessage(author, "#{bot.mention_name}: #{message}")
# Join rooms... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
# 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", pa... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 107 | 156 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
# Convenience HTTP Methods for posting on behalf of the token"d user
get: (path, callback) ->
@request "GET", path, null, callback
... | var e;
try {
return jid.match(/^\d+_([\w_\.-]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
return null;
}
({
// Convenience HTTP Methods for posting on behalf of the token"d user
get: function(path, callback) {
return this.request("GET", path, null, callback);
},
post... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var e;
try {
return jid.match(/^\d+_([\w_\.-]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
return null;
}
({
// Convenience HTTP Methods for posting on behalf of the token"d user
get: function(path, callback) {
return... | try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
# 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", pa... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
# 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", pa... | "port" : 443
"path" : path
"method" : method
"headers": headers
if method is "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
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:raw_corpus | raw_corpus | catch err
callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary')
else
request.end()
request.on "error", (err) ->
console.log err
console.log err.stack
callback err | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 157 | 170 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:4:completion | completion | catch err
callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary') | else
request.end()
request.on "error", (err) ->
console.log err
console.log err.stack
callback err | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2113c53f13ecdd931b654c129dd9062710b186a6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/2113c53f13ecdd931b654c129dd9062710b186a6/src/hipchat.coffee | 157 | 170 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | f82d5cbeac88874c6d42b8d28d09ac0779c24c34 | 661 | https://github.com/hipchat/hubot-hipchat/blob/f82d5cbeac88874c6d42b8d28d09ac0779c24c34/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | f82d5cbeac88874c6d42b8d28d09ac0779c24c34 | 661 | https://github.com/hipchat/hubot-hipchat/blob/f82d5cbeac88874c6d42b8d28d09ac0779c24c34/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | f82d5cbeac88874c6d42b8d28d09ac0779c24c34 | 661 | https://github.com/hipchat/hubot-hipchat/blob/f82d5cbeac88874c6d42b8d28d09ac0779c24c34/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | host: @options.host
)
console.log "Wobot object:", bot
bot.onConnect =>
console.log "Connected to HipChat as @#{bot.mention_name}!"
# Provide our name to Hubot
self.robot.name = bot.mention_name
# Tell Hubot we're connected so it can load scripts
self.emit "connected"
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | f82d5cbeac88874c6d42b8d28d09ac0779c24c34 | 661 | https://github.com/hipchat/hubot-hipchat/blob/f82d5cbeac88874c6d42b8d28d09ac0779c24c34/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | debug: @options.debug == 'true',
host: @options.host
)
mention = new RegExp("@#{@options.name.replace(' ', '')}\\b", "i")
console.log mention
console.log "Bot:", bot
bot.onConnect =>
console.log "Connected to HipChat"
# Join requested rooms
if @options.rooms is "All"
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error, we get the error message from XMPP.
# Othe... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends a... | bot.getRoster(function(err, users, stanza) {
var i, len, results, user;
if (users) {
results = [];
for (i = 0, len = users.length; i < len; i++) {
user = users[i];
results.push(self.userForId(self.userIdFromJid(user.jid), user));
}
return results;
} else {
return console.log(`Can't... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
bot.getRoster(function(err, users, stanza) {
var i, len, results, user;
if (users) {
results = [];
for (i = 0, len = users.length; i < len; i++) {
user = users[i];
results.push(self.userForId(self.userIdFromJid(user.jid), user));
}
r... | bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error, we get the error message from XMPP.
# Othe... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | bot.getRoster (err, users, stanza) ->
if users
for user in users
self.userForId self.userIdFromJid(user.jid), user
else
console.log "Can't list users: #{err}"
bot.onError (message) ->
# If HipChat sends an error, we get the error message from XMPP.
# Othe... | author.reply_to = from
author.room = self.roomNameFromJid(from)
self.receive new TextMessage(author, "#{self.robot.name}: #{message}")
# Join rooms automatically when invited
bot.onInvite (room_jid, from_jid, message) =>
console.log "Got invite to #{room_jid} from #{from_jid} - joining"
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | headers = "Host": host
unless @options.token
callback "No API token provided to Hubot", null
return
options =
"agent" : false
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @o... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 107 | 156 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | headers = "Host": host
unless @options.token
callback "No API token provided to Hubot", null
return
options =
"agent" : false
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @o... | data = ""
response.on "data", (chunk) ->
data += chunk
response.on "end", ->
if response.statusCode >= 400
console.log "HipChat API error: #{response.statusCode}"
try
callback null, JSON.parse(data)
catch err
callback null, data or { }
res... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:raw_corpus | raw_corpus | try
return jid.match(/^\d+_(\d+)@/)[1]
catch e
console.log "Bad user JID: #{jid}"
return null
roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 157 | 168 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
try
return jid.match(/^\d+_(\d+)@/)[1]
catch e
console.log "Bad user JID: #{jid}"
return null
roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
retu... | var e;
try {
return jid.match(/^\d+_(\d+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad user JID: ${jid}`);
return null;
}
({
roomNameFromJid: function(jid) {
try {
return jid.match(/^\d+_([\w_\.-]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 157 | 168 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var e;
try {
return jid.match(/^\d+_(\d+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad user JID: ${jid}`);
return null;
}
({
roomNameFromJid: function(jid) {
try {
return jid.match(/^\d+_([\w_\.-]+)@/)[1];
} catch (error) {
e... | try
return jid.match(/^\d+_(\d+)@/)[1]
catch e
console.log "Bad user JID: #{jid}"
return null
roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 157 | 168 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:completion | completion | try
return jid.match(/^\d+_(\d+)@/)[1]
catch e
console.log "Bad user JID: #{jid}"
return null | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 0f5f5353ce475458940edbcf995df2d4f281b923 | 661 | https://github.com/hipchat/hubot-hipchat/blob/0f5f5353ce475458940edbcf995df2d4f281b923/src/hipchat.coffee | 157 | 168 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | bot.onConnect =>
console.log "Connected to HipChat"
# Join requested rooms
if @options.rooms is "All"
bot.getRooms (err, rooms, stanza) ->
if rooms
for room in rooms
console.log "Joining #{room.jid}"
bot.join room.jid
else
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | 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:", mes... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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
els... | bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} else {
return console.log("Received error from HipCh... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} e... | 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:", mes... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | 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:", mes... | console.log "Got invite to #{room_jid} from #{from_jid} - joining"
bot.join room_jid
bot.connect()
@bot = bot
self.emit "connected"
# Convenience HTTP Methods for posting on behalf of the token"d user
get: (path, callback) ->
@request "GET", path, null, callback
post: (path, body, callb... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | options =
"agent" : false
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 107 | 156 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
options =
"agent" : false
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Con... | var body, options, request;
options = {
"agent": false,
"host": host,
"port": 443,
"path": path,
"method": method,
"headers": headers
};
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "application/json";
body = new Buffer(body)... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var body, options, request;
options = {
"agent": false,
"host": host,
"port": 443,
"path": path,
"method": method,
"headers": headers
};
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content... | options =
"agent" : false
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | options =
"agent" : false
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer... | console.log "HipChat API error: #{response.statusCode}"
try
callback null, JSON.parse(data)
catch err
callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary')
else
request.end()
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:raw_corpus | raw_corpus | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 157 | 162 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
``` | ({
roomNameFromJid: function(jid) {
var e;
try {
return jid.match(/^\d+_([\w_\.-]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
return null;
}
}
}); | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 157 | 162 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
roomNameFromJid: function(jid) {
var e;
try {
return jid.match(/^\d+_([\w_\.-]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
return null;
}
}
});
``` | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 157 | 162 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:completion | completion | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.-]+)@/)[1] | catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 26a1ccb1b0fcb8bac8925d98aafb861103402a28 | 661 | https://github.com/hipchat/hubot-hipchat/blob/26a1ccb1b0fcb8bac8925d98aafb861103402a28/src/hipchat.coffee | 157 | 162 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2dd93afab97dd38f697beb4e6357052039279efc | 661 | https://github.com/hipchat/hubot-hipchat/blob/2dd93afab97dd38f697beb4e6357052039279efc/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2dd93afab97dd38f697beb4e6357052039279efc | 661 | https://github.com/hipchat/hubot-hipchat/blob/2dd93afab97dd38f697beb4e6357052039279efc/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2dd93afab97dd38f697beb4e6357052039279efc | 661 | https://github.com/hipchat/hubot-hipchat/blob/2dd93afab97dd38f697beb4e6357052039279efc/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@#{user.name.replace(' ', '')} #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
... | bot.onConnect =>
console.log "Connected to HipChat"
# Join requested rooms
if @options.rooms is "@All"
bot.getRooms (err, rooms, stanza) ->
if rooms
for room in rooms
console.log "Joining #{room.jid}"
bot.join room.jid
else
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 2dd93afab97dd38f697beb4e6357052039279efc | 661 | https://github.com/hipchat/hubot-hipchat/blob/2dd93afab97dd38f697beb4e6357052039279efc/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | 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:", mes... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579 | 661 | https://github.com/hipchat/hubot-hipchat/blob/dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579/src/hipchat.coffee | 55 | 104 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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
els... | bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} else {
return console.log("Received error from HipCh... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579 | 661 | https://github.com/hipchat/hubot-hipchat/blob/dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579/src/hipchat.coffee | 55 | 104 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} e... | 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:", mes... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579 | 661 | https://github.com/hipchat/hubot-hipchat/blob/dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579/src/hipchat.coffee | 55 | 104 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | 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:", mes... | console.log "Got invite to #{room_jid} from #{from_jid} - joining"
bot.join room_jid
bot.connect()
@bot = bot
self.emit "connected"
# Convenience HTTP Methods for posting on behalf of the token"d user
get: (path, callback) ->
@request "GET", path, null, callback
post: (path, body, callb... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579 | 661 | https://github.com/hipchat/hubot-hipchat/blob/dd71c91dd2c602cd76e1c4f9cd6f6dfd8b3f6579/src/hipchat.coffee | 55 | 104 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 9688b99c38c156719aa0b26f0d4fe200a2f396d6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/9688b99c38c156719aa0b26f0d4fe200a2f396d6/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 9688b99c38c156719aa0b26f0d4fe200a2f396d6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/9688b99c38c156719aa0b26f0d4fe200a2f396d6/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 9688b99c38c156719aa0b26f0d4fe200a2f396d6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/9688b99c38c156719aa0b26f0d4fe200a2f396d6/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password... | bot.onConnect =>
console.log "Connected to HipChat"
# Join requested rooms
if @options.rooms is "@All"
bot.getRooms (err, rooms, stanza) ->
if rooms
for room in rooms
console.log "Joining #{room.jid}"
bot.join room.jid
else
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 9688b99c38c156719aa0b26f0d4fe200a2f396d6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/9688b99c38c156719aa0b26f0d4fe200a2f396d6/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a | 661 | https://github.com/hipchat/hubot-hipchat/blob/7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a | 661 | https://github.com/hipchat/hubot-hipchat/blob/7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a | 661 | https://github.com/hipchat/hubot-hipchat/blob/7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password... | bot.onConnect =>
console.log "Connected to HipChat"
# Join requested rooms
if @options.rooms is "@All"
bot.getRooms (err, rooms, stanza) ->
if rooms
for room in rooms
console.log "Joining #{room.jid}"
bot.join room.jid
else
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a | 661 | https://github.com/hipchat/hubot-hipchat/blob/7186a2c3c8d37f5a4dd62c351457b5cb77ea0e9a/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:raw_corpus | raw_corpus | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c1009383e8d951c73826959aa52c6c0bd7d5f3bf | 661 | https://github.com/hipchat/hubot-hipchat/blob/c1009383e8d951c73826959aa52c6c0bd7d5f3bf/src/hipchat.coffee | 157 | 162 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null
``` | ({
roomNameFromJid: function(jid) {
var e;
try {
return jid.match(/^\d+_([\w_\.]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
return null;
}
}
}); | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c1009383e8d951c73826959aa52c6c0bd7d5f3bf | 661 | https://github.com/hipchat/hubot-hipchat/blob/c1009383e8d951c73826959aa52c6c0bd7d5f3bf/src/hipchat.coffee | 157 | 162 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
roomNameFromJid: function(jid) {
var e;
try {
return jid.match(/^\d+_([\w_\.]+)@/)[1];
} catch (error) {
e = error;
console.log(`Bad room JID: ${jid}`);
return null;
}
}
});
``` | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c1009383e8d951c73826959aa52c6c0bd7d5f3bf | 661 | https://github.com/hipchat/hubot-hipchat/blob/c1009383e8d951c73826959aa52c6c0bd7d5f3bf/src/hipchat.coffee | 157 | 162 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:completion | completion | roomNameFromJid: (jid) ->
try
return jid.match(/^\d+_([\w_\.]+)@/)[1] | catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | c1009383e8d951c73826959aa52c6c0bd7d5f3bf | 661 | https://github.com/hipchat/hubot-hipchat/blob/c1009383e8d951c73826959aa52c6c0bd7d5f3bf/src/hipchat.coffee | 157 | 162 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | 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:", mes... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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
els... | bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} else {
return console.log("Received error from HipCh... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} e... | 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:", mes... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | 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:", mes... | console.log "Got invite to #{room_jid} from #{from_jid} - joining"
bot.join room_jid
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"... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 107 | 156 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
... | var body, request;
({
"host": host({
"port": 443,
"path": path,
"method": method,
"headers": headers
})
});
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "application/json";
body = new Buffer(body);
options.headers["... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var body, request;
({
"host": host({
"port": 443,
"path": path,
"method": method,
"headers": headers
})
});
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "applicatio... | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | callback null, JSON.parse(data)
catch err
callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary')
else
request.end()
request.on "error", (err) ->
console.log err
console.log err.stac... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 107 | 156 |
hipchat/hubot-hipchat:src/hipchat.coffee:4:raw_corpus | raw_corpus | return jid.match(/^\d+_([\w_\.]+)@/)[1]
catch e
console.log "Bad room JID: #{jid}"
return null | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 157 | 160 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:4:completion | completion | return jid.match(/^\d+_([\w_\.]+)@/)[1]
catch e | console.log "Bad room JID: #{jid}"
return null | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9 | 661 | https://github.com/hipchat/hubot-hipchat/blob/14badadfb9aeccf33670d6bc6ec126eaa3c4f0d9/src/hipchat.coffee | 157 | 160 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | 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:", mes... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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
els... | bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} else {
return console.log("Received error from HipCh... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
bot.onError(function(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) {
return console.log("Error talking to HipChat:", message.message);
} e... | 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:", mes... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | 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:", mes... | console.log "Got invite to #{room_jid} from #{from_jid} - joining"
bot.join room_jid
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"... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 57 | 106 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 107 | 152 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
... | var body, request;
({
"host": host({
"port": 443,
"path": path,
"method": method,
"headers": headers
})
});
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "application/json";
body = new Buffer(body);
options.headers["... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 107 | 152 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var body, request;
({
"host": host({
"port": 443,
"path": path,
"method": method,
"headers": headers
})
});
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "applicatio... | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 107 | 152 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | try
callback null, JSON.parse(data)
catch err
callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary')
else
request.end()
request.on "error", (err) ->
console.log err
consol... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6 | 661 | https://github.com/hipchat/hubot-hipchat/blob/e4473ca6c29f7f3f92eb009b84d333e6ecd47ac6/src/hipchat.coffee | 107 | 152 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:raw_corpus | raw_corpus | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 216fa542ca965e9c33ce32dcc758eb7ed10aba69 | 661 | https://github.com/hipchat/hubot-hipchat/blob/216fa542ca965e9c33ce32dcc758eb7ed10aba69/src/hipchat.coffee | 107 | 152 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
"host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
... | var body, request;
({
"host": host({
"port": 443,
"path": path,
"method": method,
"headers": headers
})
});
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "application/json";
body = new Buffer(body);
options.headers["... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 216fa542ca965e9c33ce32dcc758eb7ed10aba69 | 661 | https://github.com/hipchat/hubot-hipchat/blob/216fa542ca965e9c33ce32dcc758eb7ed10aba69/src/hipchat.coffee | 107 | 152 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var body, request;
({
"host": host({
"port": 443,
"path": path,
"method": method,
"headers": headers
})
});
if (method === "POST") {
body.auth_token = this.options.token;
body = JSON.stringify(body);
headers["Content-Type"] = "applicatio... | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 216fa542ca965e9c33ce32dcc758eb7ed10aba69 | 661 | https://github.com/hipchat/hubot-hipchat/blob/216fa542ca965e9c33ce32dcc758eb7ed10aba69/src/hipchat.coffee | 107 | 152 |
hipchat/hubot-hipchat:src/hipchat.coffee:3:completion | completion | "host" : host
"port" : 443
"path" : path
"method" : method
"headers": headers
if method is "POST"
body.auth_token = @options.token
body = JSON.stringify(body)
headers["Content-Type"] = "application/json"
body = new Buffer(body)
options.headers["Content-L... | try
callback null, JSON.parse(data)
catch err
callback null, data or { }
response.on "error", (err) ->
callback err, null
if method is "POST"
request.end(body, 'binary')
else
request.end()
request.on "error", (err) ->
console.log err
consol... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 216fa542ca965e9c33ce32dcc758eb7ed10aba69 | 661 | https://github.com/hipchat/hubot-hipchat/blob/216fa542ca965e9c33ce32dcc758eb7ed10aba69/src/hipchat.coffee | 107 | 152 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:raw_corpus | raw_corpus | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
token: process.env.HUBOT_HIPCHAT_TOKEN
jid: ... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 6b228eb74e84f0430a7e086bb083d53e954a12eb | 661 | https://github.com/hipchat/hubot-hipchat/blob/6b228eb74e84f0430a7e086bb083d53e954a12eb/src/hipchat.coffee | 7 | 56 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
... | var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str));
}
return results;
}
reply(user, ...strin... | CoffeeScript | JavaScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 6b228eb74e84f0430a7e086bb083d53e954a12eb | 661 | https://github.com/hipchat/hubot-hipchat/blob/6b228eb74e84f0430a7e086bb083d53e954a12eb/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var HipChat;
HipChat = class HipChat extends Adapter {
send(user, ...strings) {
var i, len, results, str;
results = [];
for (i = 0, len = strings.length; i < len; i++) {
str = strings[i];
results.push(this.bot.message(user.reply_to, str))... | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
token: process.env.HUBOT_HIPCHAT_TOKEN
jid: ... | JavaScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 6b228eb74e84f0430a7e086bb083d53e954a12eb | 661 | https://github.com/hipchat/hubot-hipchat/blob/6b228eb74e84f0430a7e086bb083d53e954a12eb/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:1:completion | completion | class HipChat extends Adapter
send: (user, strings...) ->
for str in strings
@bot.message user.reply_to, str
reply: (user, strings...) ->
for str in strings
@send user, "@\"#{user.name}\" #{str}"
run: ->
self = @
@options =
token: process.env.HUBOT_HIPCHAT_TOKEN
jid: ... | bot.onConnect =>
console.log "Connected to HipChat"
if @options.rooms is "@All"
@get "/v1/rooms/list", (err, response) ->
if response
for room in response.rooms
console.log "Joining #{room.xmpp_jid}"
bot.join room.xmpp_jid
else
... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 6b228eb74e84f0430a7e086bb083d53e954a12eb | 661 | https://github.com/hipchat/hubot-hipchat/blob/6b228eb74e84f0430a7e086bb083d53e954a12eb/src/hipchat.coffee | 7 | 56 |
hipchat/hubot-hipchat:src/hipchat.coffee:2:raw_corpus | raw_corpus | # 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 = (self.userForName from) or {}
... | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 6b228eb74e84f0430a7e086bb083d53e954a12eb | 661 | https://github.com/hipchat/hubot-hipchat/blob/6b228eb74e84f0430a7e086bb083d53e954a12eb/src/hipchat.coffee | 57 | 106 | ||
hipchat/hubot-hipchat:src/hipchat.coffee:2:completion | completion | # 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 = (self.userForName from) or {}
... | @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
host = ... | CoffeeScript | CoffeeScript | hipchat/hubot-hipchat | src/hipchat.coffee | MIT | 6b228eb74e84f0430a7e086bb083d53e954a12eb | 661 | https://github.com/hipchat/hubot-hipchat/blob/6b228eb74e84f0430a7e086bb083d53e954a12eb/src/hipchat.coffee | 57 | 106 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.