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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1341e508fe9e3923c7afb7d3477b8fe8dab8b5ff
4
- data.tar.gz: 5cab7c7401b25624bb8ff2feb98d4067c6be5c36
3
+ metadata.gz: 5676126a816e9ba871336d489c7979f55e8b6f90
4
+ data.tar.gz: 90996f40decf4c0a954b4e347f7e30b9ac820618
5
5
  SHA512:
6
- metadata.gz: ddd093fc241c8d88a5e275dbf03fecebd9258a8d2adf30d91bfa12efe91826bf4c8902414af76a74e6eb99b7e29ac371e4cd21724592c1fe62d5d43011f52a06
7
- data.tar.gz: 615d61312b1c213d88d74e00f0578ff77b5371716b1ab673edbb09c7d906be1ee0cdfd6ebbde2b31c8f2495dd11794284f23080d5d232eef8596f8fd98b051a4
6
+ metadata.gz: 62bc7bb06c85d88a7f325e7fb6c9a551d9d5a9c413bad9835e01e24e0ca29d4e0061bf1db3beb6f8f2a1f27d389b16f75dddf09c9ae7f5b0bc685ea2c85ab262
7
+ data.tar.gz: 1d6d2f9356df824f476c8fa37c58c322352ed362d21b9f66b347917c9a4f9c9944931ddb69bf6313042e0ddc7ca6ee2f431720b9fcaa782aa1d957a2770e21a5
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # lita-xmpp
2
2
 
3
- WIP, probably has some bugs.
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 [HipChat](https://www.hipchat.com/).
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
 
@@ -1,6 +1,4 @@
1
1
  require "lita"
2
- require "lita/adapters/xmpp/html_message"
3
- require "lita/adapters/xmpp/notify_room"
4
2
  require "lita/adapters/xmpp/connector"
5
3
 
6
4
  module Lita
@@ -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.downcase.sub(/@.*/, '')
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 do |jid, item|
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.4"
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", "~> 2.0"
17
- spec.add_runtime_dependency "gmcmillan-xmpp4r", "~> 0.6.2"
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.3"
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
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: 2013-09-13 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
26
+ version: 3.3.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: gmcmillan-xmpp4r
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.2
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.2
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: '1.3'
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: '1.3'
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: '0'
151
+ version: 1.3.1
154
152
  requirements: []
155
153
  rubyforge_project:
156
- rubygems_version: 2.1.3
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