lita-tox 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,36 +2,11 @@ Lita::Adapters::Tox
2
2
  ===================
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/lita-tox.svg)](http://badge.fury.io/rb/lita-tox)
5
- [![Build Status](https://travis-ci.org/braiden-vasco/lita-tox.svg)](https://travis-ci.org/braiden-vasco/lita-tox)
6
- [![Coverage Status](https://coveralls.io/repos/braiden-vasco/lita-tox/badge.svg)](https://coveralls.io/r/braiden-vasco/lita-tox)
5
+ [![Build Status](https://travis-ci.org/toxon/lita-tox.svg)](https://travis-ci.org/toxon/lita-tox)
6
+ [![Coverage Status](https://coveralls.io/repos/github/toxon/lita-tox/badge.svg)](https://coveralls.io/github/toxon/lita-tox)
7
7
 
8
8
  [Tox](https://tox.chat) adapter for the [Lita](http://lita.io) chat bot.
9
9
 
10
- **WARNING**
11
-
12
- Still in development. Read the README carefully.
13
-
14
-
15
- TODO
16
- ----
17
-
18
- Current development version have some limitations
19
- which should be fixed in first release:
20
-
21
- * [\[issue #16\]](https://github.com/braiden-vasco/lita-tox/issues/16)
22
- **libtoxcore** is not included in the gem. It should be compiled manually
23
- to build the gem native extension successfully. Follow the instructions in
24
- [that file](https://github.com/irungentoo/toxcore/blob/2ab3b14731061cc04d3ccc50a35093c11d018298/INSTALL.md)
25
-
26
- * [\[issue #17\]](https://github.com/braiden-vasco/lita-tox/issues/17)
27
- JRuby is not supported. Only C extension for Tox is implemented
28
-
29
- * [\[issue #18\]](https://github.com/braiden-vasco/lita-tox/issues/18)
30
- Message length is limited to value of `TOX_MAX_MESSAGE_LENGTH`
31
- (see [source code of **libtoxcore**](https://github.com/irungentoo/toxcore/blob/2ab3b14731061cc04d3ccc50a35093c11d018298/toxcore/tox.h#L252-L255))
32
-
33
- * Adapter has incomplete API for Lita. Only basic methods are implemented
34
-
35
10
 
36
11
  Usage
37
12
  -----
@@ -48,7 +23,7 @@ When **libtoxcore** is installed, add **lita-tox**
48
23
  to your Lita instance's Gemfile:
49
24
 
50
25
  ```ruby
51
- gem 'lita-tox', '~> 0.3.0'
26
+ gem 'lita-tox', '~> 0.4.0'
52
27
  ```
53
28
 
54
29
  ### Configuration
@@ -74,7 +49,7 @@ Lita.configure do |config|
74
49
 
75
50
  config.robot.adapter = :tox
76
51
 
77
- config.savedata_filename = 'savedata'
78
- config.status = "Send me \"#{config.robot.name}: help\""
52
+ config.adapters.tox.savedata_filename = 'savedata'
53
+ config.adapters.tox.status = "Send me \"#{config.robot.name}: help\""
79
54
  end
80
55
  ```
data/Rakefile CHANGED
@@ -1,37 +1,34 @@
1
- require 'rubygems'
2
-
3
- gemspec = Gem::Specification.load('lita-tox.gemspec')
4
-
5
- github_user, github_project =
6
- gemspec.homepage.scan(%r{^https://github\.com/([^/]+)/([^/]+)/?$})[0]
1
+ # frozen_string_literal: true
7
2
 
8
3
  require 'bundler/gem_tasks'
9
4
 
10
- task default: [:spec, :lint]
5
+ GEMSPEC = Gem::Specification.load 'lita-tox.gemspec'
11
6
 
12
- require 'rspec/core/rake_task'
13
- RSpec::Core::RakeTask.new
14
-
15
- task lint: [:rubocop]
7
+ github_user, github_project =
8
+ GEMSPEC.homepage.scan(%r{^https://github\.com/([^/]+)/([^/]+)/?$})[0]
16
9
 
17
- require 'rubocop/rake_task'
18
- RuboCop::RakeTask.new
10
+ task default: %i[spec lint]
19
11
 
20
- require 'yard'
21
- YARD::Rake::YardocTask.new
12
+ task lint: :rubocop
22
13
 
23
- desc 'Generate changelog'
24
- task :changelog, [:token] do |_t, args|
25
- cmd = 'github_changelog_generator'
26
- cmd << " -u #{github_user}"
27
- cmd << " -p #{github_project}"
28
- cmd << " -t #{args[:token]}" if args[:token]
14
+ task fix: 'rubocop:auto_correct'
29
15
 
30
- sh cmd
16
+ begin
17
+ require 'rspec/core/rake_task'
18
+ RSpec::Core::RakeTask.new
19
+ rescue LoadError
20
+ nil
31
21
  end
32
22
 
33
- require 'rake/extensiontask'
23
+ begin
24
+ require 'rubocop/rake_task'
25
+ RuboCop::RakeTask.new
26
+ rescue LoadError
27
+ nil
28
+ end
34
29
 
35
- Rake::ExtensionTask.new 'tox' do |ext|
36
- ext.lib_dir = 'lib/tox'
30
+ desc 'Generate changelog'
31
+ task :changelog, [:token] do |_t, args|
32
+ raise 'please provide access token' unless args[:token]
33
+ sh "github_changelog_generator -u #{github_user} -p #{github_project} -t #{args[:token]}"
37
34
  end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ pushd 'vendor/libsodium'
8
+ ./autogen.sh
9
+ ./configure
10
+ make install
11
+ popd
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ pushd 'vendor/libtoxcore'
8
+ autoreconf -i
9
+ ./configure
10
+ make install
11
+ popd
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'lita-tox'
@@ -0,0 +1 @@
1
+ /savedata
data/example/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'lita', '~> 4.7'
6
+
7
+ gem 'lita-tox', path: '..'
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ lita-tox (0.3.0)
5
+ lita (~> 4.7)
6
+ tox (~> 0.0.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ faraday (0.12.1)
12
+ multipart-post (>= 1.2, < 3)
13
+ http_router (0.11.2)
14
+ rack (>= 1.0.0)
15
+ url_mount (~> 0.2.1)
16
+ i18n (0.8.6)
17
+ ice_nine (0.11.2)
18
+ lita (4.7.1)
19
+ bundler (>= 1.3)
20
+ faraday (>= 0.8.7)
21
+ http_router (>= 0.11.2)
22
+ i18n (>= 0.6.9)
23
+ ice_nine (>= 0.11.0)
24
+ multi_json (>= 1.7.7)
25
+ puma (>= 2.7.1)
26
+ rack (>= 1.5.2, < 2.0.0)
27
+ rb-readline (>= 0.5.1)
28
+ redis-namespace (>= 1.3.0)
29
+ thor (>= 0.18.1)
30
+ multi_json (1.12.1)
31
+ multipart-post (2.0.0)
32
+ puma (3.9.1)
33
+ rack (1.6.8)
34
+ rb-readline (0.5.4)
35
+ redis (3.3.3)
36
+ redis-namespace (1.5.3)
37
+ redis (~> 3.0, >= 3.0.4)
38
+ thor (0.19.4)
39
+ tox (0.0.1)
40
+ url_mount (0.2.1)
41
+ rack
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ lita (~> 4.7)
48
+ lita-tox!
49
+
50
+ BUNDLED WITH
51
+ 1.13.6
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ Lita.configure do |config|
4
+ config.robot.name = 'Lita'
5
+
6
+ config.robot.adapter = :tox
7
+
8
+ config.adapters.tox.savedata_filename = 'savedata'
9
+ config.adapters.tox.status = "Send me \"#{config.robot.name}: help\""
10
+ end
data/lib/lita-tox.rb CHANGED
@@ -1,4 +1,20 @@
1
- # rubocop:disable Style/FileName
1
+ # frozen_string_literal: true
2
+
3
+ # lita-tox - Tox adapter for the Lita chat bot
4
+ # Copyright (C) 2015-2017 Braiden Vasco
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
2
18
 
3
19
  require 'lita'
4
20
 
@@ -1,3 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lita-tox - Tox adapter for the Lita chat bot
4
+ # Copyright (C) 2015-2017 Braiden Vasco
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+
1
19
  require 'tox'
2
20
 
3
21
  ##
@@ -15,54 +33,42 @@ module Lita
15
33
  config :savedata_filename, type: String
16
34
  config :status, type: String
17
35
 
18
- def initialize(robot)
36
+ def initialize(robot) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
19
37
  super
20
38
 
21
39
  options = ::Tox::Options.new
22
40
 
23
41
  if config.savedata_filename && File.exist?(config.savedata_filename)
24
42
  savedata_file = open(config.savedata_filename)
25
- options.data = savedata_file.read
43
+ options.savedata = savedata_file.read
26
44
  savedata_file.close
27
45
  end
28
46
 
29
- @tox = ::Tox.new(options)
47
+ @tox = ::Tox::Client.new(options)
48
+
49
+ log.info("ID: #{@tox.address.to_hex}")
30
50
 
31
- log.info("ID: #{@tox.id}")
51
+ @tox.bootstrap_official
32
52
 
33
53
  @tox.name = robot.name if robot.name
34
54
  @tox.status_message = config.status if config.status
35
55
 
36
- @tox.on_friend_request do |key|
37
- @tox.friend_add_norequest(key)
56
+ @tox.on_friend_request do |public_key|
57
+ @tox.friend_add_norequest(public_key)
38
58
  end
39
59
 
40
- @tox.on_friend_message do |friend_number, text|
41
- user = User.new(friend_number)
60
+ @tox.on_friend_message do |friend, text|
61
+ user = User.new(friend.number)
42
62
  source = Source.new(user: user)
43
63
  message = Message.new(robot, text, source)
44
64
 
45
65
  message.command!
46
66
  robot.receive(message)
47
67
  end
48
-
49
- @tox.on_group_invite do |friend_number, data|
50
- @tox.join_groupchat(friend_number, data)
51
- end
52
-
53
- @tox.on_group_message do |group_number, peer_number, text|
54
- unless @tox.group_peernumber_is_ours(group_number, peer_number)
55
- user = User.new(-1 - peer_number) # TODO
56
- source = Source.new(user: user, room: group_number)
57
- message = Message.new(robot, text, source)
58
-
59
- robot.receive(message)
60
- end
61
- end
62
68
  end
63
69
 
64
70
  def run
65
- @tox.loop
71
+ @tox.run
66
72
  end
67
73
 
68
74
  def shut_down
@@ -72,16 +78,12 @@ module Lita
72
78
  savedata_file.close
73
79
  end
74
80
 
75
- @tox.kill
81
+ @tox.stop
76
82
  end
77
83
 
78
84
  def send_messages(target, messages)
79
85
  messages.reject(&:empty?).each do |message|
80
- if target.user.id.to_i >= 0
81
- @tox.friend_send_message(target.user.id.to_i, message)
82
- else
83
- @tox.group_message_send(target.room.to_i, message)
84
- end
86
+ ::Tox::Friend.new(@tox, target.user.id.to_i).send_message(message)
85
87
  end
86
88
  end
87
89
  end
data/lita-tox.gemspec CHANGED
@@ -1,38 +1,42 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__).freeze
5
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
2
6
 
3
7
  Gem::Specification.new do |spec|
4
- spec.name = 'lita-tox'
5
- spec.version = '0.3.0'
6
- spec.authors = ['Braiden Vasco']
7
- spec.email = ['braiden-vasco@mailtor.net']
8
+ spec.name = 'lita-tox'
9
+ spec.version = '0.4.0'
10
+ spec.license = 'GPL-3.0'
11
+ spec.homepage = 'https://github.com/toxon/lita-tox'
12
+ spec.summary = 'Tox adapter for the Lita chat bot'
13
+ spec.platform = Gem::Platform::RUBY
14
+
15
+ spec.authors = ['Braiden Vasco']
16
+ spec.email = %w[braiden-vasco@users.noreply.github.com]
8
17
 
9
- spec.summary = 'Tox adapter for the Lita chat bot'
10
- spec.description = 'Tox adapter for the Lita chat bot.'
11
- spec.homepage = 'https://github.com/braiden-vasco/lita-tox'
12
- spec.license = 'MIT'
18
+ spec.required_ruby_version = '~> 2.3'
19
+
20
+ spec.description = 'Tox adapter for the Lita chat bot.'
13
21
 
14
22
  spec.metadata['lita_plugin_type'] = 'adapter'
15
23
 
16
24
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
25
+ f.match %r{^(test|spec|features)/}
18
26
  end
19
27
 
20
- spec.bindir = 'exe'
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ['lib']
23
-
24
- spec.extensions << 'ext/tox/extconf.rb'
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep %r{^exe/}, &File.method(:basename)
25
30
 
26
- spec.add_development_dependency 'bundler', '~> 1.7'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rubocop', '~> 0.31'
29
- spec.add_development_dependency 'rspec', '~> 3.3'
30
- spec.add_development_dependency 'simplecov', '~> 0.10'
31
- spec.add_development_dependency 'yard', '~> 0.8'
32
- spec.add_development_dependency 'redcarpet', '~> 3.3'
31
+ spec.add_development_dependency 'bundler', '~> 1.7'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rubocop', '~> 0.49.1'
34
+ spec.add_development_dependency 'rspec', '~> 3.3'
35
+ spec.add_development_dependency 'simplecov', '~> 0.10'
36
+ spec.add_development_dependency 'redcarpet', '~> 3.3'
33
37
  spec.add_development_dependency 'github_changelog_generator', '~> 1.6'
34
- spec.add_development_dependency 'rake-compiler', '~> 0.9'
35
- spec.add_development_dependency 'pry', '~> 0.10'
38
+ spec.add_development_dependency 'pry', '~> 0.10'
36
39
 
37
- spec.add_runtime_dependency 'lita', '~> 4.4'
40
+ spec.add_runtime_dependency 'lita', '~> 4.7'
41
+ spec.add_runtime_dependency 'tox', '~> 0.0.1'
38
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-tox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braiden Vasco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-15 00:00:00.000000000 Z
11
+ date: 2017-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.31'
47
+ version: 0.49.1
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: '0.31'
54
+ version: 0.49.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.10'
83
- - !ruby/object:Gem::Dependency
84
- name: yard
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.8'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.8'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: redcarpet
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -123,56 +109,56 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '1.6'
125
111
  - !ruby/object:Gem::Dependency
126
- name: rake-compiler
112
+ name: pry
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '0.9'
117
+ version: '0.10'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '0.9'
124
+ version: '0.10'
139
125
  - !ruby/object:Gem::Dependency
140
- name: pry
126
+ name: lita
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '0.10'
146
- type: :development
131
+ version: '4.7'
132
+ type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '0.10'
138
+ version: '4.7'
153
139
  - !ruby/object:Gem::Dependency
154
- name: lita
140
+ name: tox
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '4.4'
145
+ version: 0.0.1
160
146
  type: :runtime
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '4.4'
152
+ version: 0.0.1
167
153
  description: Tox adapter for the Lita chat bot.
168
154
  email:
169
- - braiden-vasco@mailtor.net
155
+ - braiden-vasco@users.noreply.github.com
170
156
  executables: []
171
- extensions:
172
- - ext/tox/extconf.rb
157
+ extensions: []
173
158
  extra_rdoc_files: []
174
159
  files:
175
160
  - ".gitignore"
161
+ - ".gitmodules"
176
162
  - ".rspec"
177
163
  - ".rubocop.yml"
178
164
  - ".simplecov"
@@ -183,18 +169,21 @@ files:
183
169
  - LICENSE
184
170
  - README.md
185
171
  - Rakefile
172
+ - bin/build/libsodium
173
+ - bin/build/libtoxcore
186
174
  - bin/console
187
175
  - bin/setup
188
- - ext/tox/extconf.rb
189
- - ext/tox/tox.c
176
+ - example/.gitignore
177
+ - example/Gemfile
178
+ - example/Gemfile.lock
179
+ - example/lita_config.rb
190
180
  - lib/lita-tox.rb
191
181
  - lib/lita/adapters/tox.rb
192
- - lib/tox.rb
193
182
  - lita-tox.gemspec
194
183
  - locales/en.yml
195
- homepage: https://github.com/braiden-vasco/lita-tox
184
+ homepage: https://github.com/toxon/lita-tox
196
185
  licenses:
197
- - MIT
186
+ - GPL-3.0
198
187
  metadata:
199
188
  lita_plugin_type: adapter
200
189
  post_install_message:
@@ -203,9 +192,9 @@ require_paths:
203
192
  - lib
204
193
  required_ruby_version: !ruby/object:Gem::Requirement
205
194
  requirements:
206
- - - ">="
195
+ - - "~>"
207
196
  - !ruby/object:Gem::Version
208
- version: '0'
197
+ version: '2.3'
209
198
  required_rubygems_version: !ruby/object:Gem::Requirement
210
199
  requirements:
211
200
  - - ">="
@@ -213,9 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
202
  version: '0'
214
203
  requirements: []
215
204
  rubyforge_project:
216
- rubygems_version: 2.4.8
205
+ rubygems_version: 2.5.2
217
206
  signing_key:
218
207
  specification_version: 4
219
208
  summary: Tox adapter for the Lita chat bot
220
209
  test_files: []
221
- has_rdoc: