Permalink
Browse files

Remove adapters with npm packages now

  • Loading branch information...
1 parent 53bd377 commit a2b4e67cd231ca8b8f534e41a45fb8733b524926 Tom Bell committed Nov 27, 2011
@@ -1,44 +0,0 @@
-Robot = require('hubot').robot()
-Adapter = require('hubot').adapter()
-
-flowdock = require 'flowdock'
-
-class Flowdock extends Adapter
- send: (user, strings...) ->
- for str in strings
- @bot.chatMessage(user.flow.subdomain, user.flow.name, str)
-
- reply: (user, strings...) ->
- for str in strings
- @send user, "#{user.name}: #{str}"
-
- run: ->
- 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)
- return if @name == author.name
- author.flow = flow
- @receive new Robot.TextMessage(author, message.content)
-
- @bot = bot
-
-module.exports = Flowdock
@@ -1,131 +0,0 @@
-Robot = require('hubot').robot()
-Adapter = require('hubot').adapter()
-
-HTTPS = require 'https'
-Wobot = require('wobot').Bot
-
-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: process.env.HUBOT_HIPCHAT_JID
- name: process.env.HUBOT_HIPCHAT_NAME or "#{self.name} Bot"
- password: process.env.HUBOT_HIPCHAT_PASSWORD
- rooms: process.env.HUBOT_HIPCHAT_ROOMS or "@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 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
- console.log "Can't list rooms: #{err}"
- else
- for room_id in @options.rooms.split(',')
- console.log "Joining #{room_id}"
- bot.join room_id
-
- @get "/v1/users/list", (err, response) ->
- if response
- for user in response.users
- 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.TextMessage(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 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
- 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 or { }
- response.on "error", (err) ->
- callback err, { }
-
- if method is "POST"
- request.end(body, 'binary')
- else
- request.end()
-
- request.on "error", (err) ->
- console.log err
- console.log err.stack
- callback err
-
-exports.use = (robot) ->
- new HipChat robot
-
@@ -1,109 +0,0 @@
-Robot = require('hubot').robot()
-Adapter = require('hubot').adapter()
-
-Irc = require 'irc'
-
-class IrcBot extends Adapter
- send: (user, strings...) ->
- for str in strings
- 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
- @send user, "#{user.name}: #{str}"
-
- join: (channel) ->
- self = @
- @bot.join channel, () ->
- console.log('joined %s', channel)
-
- part: (channel) ->
- @bot.part channel, () ->
- console.log('left %s', channel)
-
- run: ->
- self = @
-
- options =
- nick: process.env.HUBOT_IRC_NICK or @robot.name
- port: process.env.HUBOT_IRC_PORT
- rooms: process.env.HUBOT_IRC_ROOMS.split(",")
- server: process.env.HUBOT_IRC_SERVER
- password: process.env.HUBOT_IRC_PASSWORD
- nickpass: process.env.HUBOT_IRC_NICKSERV_PASSWORD
- fakessl: process.env.HUBOT_IRC_SERVER_FAKE_SSL?
- unflood: process.env.HUBOT_IRC_UNFLOOD?
- debug: process.env.HUBOT_IRC_DEBUG?
- usessl: process.env.HUBOT_IRC_USESSL?
-
- client_options =
- password: options.password,
- debug: options.debug,
- port: options.port,
- stripColors: true,
- secure: options.usessl,
- selfSigned: options.fakessl,
- floodProtection: options.unflood
-
- client_options['channels'] = options.rooms unless options.nickpass
-
- bot = new Irc.Client options.server, options.nick, client_options
-
- next_id = 1
- user_id = {}
-
- if options.nickpass?
- bot.addListener 'notice', (from, to, text) ->
- if from is 'NickServ' and text.indexOf('registered') isnt -1
- bot.say 'NickServ', "identify #{options.nickpass}"
- else if options.nickpass and from is 'NickServ' and text.indexOf('Password accepted') isnt -1
- for room in options.rooms
- @join room
-
- bot.addListener 'message', (from, to, message) ->
- console.log "From #{from} to #{to}: #{message}"
-
- user = self.userForName from
- unless user?
- id = (new Date().getTime() / 1000).toString().replace('.','')
- user = self.userForId id
- user.name = from
-
- if to.match(/^[&#]/)
- user.room = to
- console.log "#{to} <#{from}> #{message}"
- else
- user.room = null
- console.log "msg <#{from}> #{message}"
-
- self.receive new Robot.TextMessage(user, message)
-
- bot.addListener 'error', (message) ->
- console.error('ERROR: %s: %s', message.command, message.args.join(' '))
-
- bot.addListener 'pm', (nick, message) ->
- console.log('Got private message from %s: %s', nick, message)
-
- bot.addListener 'join', (channel, who) ->
- console.log('%s has joined %s', who, channel)
-
- bot.addListener 'part', (channel, who, reason) ->
- console.log('%s has left %s: %s', who, channel, reason)
-
- bot.addListener 'kick', (channel, who, _by, reason) ->
- console.log('%s was kicked from %s by %s: %s', who, channel, _by, reason)
-
- bot.addListener 'invite', (channel, from) ->
- console.log('%s invite you to join %s', from, channel)
- bot.join channel
-
- @bot = bot
-
-exports.use = (robot) ->
- new IrcBot robot
-
Oops, something went wrong.

8 comments on commit a2b4e67

Hi! So if we want to improve these adapters, where can we get the source?

Contributor

tombell replied Nov 28, 2011

You'll need to find the repository for the adapter. Hopefully people will update the wiki for each adapter with a link to the repos.

If an adapter hasn't been removed from third-party yet, it means there is no external package for it yet and needs someone who contributed to it to create a package outside of hubot.

Contributor

atmos replied Nov 28, 2011

Oh, man. The @hipchat guys wanted to maintain their stuff. I wonder if we can get @warorface to move his adapter over there.

@atmos I don't have any issue with that but since they didn't upload theirs I did it. Do I transfer it now or wait until they ask (or have one)?

Contributor

atmos replied Nov 28, 2011

I'll hit them up and have em give you access. Thanks, man!

I should have seen this thread earlier. :) Thanks for being the mediator, @atmos. @warorface - I've added you to the hipchat/hubot-hipchat repo.

@tombell - Thanks. I've alrady took the liberty to update the wiki pages before I forget.

Contributor

paulcbetts replied Nov 29, 2011

The history for the IRC client didn't get migrated over :-/ It's not a huge deal, but in the future we can probably do this better with some judicious use of git-filter-branch.

Please sign in to comment.