ruboty-xmpp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/lib/ruboty/adapters/xmpp.rb +102 -0
- data/lib/ruboty/xmpp.rb +2 -0
- data/lib/ruboty/xmpp/version.rb +5 -0
- data/ruboty-xmpp.gemspec +24 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 62f6203d248a8d5e174fcfeb28fb459ad330dc25
|
4
|
+
data.tar.gz: b83a197c77ac921330316ff996890bda5c081d71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e71039b390dc7315fca35ffa7cd5c92a659ddbaf9db89373bf7bb5238ff74d87d4a62606ead1a8dee5808bdaad08d156f96ed73f0b26cdf862384a1b4470545
|
7
|
+
data.tar.gz: fc7e86f68b3e5f15687c631d0cb3cbd13689bcccf9ca9c87eac6b42f0e142900c37ab2905178740229edbdf42fa0972ac0ec5f5ea13b5a0bf7b307a264ef0f21
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Toshinori Minami
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Ruboty::Xmpp
|
2
|
+
|
3
|
+
XMPP adapter for [Ruboty](https://github.com/r7kamura/ruboty).
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
# Gemfile
|
9
|
+
gem 'ruboty-xmpp'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install ruboty-xmpp
|
19
|
+
|
20
|
+
## ENV
|
21
|
+
|
22
|
+
```
|
23
|
+
RUBOTY_XMPP_USERNAME - JID (e.g. alice@wonderland.lit)
|
24
|
+
RUBOTY_XMPP_PASSWORD - Password
|
25
|
+
RUBOTY_XMPP_ROOMS - Comma separated room names to join in (e.g. dev@conference.jabber.example.org)
|
26
|
+
RUBOTY_XMPP_HOST - Optional, automatically determined from JID in absence
|
27
|
+
RUBOTY_XMPP_PORT - Optional, default: 5222
|
28
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require "xrc"
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Adapters
|
5
|
+
class Xmpp < Base
|
6
|
+
env :RUBOTY_XMPP_USERNAME, "JID (e.g. alice@wonderland.lit)"
|
7
|
+
env :RUBOTY_XMPP_PASSWORD, "Password"
|
8
|
+
env :RUBOTY_XMPP_ROOMS, "Comma separated room names to join in (e.g. dev@conference.jabber.example.org)."
|
9
|
+
env :RUBOTY_XMPP_HOST, "Optional, automatically determined from JID in absence", optional: true
|
10
|
+
env :RUBOTY_XMPP_PORT, "Optional, default: 5222", optional: true
|
11
|
+
|
12
|
+
def run
|
13
|
+
init
|
14
|
+
bind
|
15
|
+
connect
|
16
|
+
end
|
17
|
+
|
18
|
+
def say(message)
|
19
|
+
client.say(
|
20
|
+
body: message[:body],
|
21
|
+
from: message[:from],
|
22
|
+
to: message[:to].split("/")[0],
|
23
|
+
type: message[:original][:type],
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def client
|
30
|
+
@client ||= Xrc::Client.new(
|
31
|
+
jid: jid,
|
32
|
+
nickname: ruboty_name,
|
33
|
+
password: password,
|
34
|
+
room_jid: room_jids,
|
35
|
+
hosts: [host],
|
36
|
+
port: port,
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def init
|
41
|
+
ruboty_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def ruboty_name
|
45
|
+
ENV["RUBOTY_NAME"] ||= username
|
46
|
+
end
|
47
|
+
|
48
|
+
def jid
|
49
|
+
ENV["RUBOTY_XMPP_USERNAME"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def username
|
53
|
+
jid.split("@")[0]
|
54
|
+
end
|
55
|
+
|
56
|
+
def password
|
57
|
+
ENV["RUBOTY_XMPP_PASSWORD"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def room_jids
|
61
|
+
ENV["RUBOTY_XMPP_ROOMS"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def host
|
65
|
+
ENV["RUBOTY_XMPP_HOST"] ||= jid.split("@")[1]
|
66
|
+
end
|
67
|
+
|
68
|
+
def port
|
69
|
+
ENV["RUBOTY_XMPP_PORT"] ||= "5222"
|
70
|
+
end
|
71
|
+
|
72
|
+
def bind
|
73
|
+
client.on_private_message(&method(:on_message))
|
74
|
+
client.on_room_message(&method(:on_message))
|
75
|
+
end
|
76
|
+
|
77
|
+
def connect
|
78
|
+
client.connect
|
79
|
+
end
|
80
|
+
|
81
|
+
def on_message(message)
|
82
|
+
return if message.delayed?
|
83
|
+
robot.receive(
|
84
|
+
body: message.body,
|
85
|
+
from: message.from,
|
86
|
+
from_name: username_of(message),
|
87
|
+
to: message.to,
|
88
|
+
type: message.type,
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def username_of(message)
|
93
|
+
case message.type
|
94
|
+
when "groupchat"
|
95
|
+
Xrc::Jid.new(message.from).resource
|
96
|
+
else
|
97
|
+
Xrc::Jid.new(message.from).node
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/ruboty/xmpp.rb
ADDED
data/ruboty-xmpp.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/xmpp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-xmpp"
|
8
|
+
spec.version = Ruboty::Xmpp::VERSION
|
9
|
+
spec.authors = ["Toshinori Minami"]
|
10
|
+
spec.email = ["toshinoriminami@gmail.com"]
|
11
|
+
spec.summary = "XMPP adapter for Ruboty."
|
12
|
+
spec.homepage = "https://github.com/minamimonji/ruboty-xmpp"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "ruboty", ">= 1.0.4"
|
21
|
+
spec.add_dependency "xrc", ">= 0.0.6"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-xmpp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toshinori Minami
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xrc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- toshinoriminami@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/ruboty/adapters/xmpp.rb
|
82
|
+
- lib/ruboty/xmpp.rb
|
83
|
+
- lib/ruboty/xmpp/version.rb
|
84
|
+
- ruboty-xmpp.gemspec
|
85
|
+
homepage: https://github.com/minamimonji/ruboty-xmpp
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.4.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: XMPP adapter for Ruboty.
|
109
|
+
test_files: []
|