lita-xmpp 1.0.4 → 1.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/lita/adapters/xmpp.rb +0 -2
- data/lib/lita/adapters/xmpp/callback.rb +4 -9
- data/lib/lita/adapters/xmpp/connector.rb +1 -1
- data/lita-xmpp.gemspec +4 -4
- metadata +29 -31
- data/lib/lita/adapters/xmpp/html_message.rb +0 -52
- data/lib/lita/adapters/xmpp/notify_room.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5676126a816e9ba871336d489c7979f55e8b6f90
|
4
|
+
data.tar.gz: 90996f40decf4c0a954b4e347f7e30b9ac820618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62bc7bb06c85d88a7f325e7fb6c9a551d9d5a9c413bad9835e01e24e0ca29d4e0061bf1db3beb6f8f2a1f27d389b16f75dddf09c9ae7f5b0bc685ea2c85ab262
|
7
|
+
data.tar.gz: 1d6d2f9356df824f476c8fa37c58c322352ed362d21b9f66b347917c9a4f9c9944931ddb69bf6313042e0ddc7ca6ee2f431720b9fcaa782aa1d957a2770e21a5
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# lita-xmpp
|
2
2
|
|
3
|
-
|
3
|
+
If it works, cool. If it doesn't, there's always [HipChat](http://hipchat.com).
|
4
4
|
|
5
|
-
**lita-xmpp** is an adapter for [Lita](https://github.com/jimmycuadra/lita) that allows you to use the robot with
|
5
|
+
**lita-xmpp** is an adapter for [Lita](https://github.com/jimmycuadra/lita) that allows you to use the robot with XMPP.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
data/lib/lita/adapters/xmpp.rb
CHANGED
@@ -11,11 +11,10 @@ module Lita
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def private_message(client)
|
14
|
-
return
|
15
14
|
client.add_message_callback do |m|
|
16
15
|
next if m.type == :error || m.body.nil?
|
17
16
|
user = user_by_jid(m.from)
|
18
|
-
source = Source.new(user)
|
17
|
+
source = Source.new(user: user)
|
19
18
|
message = Message.new(robot, m.body, source)
|
20
19
|
message.command!
|
21
20
|
Lita.logger.debug("Dispatching PM to Lita from #{user.id}.")
|
@@ -30,7 +29,7 @@ module Lita
|
|
30
29
|
next
|
31
30
|
else
|
32
31
|
user = user_by_name(nick)
|
33
|
-
source = Source.new(user, muc.jid.bare.to_s)
|
32
|
+
source = Source.new(user: user, room: muc.jid.bare.to_s)
|
34
33
|
message = Message.new(robot, text, source)
|
35
34
|
Lita.logger.debug(
|
36
35
|
"Dispatching message to Lita from #{user.id} in MUC #{muc.jid}."
|
@@ -51,7 +50,7 @@ module Lita
|
|
51
50
|
private
|
52
51
|
|
53
52
|
def jid_without_domain(jid)
|
54
|
-
jid.to_s.
|
53
|
+
jid.to_s.sub(/@.*/, '')
|
55
54
|
end
|
56
55
|
|
57
56
|
def create_user(user_data)
|
@@ -69,12 +68,8 @@ module Lita
|
|
69
68
|
end
|
70
69
|
|
71
70
|
def user_by_name(name)
|
72
|
-
name = name.to_s.downcase
|
73
71
|
Lita.logger.info("Looking up user with name: #{name}.")
|
74
|
-
items = roster.items.detect
|
75
|
-
Lita.logger.debug("Checking #{jid}: #{jid_without_domain(jid)} => #{name}.")
|
76
|
-
jid_without_domain(jid) == name || jid_without_domain(jid).sub(/\./, ' ') == name
|
77
|
-
end
|
72
|
+
items = roster.items.detect { |jid, item| jid_without_domain(jid) == name }
|
78
73
|
|
79
74
|
if items
|
80
75
|
Lita.logger.info("Looking up user by jid: #{items.first}.")
|
@@ -39,7 +39,7 @@ module Lita
|
|
39
39
|
def join_rooms(muc_domain, rooms)
|
40
40
|
rooms.each do |room_name|
|
41
41
|
muc = Jabber::MUC::SimpleMUCClient.new(client)
|
42
|
-
room_jid = normalized_jid(room_name, muc_domain, robot.name)
|
42
|
+
room_jid = normalized_jid(room_name, muc_domain.dup, robot.name)
|
43
43
|
mucs[room_jid.bare.to_s] = muc
|
44
44
|
register_muc_message_callback(muc)
|
45
45
|
Lita.logger.info("Joining room: #{room_jid}.")
|
data/lita-xmpp.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-xmpp"
|
3
|
-
spec.version = "1.0.
|
3
|
+
spec.version = "1.1.0.pre"
|
4
4
|
spec.authors = ["Justin Mazzi"]
|
5
5
|
spec.email = ["jmazzi@gmail.com"]
|
6
6
|
spec.description = %q{A XMPP adapter for Lita.}
|
@@ -13,10 +13,10 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
14
|
spec.require_paths = ["lib"]
|
15
15
|
|
16
|
-
spec.add_runtime_dependency "lita", "~>
|
17
|
-
spec.add_runtime_dependency "
|
16
|
+
spec.add_runtime_dependency "lita", "~> 3.3.1"
|
17
|
+
spec.add_runtime_dependency "xmpp4r", "~> 0.5.6"
|
18
18
|
|
19
|
-
spec.add_development_dependency "bundler", "~> 1.
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.7.2"
|
20
20
|
spec.add_development_dependency "rake"
|
21
21
|
spec.add_development_dependency "rspec", "~> 2.14"
|
22
22
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-xmpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Mazzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.3.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.3.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: xmpp4r
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.6
|
33
|
+
version: 0.5.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.6
|
40
|
+
version: 0.5.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.7.2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.7.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.14'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.14'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: coveralls
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: A XMPP adapter for Lita.
|
@@ -115,8 +115,8 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .travis.yml
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
120
|
- Gemfile
|
121
121
|
- LICENSE
|
122
122
|
- README.md
|
@@ -125,8 +125,6 @@ files:
|
|
125
125
|
- lib/lita/adapters/xmpp.rb
|
126
126
|
- lib/lita/adapters/xmpp/callback.rb
|
127
127
|
- lib/lita/adapters/xmpp/connector.rb
|
128
|
-
- lib/lita/adapters/xmpp/html_message.rb
|
129
|
-
- lib/lita/adapters/xmpp/notify_room.rb
|
130
128
|
- lib/lita/encoding_patches.rb
|
131
129
|
- lita-xmpp.gemspec
|
132
130
|
- spec/lita/adapters/hipchat/callback_spec.rb
|
@@ -143,17 +141,17 @@ require_paths:
|
|
143
141
|
- lib
|
144
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
143
|
requirements:
|
146
|
-
- -
|
144
|
+
- - ">="
|
147
145
|
- !ruby/object:Gem::Version
|
148
146
|
version: '0'
|
149
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
148
|
requirements:
|
151
|
-
- -
|
149
|
+
- - ">"
|
152
150
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
151
|
+
version: 1.3.1
|
154
152
|
requirements: []
|
155
153
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.2.2
|
157
155
|
signing_key:
|
158
156
|
specification_version: 4
|
159
157
|
summary: A XMPP adapter for the Lita chat robot.
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'xmpp4r'
|
2
|
-
|
3
|
-
module Lita
|
4
|
-
module Adapters
|
5
|
-
# Usage:
|
6
|
-
#
|
7
|
-
# h = HtmlMessage.new
|
8
|
-
# h.add_text = "Hi"
|
9
|
-
#
|
10
|
-
# Or:
|
11
|
-
#
|
12
|
-
# HtmlMessage.new { add_text "hi" }
|
13
|
-
class HtmlMessage
|
14
|
-
include ::Jabber
|
15
|
-
attr_reader :body, :doc
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
@doc = REXML::Element::new("html")
|
19
|
-
@body = REXML::Element::new("body")
|
20
|
-
|
21
|
-
build
|
22
|
-
|
23
|
-
yield(self) if block_given?
|
24
|
-
end
|
25
|
-
|
26
|
-
def message
|
27
|
-
doc.add body
|
28
|
-
doc
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_text(str)
|
32
|
-
text = REXML::Text.new("#{str}", false, nil, true, nil, %r/.^/)
|
33
|
-
body.add text
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_link(text, url)
|
37
|
-
link = REXML::Element.new('a')
|
38
|
-
link.add_attribute('href', url)
|
39
|
-
link.text = text
|
40
|
-
|
41
|
-
body.add link
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def build
|
47
|
-
doc.add_namespace('http://jabber.org/protocol/xhtml-im')
|
48
|
-
body.add_namespace('http://www.w3.org/1999/xhtml')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Lita
|
2
|
-
module Adapters
|
3
|
-
module NotifyRoom
|
4
|
-
def send_html_message_to_room(string, room)
|
5
|
-
muc_domain = Lita.config.adapter.muc_domain
|
6
|
-
target = Source.new(nil, "#{room}@#{muc_domain}")
|
7
|
-
adapter = robot.instance_variable_get('@adapter')
|
8
|
-
|
9
|
-
begin
|
10
|
-
adapter.send_raw_messages(target, string)
|
11
|
-
rescue => e
|
12
|
-
puts e.backtrace.join("\n")
|
13
|
-
puts :error
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def send_message_to_room(string, room)
|
18
|
-
muc_domain = Lita.config.adapter.muc_domain
|
19
|
-
target = Source.new(nil, "#{room}@#{muc_domain}")
|
20
|
-
robot.send_message(target, string)
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_raw_message(string)
|
24
|
-
message = Jabber::Message::new.set_type(:groupchat)
|
25
|
-
message.add_element string
|
26
|
-
message
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|