trovobot 0.0.1 → 0.1.1

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
  SHA256:
3
- metadata.gz: 6b7663f68f63115e61353d82886cf07854ed3d9fd595397342d19574f0ea8738
4
- data.tar.gz: 78308c69ccfc5806298182b18506aa1eebf5ab86ea86424c9bda23915687b943
3
+ metadata.gz: 3b60d21cfe324d5e9e6626a14374fd1a1884385c53c4e70583fb2762dafe2e31
4
+ data.tar.gz: cd5cee42ba6b00620e6a3de0cc9015269939f8a2eda85a885e2c3ae631859b57
5
5
  SHA512:
6
- metadata.gz: 33b9d983a123386370e417fc4f2b6dcee48020ac9fdaa3266d7d202a1ab58180280e3ff54294df139e5293fafa130c86b28fa2cfc128c3dbcabffa4908bb2502
7
- data.tar.gz: de52c29a50ffb70d18211c651c89b981a180dad962a138c5c44b5b6c57cd84a767ae9ff3e19fd8b6c70d2ac315576b7421388a119fc6ab92ebfb1d2e2b62323f
6
+ metadata.gz: 392b6f18604b9a2bafd481e470d6c77995ee69a0733cf4dbb1489185b5447683cf7c7b20465a816e59aeb4e96728ae9325b7410cbae062e9a93fb85ff0432ff1
7
+ data.tar.gz: 50f9592d36f6e53004df684b8045961af85dfee8e994d349907afc0c160da2ef3a429a932834f81244fae0d199b0b7417dbc336b05fea5866d9ad4a265796386
@@ -0,0 +1,14 @@
1
+ # this might some day before a separate gem
2
+
3
+ module TrovoBot
4
+ module Common
5
+ require "fileutils"
6
+ def self.cache_text filename, update = false
7
+ if !update && File.exist?(filename)
8
+ File.read filename
9
+ else
10
+ yield.tap{ |_| FileUtils.mkdir_p File.dirname filename; File.write filename, _ }
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/trovobot.rb CHANGED
@@ -62,18 +62,18 @@ module TrovoBot
62
62
  attr_accessor :queue
63
63
  end
64
64
  self.queue = Queue.new
65
- Thread.new do
66
- loop do
67
- content, channel_id = queue.pop
68
- fail unless channel_id # omitting (for sending to own channel) isn't implemented yet
69
- pp TrovoBot::request "chat/send", {content: content, channel_id: channel_id}
70
- sleep 1
71
- end
72
- end.abort_on_exception = true
73
65
 
74
66
  def self.start
75
- puts "admin -- #{ARGV[0]}"
76
- puts "channel -- #{ARGV[1]}"
67
+ Thread.new do
68
+ loop do
69
+ content, channel_id = queue.pop
70
+ fail unless channel_id # omitting (for sending to own channel) isn't implemented yet
71
+ pp request "chat/send", {content: content, channel_id: channel_id}
72
+ sleep 1
73
+ end
74
+ end.abort_on_exception = true
75
+ puts "admin -- #{ARGV[0] || fail}"
76
+ puts "channel -- #{ARGV[1] || fail}"
77
77
  require "async/websocket/client"
78
78
  require "async/http/endpoint"
79
79
  Async do |task|
@@ -118,7 +118,7 @@ module TrovoBot
118
118
  yield msg, channel_id
119
119
  rescue
120
120
  puts $!.full_message
121
- TrovoBot::queue.push ["error at #{ARGV[1]}: #{$!}, #{$!.backtrace.first}", name_to_id(ARGV[0])]
121
+ queue.push ["error at #{ARGV[1]}: #{$!}, #{$!.backtrace.first}", name_to_id(ARGV[0])]
122
122
  else
123
123
  File.open("processed.jsonl", "a"){ |_| _.puts msg.fetch :message_id }
124
124
  end
data/trovobot.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "trovobot"
3
- spec.version = "0.0.1"
4
- spec.summary = "Trovo Live API library"
3
+ spec.version = "0.1.1"
4
+ spec.summary = "Trovo Live API client"
5
5
 
6
6
  spec.author = "Victor Maslov aka Nakilon"
7
7
  spec.email = "nakilon@gmail.com"
@@ -14,5 +14,5 @@ Gem::Specification.new do |spec|
14
14
  spec.add_dependency "async-http"
15
15
  spec.add_dependency "async-websocket"
16
16
 
17
- spec.files = %w{ LICENSE trovobot.gemspec lib/trovobot.rb }
17
+ spec.files = %w{ LICENSE trovobot.gemspec lib/trovobot.rb lib/trovobot/common.rb }
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trovobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov aka Nakilon
@@ -60,6 +60,7 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - LICENSE
62
62
  - lib/trovobot.rb
63
+ - lib/trovobot/common.rb
63
64
  - trovobot.gemspec
64
65
  homepage:
65
66
  licenses:
@@ -84,5 +85,5 @@ requirements: []
84
85
  rubygems_version: 3.2.22
85
86
  signing_key:
86
87
  specification_version: 4
87
- summary: Trovo Live API library
88
+ summary: Trovo Live API client
88
89
  test_files: []