Archived
1
0
Fork 0

Merge pull request #25 from braiden-vasco/use-external-tox-adapter

Use external Tox gem
This commit is contained in:
Braiden Vasco 2017-07-20 20:47:44 +00:00 committed by GitHub
commit f2f28270df
15 changed files with 87 additions and 624 deletions

4
.gitignore vendored
View file

@ -10,10 +10,6 @@
/test/version_tmp/
/tmp/
Makefile
*.o
*.so
## Specific to RubyMotion:
.dat*
.repl_history

View file

@ -1,9 +1,6 @@
language: ruby
rvm:
- 2.0
- 2.1
- 2.2
- 2.3
- 2.4
@ -20,6 +17,3 @@ before_install:
- sudo mkdir -p '/etc/ld.so.conf.d/'
- echo '/usr/local/lib/' | sudo tee -a '/etc/ld.so.conf.d/locallib.conf'
- sudo ldconfig
before_script:
- rake compile

View file

@ -7,31 +7,6 @@ Lita::Adapters::Tox
[Tox](https://tox.chat) adapter for the [Lita](http://lita.io) chat bot.
**WARNING**
Still in development. Read the README carefully.
TODO
----
Current development version have some limitations
which should be fixed in first release:
* [\[issue #16\]](https://github.com/braiden-vasco/lita-tox/issues/16)
**libtoxcore** is not included in the gem. It should be compiled manually
to build the gem native extension successfully. Follow the instructions in
[that file](https://github.com/irungentoo/toxcore/blob/2ab3b14731061cc04d3ccc50a35093c11d018298/INSTALL.md)
* [\[issue #17\]](https://github.com/braiden-vasco/lita-tox/issues/17)
JRuby is not supported. Only C extension for Tox is implemented
* [\[issue #18\]](https://github.com/braiden-vasco/lita-tox/issues/18)
Message length is limited to value of `TOX_MAX_MESSAGE_LENGTH`
(see [source code of **libtoxcore**](https://github.com/irungentoo/toxcore/blob/2ab3b14731061cc04d3ccc50a35093c11d018298/toxcore/tox.h#L252-L255))
* Adapter has incomplete API for Lita. Only basic methods are implemented
Usage
-----

View file

@ -33,9 +33,3 @@ task :changelog, [:token] do |_t, args|
sh cmd
end
require 'rake/extensiontask'
Rake::ExtensionTask.new 'tox' do |ext|
ext.lib_dir = 'lib/tox'
end

1
example/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/savedata

7
example/Gemfile Normal file
View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'lita', '~> 4.4.0'
gem 'lita-tox', path: '..'

51
example/Gemfile.lock Normal file
View file

@ -0,0 +1,51 @@
PATH
remote: ..
specs:
lita-tox (0.3.0)
lita (~> 4.4)
tox (~> 0.0.1)
GEM
remote: https://rubygems.org/
specs:
faraday (0.12.1)
multipart-post (>= 1.2, < 3)
http_router (0.11.2)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
i18n (0.8.6)
ice_nine (0.11.2)
lita (4.4.3)
bundler (>= 1.3)
faraday (>= 0.8.7)
http_router (>= 0.11.1)
i18n (>= 0.6.9)
ice_nine (>= 0.11.0)
multi_json (>= 1.7.7)
puma (>= 2.7.1)
rack (>= 1.5.2)
rb-readline (>= 0.5.1)
redis-namespace (>= 1.3.0)
thor (>= 0.18.1)
multi_json (1.12.1)
multipart-post (2.0.0)
puma (3.9.1)
rack (2.0.3)
rb-readline (0.5.4)
redis (3.3.3)
redis-namespace (1.5.3)
redis (~> 3.0, >= 3.0.4)
thor (0.19.4)
tox (0.0.1)
url_mount (0.2.1)
rack
PLATFORMS
ruby
DEPENDENCIES
lita (~> 4.4.0)
lita-tox!
BUNDLED WITH
1.13.6

10
example/lita_config.rb Normal file
View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
Lita.configure do |config|
config.robot.name = 'Lita'
config.robot.adapter = :tox
config.adapters.tox.savedata_filename = 'savedata'
config.adapters.tox.status = "Send me \"#{config.robot.name}: help\""
end

View file

@ -1,39 +0,0 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'mkmf'
NAME = 'tox'
LIBTOXCORE = 'toxcore'
have_header 'time.h' and
have_header 'tox/tox.h' and
have_header 'tox/tox_old.h' and
have_func 'sprintf' and
have_func 'sscanf' and
have_func 'nanosleep' and
have_library LIBTOXCORE, 'tox_options_default' and
have_library LIBTOXCORE, 'tox_new' and
have_library LIBTOXCORE, 'tox_get_savedata_size' and
have_library LIBTOXCORE, 'tox_get_savedata' and
have_library LIBTOXCORE, 'tox_self_get_address' and
have_library LIBTOXCORE, 'tox_bootstrap' and
have_library LIBTOXCORE, 'tox_kill' and
have_library LIBTOXCORE, 'tox_version_is_compatible' and
have_library LIBTOXCORE, 'tox_iteration_interval' and
have_library LIBTOXCORE, 'tox_iterate' and
have_library LIBTOXCORE, 'tox_friend_add_norequest' and
have_library LIBTOXCORE, 'tox_friend_send_message' and
have_library LIBTOXCORE, 'tox_callback_friend_request' and
have_library LIBTOXCORE, 'tox_callback_friend_message' and
have_library LIBTOXCORE, 'tox_self_get_name_size' and
have_library LIBTOXCORE, 'tox_self_get_name' and
have_library LIBTOXCORE, 'tox_self_set_name' and
have_library LIBTOXCORE, 'tox_self_get_status_message_size' and
have_library LIBTOXCORE, 'tox_self_get_status_message' and
have_library LIBTOXCORE, 'tox_self_set_status_message' and
create_makefile "#{NAME}/#{NAME}" or exit(1)

View file

@ -1,452 +0,0 @@
#include <ruby.h>
#include <time.h>
#include <tox/tox.h>
#define TOX_IS_COMPATIBLE TOX_VERSION_IS_API_COMPATIBLE
TOX_VERSION_REQUIRE(0, 0, 0);
void Init_tox();
#define IP_LENGTH_MAX 15
typedef char IP[IP_LENGTH_MAX + 1];
typedef char Key[(TOX_PUBLIC_KEY_SIZE * 2) + 1];
typedef struct Node {
IP ip;
int port;
Key key;
} Node;
typedef uint8_t KeyBin[TOX_PUBLIC_KEY_SIZE];
static void Key_to_KeyBin(const char *key, uint8_t *key_bin);
typedef struct cTox_ {
Tox *tox;
} cTox_;
static VALUE cTox;
static VALUE cTox_alloc(VALUE klass);
static void cTox_free(void *ptr);
static VALUE cTox_initialize_with(VALUE self, VALUE options);
static VALUE cTox_savedata(VALUE self);
static VALUE cTox_id(VALUE self);
static VALUE cTox_bootstrap(VALUE self, VALUE options);
static VALUE cTox_kill(VALUE self);
static VALUE cTox_loop(VALUE self);
static VALUE cTox_friend_add_norequest(VALUE self, VALUE key);
static VALUE cTox_friend_send_message(VALUE self, VALUE friend_number, VALUE text);
static VALUE cTox_name(VALUE self);
static VALUE cTox_name_ASSIGN(VALUE self, VALUE name);
static VALUE cTox_status_message(VALUE self);
static VALUE cTox_status_message_ASSIGN(VALUE self, VALUE text);
static void on_friend_request(
Tox *tox,
const uint8_t *key,
const uint8_t *data,
size_t length,
VALUE self);
static void on_friend_message(
Tox *tox,
uint32_t friend_number,
TOX_MESSAGE_TYPE type,
const uint8_t *text,
size_t length,
VALUE self);
typedef struct Tox_Options cTox_cOptions_;
static VALUE cTox_cOptions;
static VALUE cTox_cOptions_alloc(VALUE klass);
static void cTox_cOptions_free(void *ptr);
static VALUE cTox_cOptions_initialize(VALUE self);
static VALUE cTox_cOptions_data_EQUALS(VALUE self, VALUE data);
void Init_tox()
{
if (!TOX_VERSION_IS_ABI_COMPATIBLE())
rb_raise(rb_eLoadError, "incompatible Tox ABI version");
cTox = rb_define_class("Tox", rb_cObject);
rb_define_alloc_func(cTox, cTox_alloc);
rb_define_method(cTox, "initialize_with", cTox_initialize_with, 1);
rb_define_method(cTox, "savedata", cTox_savedata, 0);
rb_define_method(cTox, "id", cTox_id, 0);
rb_define_method(cTox, "bootstrap", cTox_bootstrap, 1);
rb_define_method(cTox, "kill", cTox_kill, 0);
rb_define_method(cTox, "loop", cTox_loop, 0);
rb_define_method(cTox, "friend_add_norequest", cTox_friend_add_norequest, 1);
rb_define_method(cTox, "friend_send_message", cTox_friend_send_message, 2);
rb_define_method(cTox, "name", cTox_name, 0);
rb_define_method(cTox, "name=", cTox_name_ASSIGN, 1);
rb_define_method(cTox, "status_message", cTox_status_message, 0);
rb_define_method(cTox, "status_message=", cTox_status_message_ASSIGN, 1);
cTox_cOptions = rb_define_class_under(cTox, "Options", rb_cObject);
rb_define_alloc_func(cTox_cOptions, cTox_cOptions_alloc);
rb_define_method(cTox_cOptions, "initialize", cTox_cOptions_initialize, 0);
rb_define_method(cTox_cOptions, "data=", cTox_cOptions_data_EQUALS, 1);
}
/******************************************************************************
* KeyBin
******************************************************************************/
void Key_to_KeyBin(const char *const key, uint8_t *const key_bin)
{
long i;
for (i = 0; i < TOX_PUBLIC_KEY_SIZE; ++i)
sscanf(&key[i * 2], "%2hhx", &key_bin[i]);
}
/******************************************************************************
* Tox
******************************************************************************/
VALUE cTox_alloc(const VALUE klass)
{
cTox_ *tox;
tox = ALLOC(cTox_);
return Data_Wrap_Struct(klass, NULL, cTox_free, tox);
}
void cTox_free(void *const ptr)
{
free(ptr);
}
VALUE cTox_initialize_with(const VALUE self, const VALUE options)
{
cTox_ *tox;
cTox_cOptions_ *tox_options;
TOX_ERR_NEW error;
// check if `options` is instance of `Tox::Options`
if (Qfalse == rb_funcall(options, rb_intern("is_a?"), 1, cTox_cOptions))
rb_raise(rb_eTypeError, "argument 1 should be Tox::Options");
Data_Get_Struct(self, cTox_, tox);
Data_Get_Struct(options, cTox_cOptions_, tox_options);
tox->tox = tox_new(tox_options, &error);
if (error != TOX_ERR_NEW_OK)
rb_raise(rb_eRuntimeError, "tox_new() failed");
tox_callback_friend_request(tox->tox, (tox_friend_request_cb*)on_friend_request, (void*)self);
tox_callback_friend_message(tox->tox, (tox_friend_message_cb*)on_friend_message, (void*)self);
return self;
}
VALUE cTox_savedata(const VALUE self)
{
cTox_ *tox;
size_t data_size;
char *data;
Data_Get_Struct(self, cTox_, tox);
data_size = tox_get_savedata_size(tox->tox);
data = ALLOC_N(char, data_size);
tox_get_savedata(tox->tox, (uint8_t*)data);
return rb_str_new(data, data_size);
}
VALUE cTox_id(const VALUE self)
{
cTox_ *tox;
char address[TOX_ADDRESS_SIZE];
char id[2 * TOX_ADDRESS_SIZE];
unsigned long i;
Data_Get_Struct(self, cTox_, tox);
tox_self_get_address(tox->tox, (uint8_t*)address);
for (i = 0; i < TOX_ADDRESS_SIZE; ++i)
sprintf(&id[2 * i], "%02X", address[i] & 0xFF);
return rb_str_new(id, 2 * TOX_ADDRESS_SIZE);
}
VALUE cTox_bootstrap(const VALUE self, const VALUE options)
{
cTox_ *tox;
VALUE ip;
VALUE port;
VALUE key;
Node node;
KeyBin key_bin;
TOX_ERR_BOOTSTRAP error;
Check_Type(options, T_HASH);
ip = rb_hash_aref(options, ID2SYM(rb_intern("ip")));
port = rb_hash_aref(options, ID2SYM(rb_intern("port")));
key = rb_hash_aref(options, ID2SYM(rb_intern("key")));
if (ip == Qnil) rb_raise(rb_eRuntimeError, "option \"ip\" is required");
if (port == Qnil) rb_raise(rb_eRuntimeError, "option \"port\" is required");
if (key == Qnil) rb_raise(rb_eRuntimeError, "option \"key\" is required");
Data_Get_Struct(self, cTox_, tox);
memcpy(node.ip, RSTRING_PTR(ip), RSTRING_LEN(ip) + 1);
node.port = NUM2INT(port);
memcpy(node.key, RSTRING_PTR(key), RSTRING_LEN(key) + 1);
Key_to_KeyBin(node.key, key_bin);
tox_bootstrap(tox->tox, node.ip, node.port, key_bin, &error);
if (error == TOX_ERR_BOOTSTRAP_OK)
return Qtrue;
else
return Qfalse;
}
VALUE cTox_kill(const VALUE self)
{
cTox_ *tox;
Data_Get_Struct(self, cTox_, tox);
tox_kill(tox->tox);
return self;
}
VALUE cTox_loop(const VALUE self)
{
cTox_ *tox;
struct timespec delay;
Data_Get_Struct(self, cTox_, tox);
rb_funcall(self, rb_intern("running="), 1, Qtrue);
delay.tv_sec = 0;
while (rb_funcall(self, rb_intern("running"), 0)) {
delay.tv_nsec = tox_iteration_interval(tox->tox) * 1000000;
nanosleep(&delay, NULL);
tox_iterate(tox->tox);
}
return self;
}
VALUE cTox_friend_add_norequest(const VALUE self, const VALUE key)
{
cTox_ *tox;
Check_Type(key, T_STRING);
Data_Get_Struct(self, cTox_, tox);
return LONG2FIX(tox_friend_add_norequest(tox->tox, (uint8_t*)RSTRING_PTR(key), NULL));
}
VALUE cTox_friend_send_message(const VALUE self, const VALUE friend_number, const VALUE text)
{
cTox_ *tox;
// Don't know yet how to check for integers
// Check_Type(friend_number, T_INTEGER);
Check_Type(text, T_STRING);
Data_Get_Struct(self, cTox_, tox);
return LONG2FIX(tox_friend_send_message(
tox->tox,
NUM2LONG(friend_number),
TOX_MESSAGE_TYPE_NORMAL,
(uint8_t*)RSTRING_PTR(text),
RSTRING_LEN(text),
NULL
));
}
VALUE cTox_name(const VALUE self)
{
cTox_ *tox;
char name[TOX_MAX_NAME_LENGTH];
size_t name_size;
Data_Get_Struct(self, cTox_, tox);
name_size = tox_self_get_name_size(tox->tox);
if (name_size > 0)
tox_self_get_name(tox->tox, (uint8_t*)name);
return rb_str_new(name, name_size);
}
VALUE cTox_name_ASSIGN(const VALUE self, const VALUE name)
{
cTox_ *tox;
bool result;
TOX_ERR_SET_INFO error;
Check_Type(name, T_STRING);
Data_Get_Struct(self, cTox_, tox);
result = tox_self_set_name(tox->tox, (uint8_t*)RSTRING_PTR(name), RSTRING_LEN(name), &error);
if (error != TOX_ERR_SET_INFO_OK || !result)
return Qfalse;
else
return Qtrue;
}
VALUE cTox_status_message(const VALUE self)
{
cTox_ *tox;
char text[TOX_MAX_STATUS_MESSAGE_LENGTH];
size_t text_size;
Data_Get_Struct(self, cTox_, tox);
text_size = tox_self_get_status_message_size(tox->tox);
if (text_size > 0)
tox_self_get_status_message(tox->tox, (uint8_t*)text);
return rb_str_new(text, text_size);
}
VALUE cTox_status_message_ASSIGN(const VALUE self, const VALUE text)
{
cTox_ *tox;
bool result;
TOX_ERR_SET_INFO error;
Check_Type(text, T_STRING);
Data_Get_Struct(self, cTox_, tox);
result = tox_self_set_status_message(tox->tox, (uint8_t*)RSTRING_PTR(text), RSTRING_LEN(text), &error);
if (error != TOX_ERR_SET_INFO_OK || !result)
return Qfalse;
else
return Qtrue;
}
void on_friend_request(
Tox *const tox,
const uint8_t *const key,
const uint8_t *const data,
const size_t length,
const VALUE self)
{
VALUE rb_on_friend_request;
rb_on_friend_request = rb_iv_get(self, "@on_friend_request");
if (Qnil != rb_on_friend_request)
rb_funcall(
rb_on_friend_request,
rb_intern("call"),
2,
rb_str_new((char*)key, TOX_PUBLIC_KEY_SIZE),
rb_str_new((char*)data, length)
);
}
void on_friend_message(
Tox *const tox,
const uint32_t friend_number,
const TOX_MESSAGE_TYPE type,
const uint8_t *const text,
const size_t length,
const VALUE self)
{
VALUE rb_on_friend_message;
if (type != TOX_MESSAGE_TYPE_NORMAL)
return;
rb_on_friend_message = rb_iv_get(self, "@on_friend_message");
if (Qnil != rb_on_friend_message)
rb_funcall(
rb_on_friend_message,
rb_intern("call"),
2,
LONG2FIX(friend_number),
rb_str_new((char*)text, length)
);
}
/******************************************************************************
* Tox::Options
******************************************************************************/
VALUE cTox_cOptions_alloc(const VALUE klass)
{
cTox_cOptions_ *tox_options;
tox_options = ALLOC(cTox_cOptions_);
return Data_Wrap_Struct(klass, NULL, cTox_cOptions_free, tox_options);
}
void cTox_cOptions_free(void *const ptr)
{
free(ptr);
}
VALUE cTox_cOptions_initialize(const VALUE self)
{
cTox_cOptions_ *tox_options;
Data_Get_Struct(self, cTox_cOptions_, tox_options);
tox_options_default(tox_options);
return self;
}
VALUE cTox_cOptions_data_EQUALS(const VALUE self, const VALUE savedata)
{
cTox_cOptions_ *tox_options;
Check_Type(savedata, T_STRING);
Data_Get_Struct(self, cTox_cOptions_, tox_options);
tox_options->savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
tox_options->savedata_data = (uint8_t*)RSTRING_PTR(savedata);
tox_options->savedata_length = RSTRING_LEN(savedata);
return savedata;
}

View file

@ -40,23 +40,25 @@ module Lita
if config.savedata_filename && File.exist?(config.savedata_filename)
savedata_file = open(config.savedata_filename)
options.data = savedata_file.read
options.savedata = savedata_file.read
savedata_file.close
end
@tox = ::Tox.new(options)
@tox = ::Tox::Client.new(options)
log.info("ID: #{@tox.id}")
log.info("ID: #{@tox.address.to_hex}")
@tox.bootstrap_official
@tox.name = robot.name if robot.name
@tox.status_message = config.status if config.status
@tox.on_friend_request do |key|
@tox.friend_add_norequest(key)
@tox.on_friend_request do |public_key|
@tox.friend_add_norequest(public_key)
end
@tox.on_friend_message do |friend_number, text|
user = User.new(friend_number)
@tox.on_friend_message do |friend, text|
user = User.new(friend.number)
source = Source.new(user: user)
message = Message.new(robot, text, source)
@ -66,7 +68,7 @@ module Lita
end
def run
@tox.loop
@tox.run
end
def shut_down
@ -76,12 +78,12 @@ module Lita
savedata_file.close
end
@tox.kill
@tox.stop
end
def send_messages(target, messages)
messages.reject(&:empty?).each do |message|
@tox.friend_send_message(target.user.id.to_i, message)
::Tox::Friend.new(@tox, target.user.id.to_i).send_message(message)
end
end
end

View file

@ -1,73 +0,0 @@
# frozen_string_literal: true
# lita-tox - Tox adapter for the Lita chat bot
# Copyright (C) 2015-2017 Braiden Vasco
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# rubocop:disable Layout/SpaceInsideArrayPercentLiteral
require 'tox/tox'
class Tox # rubocop:disable Style/Documentation
NODES = [
%w[192.254.75.102 33445 951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F],
%w[144.76.60.215 33445 04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F],
%w[23.226.230.47 33445 A09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074],
%w[178.62.125.224 33445 10B20C49ACBD968D7C80F2E8438F92EA51F189F4E70CFBBB2C2C8C799E97F03E],
%w[178.21.112.187 33445 4B2C19E924972CB9B57732FB172F8A8604DE13EEDA2A6234E348983344B23057],
%w[195.154.119.113 33445 E398A69646B8CEACA9F0B84F553726C1C49270558C57DF5F3C368F05A7D71354],
%w[192.210.149.121 33445 F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67],
%w[76.191.23.96 33445 93574A3FAB7D612FEA29FD8D67D3DD10DFD07A075A5D62E8AF3DD9F5D0932E11],
%w[46.38.239.179 33445 F5A1A38EFB6BD3C2C8AF8B10D85F0F89E931704D349F1D0720C3C4059AF2440A],
%w[178.62.250.138 33445 788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B],
%w[78.225.128.39 33445 7A2306BFBA665E5480AE59B31E116BE9C04DCEFE04D9FE25082316FA34B4DA0C],
%w[130.133.110.14 33445 461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F],
%w[104.167.101.29 33445 5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57],
%w[195.154.109.148 33445 391C96CB67AE893D4782B8E4495EB9D89CF1031F48460C06075AA8CE76D50A21],
%w[192.3.173.88 33445 3E1FFDEB667BFF549F619EC6737834762124F50A89C8D0DBF1DDF64A2DD6CD1B],
%w[205.185.116.116 33445 A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702],
%w[198.98.51.198 33445 1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F],
%w[80.232.246.79 33445 A7A060D553B017D9D8F038E265C7AFB6C70BAAC55070197F9C007432D0038E0F],
%w[108.61.165.198 33445 8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832],
%w[212.71.252.109 33445 C4CEB8C7AC607C6B374E2E782B3C00EA3A63B80D4910B8649CCACDD19F260819],
%w[194.249.212.109 33445 3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B],
%w[194.249.212.109 443 3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B],
%w[103.38.216.87 33445 601AEE6FC8C17E8CD8F8F1FFC4D4AD84E59A73BE451F037194E7A404E3795320],
%w[185.25.116.107 33445 DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43],
%w[192.99.168.140 33445 6A4D0607A296838434A6A7DDF99F50EF9D60A2C510BBF31FE538A25CB6B4652F],
].freeze
attr_accessor :running
def initialize(options = Tox::Options.new)
initialize_with(options)
NODES.each do |node|
bootstrap(
ip: node[0],
port: node[1].to_i,
key: node[2],
)
end
end
def on_friend_request(&block)
@on_friend_request = block
end
def on_friend_message(&block)
@on_friend_message = block
end
end

View file

@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/braiden-vasco/lita-tox'
spec.license = 'GPL-3.0'
spec.required_ruby_version = '~> 2.3'
spec.metadata['lita_plugin_type'] = 'adapter'
spec.files = `git ls-files -z`.split("\x0").reject do |f|
@ -22,8 +24,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.extensions << 'ext/tox/extconf.rb'
spec.add_development_dependency 'bundler', '~> 1.7'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rubocop', '~> 0.31'
@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'yard', '~> 0.8'
spec.add_development_dependency 'redcarpet', '~> 3.3'
spec.add_development_dependency 'github_changelog_generator', '~> 1.6'
spec.add_development_dependency 'rake-compiler', '~> 0.9'
spec.add_development_dependency 'pry', '~> 0.10'
spec.add_runtime_dependency 'lita', '~> 4.4'
spec.add_runtime_dependency 'tox', '~> 0.0.1'
end

View file

@ -16,5 +16,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# RSpec.describe Lita::Adapters::Tox, lita: true do
# end
RSpec.describe Lita::Adapters::Tox, lita: true do
end

View file

@ -35,12 +35,9 @@ require 'simplecov'
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'timeout'
require 'faker'
require 'lita/rspec'
# require 'lita-tox'
require 'lita-tox'
# A compatibility mode is provided for older plugins upgrading from Lita 3.
# Since this plugin was generated with Lita 4, the compatibility mode