Skip to content

Commit

Permalink
Merge pull request #101 from sonnyp/nxc3
Browse files Browse the repository at this point in the history
update node-xmpp-client to 3.0.0
  • Loading branch information
markstory committed Dec 24, 2015
2 parents 94c3438 + 043db89 commit c6a2a1f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
@@ -0,0 +1,11 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
6 changes: 6 additions & 0 deletions .npmignore
@@ -0,0 +1,6 @@
test/
.editorconfig
.gitignore
.npmignore
.travis.yml
Makefile
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -9,5 +9,6 @@ matrix:
- node_js: "4.0"
- node_js: "4.1"
- node_js: "4.2"
- node_js: "5"

sudo: false
4 changes: 2 additions & 2 deletions README.mdown
@@ -1,6 +1,6 @@
# Hubot XMPP

Connects Hubot to your XMPP network
Connects Hubot to your XMPP network

[![Build Status](https://secure.travis-ci.org/markstory/hubot-xmpp.png?branch=master)](http://travis-ci.org/markstory/hubot-xmpp)

Expand Down Expand Up @@ -33,7 +33,7 @@ Optional:

`HUBOT_XMPP_ROOMS` can be a comma separated list of rooms to join. If
your rooms require passwords you should use the `jid:password` syntax.
Room passwords cannot contain `,`. Room names must be the full jid of the
Room passwords cannot contain `,`. Room names must be the full jid of the
room for example `dev@conference.jabber.example.org`.

`HUBOT_XMPP_PM_ADD_PREFIX` works by prefixing the private message with hubot name, so a
Expand Down
12 changes: 5 additions & 7 deletions package.json
Expand Up @@ -12,11 +12,7 @@
"xmpp",
"adapter"
],
"licenses": [
{
"type": "MIT"
}
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/markstory/hubot-xmpp.git"
Expand All @@ -28,9 +24,11 @@
"test": "make test"
},
"main": "./src/xmpp",
"engine": "node > 0.6.0 < 0.13.0",
"engines": {
"node": ">=0.10"
},
"dependencies": {
"node-xmpp-client": "2.0.2"
"node-xmpp-client": "3.0.0"
},
"devDependencies": {
"coffee-script": "1.1.3",
Expand Down
16 changes: 5 additions & 11 deletions src/xmpp.coffee
@@ -1,9 +1,5 @@
{Adapter,Robot,TextMessage,EnterMessage,LeaveMessage} = require 'hubot'

XmppClient = require 'node-xmpp-client'
JID = XmppClient.JID
Stanza = XmppClient.Stanza
ltx = XmppClient.ltx
{JID, Stanza, Client, parse, Element} = require 'node-xmpp-client'
util = require 'util'

class XmppBot extends Adapter
Expand Down Expand Up @@ -63,7 +59,7 @@ class XmppBot extends Adapter
makeClient: () ->
options = @options

@client = new XmppClient
@client = new Client
reconnect: true
jid: options.username
password: options.password
Expand Down Expand Up @@ -401,13 +397,12 @@ class XmppBot extends Adapter
to: to
type: envelope.user?.type or 'groupchat'

# ltx.Element type
if msg.attrs?
if msg instanceof Element
message = msg.root()
message.attrs.to ?= params.to
message.attrs.type ?= params.type
else
parsedMsg = try new ltx.parse(msg)
parsedMsg = try parse(msg)
bodyMsg = new Stanza('message', params).
c('body').t(msg)
message = if parsedMsg?
Expand All @@ -422,8 +417,7 @@ class XmppBot extends Adapter

reply: (envelope, messages...) ->
for msg in messages
# ltx.Element?
if msg.attrs?
if msg instanceof Element
@send envelope, msg
else
@send envelope, "#{envelope.user.name}: #{msg}"
Expand Down
5 changes: 2 additions & 3 deletions test/adapter-test.coffee
@@ -1,6 +1,5 @@
Bot = require '../src/xmpp'
XmppClient = require 'node-xmpp-client'
ltx = XmppClient.ltx
{Element} = require 'node-xmpp-client'

{Adapter,Robot,EnterMessage,LeaveMessage,TextMessage} = require 'hubot'

Expand Down Expand Up @@ -739,7 +738,7 @@ describe 'XmppBot', ->
type: 'groupchat'
room: 'test@example.com'

el = new ltx.Element('message').c('body')
el = new Element('message').c('body')
.t('testing')

bot.client.send = (msg) ->
Expand Down

0 comments on commit c6a2a1f

Please sign in to comment.