botolo 0.55.2 → 0.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/bin/botolo +3 -3
- data/botolo.gemspec +3 -1
- data/lib/botolo/api/blog.rb +1 -1
- data/lib/botolo/api/tweet.rb +36 -36
- data/lib/botolo/bot/engine.rb +7 -7
- data/lib/botolo/version.rb +1 -1
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db7a2bf1606a13aa29d86ae0be2b1b999a1c5e00
|
4
|
+
data.tar.gz: ff0e8cedabffe412f5a47d2137d8567a5c9d78bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02c183271b79ddf8c6191cd924804e31fb90edd19847521af833280ace4b4fbb19cc198de5568c8d39b684b1ac38166528d29dfb7c77b1fa2af3077fab4f00a9
|
7
|
+
data.tar.gz: 2826e7fa26ace011326209376d222ba1d8cc043afccbc00e6eac0604dbdfbecf33b44b42b0fa03b5ed8f910e692aa13429cafb79b37cbb49add89e3340c205b1
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.4.0
|
data/bin/botolo
CHANGED
@@ -19,7 +19,7 @@ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
19
19
|
$logger = Logger.new(STDOUT)
|
20
20
|
$logger.datetime_format = '%Y-%m-%d %H:%M:%S'
|
21
21
|
|
22
|
-
trap("INT") { @bot.stop;
|
22
|
+
trap("INT") { @bot.stop; File.delete(BOTOLO_PID); Kernel.exit(0); }
|
23
23
|
|
24
24
|
opts.quiet=true
|
25
25
|
debug = false
|
@@ -52,8 +52,8 @@ $logger.die "usage: botolo bot_configuration_file" if config_file.nil?
|
|
52
52
|
$logger.helo "botolo", Botolo::VERSION
|
53
53
|
|
54
54
|
@bot = Botolo::Bot::Engine.new({:config=>config_file})
|
55
|
-
$logger.
|
56
|
-
$logger.
|
55
|
+
$logger.info "#{@bot.name} is online" if @bot.online?
|
56
|
+
$logger.info "#{@bot.name} is offline" unless @bot.online?
|
57
57
|
|
58
58
|
if debug
|
59
59
|
$logger.debug "forcing #{@bot.name} run"
|
data/botolo.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
you can focus on writing a set of actions your bot will execute every
|
14
14
|
amount of seconds, minutes or whatever and implement those actions. The
|
15
15
|
part of executing them and putting babies to sleep will be up to botolo.}
|
16
|
-
spec.homepage = "
|
16
|
+
spec.homepage = "https://codiceinsicuro.it"
|
17
17
|
spec.license = "MIT"
|
18
18
|
|
19
19
|
spec.files = `git ls-files`.split($/)
|
@@ -25,4 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rake"
|
26
26
|
spec.add_dependency "twitter", "~> 5.11.0"
|
27
27
|
spec.add_dependency "logger-colors"
|
28
|
+
spec.add_dependency "data_mapper"
|
29
|
+
spec.add_dependency "dm-sqlite-adapter"
|
28
30
|
end
|
data/lib/botolo/api/blog.rb
CHANGED
@@ -20,7 +20,7 @@ module Botolo
|
|
20
20
|
rss.items.each_with_index do |item, i|
|
21
21
|
@feed << {:title=>item.title.content, :link=>item.link.href}
|
22
22
|
end
|
23
|
-
$logger.
|
23
|
+
$logger.info "#{@feed.size} elements loaded from feed"
|
24
24
|
end
|
25
25
|
|
26
26
|
def tweet_random_posts(limit = 3, hashtags="")
|
data/lib/botolo/api/tweet.rb
CHANGED
@@ -28,50 +28,50 @@ module Botolo
|
|
28
28
|
$logger.err "can't authenticate #{a[:name]} (#{e.message})"
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
$logger.debug "#{@twitters}"
|
31
|
+
@twitters << a
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
34
|
+
@twitters
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
def tweet(name=nil, msg)
|
38
|
+
return nil if msg.empty?
|
39
|
+
@twitters.each do |t|
|
40
|
+
$logger.debug "#{t[:name]} sending #{msg}"
|
41
|
+
begin
|
42
|
+
t[:client].update(msg) if (name.nil? or (!name.nil? and name == t[:name]))
|
43
|
+
rescue => e
|
44
|
+
$logger.err "#{e.message}"
|
45
|
+
end
|
46
46
|
end
|
47
|
+
return msg
|
47
48
|
end
|
48
|
-
return msg
|
49
|
-
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
def retweet(name=nil, msg)
|
51
|
+
return nil if msg.empty?
|
52
|
+
@twitters.each do |t|
|
53
|
+
t[:client].retweet(msg) if (name.nil? or (!name.nil? and name == t[:name]))
|
54
|
+
end
|
55
|
+
return msg
|
55
56
|
end
|
56
|
-
return msg
|
57
|
-
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
def find_and_retweet_topic(limit = 5, topic)
|
59
|
+
list = []
|
60
|
+
@twitters.each do |tt|
|
61
|
+
list << tt[:client].search(topic).to_a
|
62
|
+
end
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
64
|
+
unless list.nil?
|
65
|
+
(0..limit-1).each do |l|
|
66
|
+
index = SecureRandom.random_number(list[0].count)
|
67
|
+
tweet = list[0][index]
|
68
|
+
begin
|
69
|
+
@twitters.each do |t|
|
70
|
+
$logger.debug("retwetting: #{tweet.txt}")
|
71
|
+
t[:client].retweet(tweet)
|
72
|
+
end
|
73
|
+
rescue => e
|
74
|
+
$logger.err("error tweeting #{tweet.text}: #{e.message}")
|
75
75
|
end
|
76
76
|
sleep(15)
|
77
77
|
end
|
data/lib/botolo/bot/engine.rb
CHANGED
@@ -26,17 +26,17 @@ module Botolo
|
|
26
26
|
$logger.helo name, version
|
27
27
|
$logger.filename = File.join(".", logfile) unless logfile.nil?
|
28
28
|
|
29
|
-
$logger.
|
29
|
+
$logger.info "#{@tasks.size} tasks loaded"
|
30
30
|
|
31
31
|
begin
|
32
32
|
load behaviour
|
33
|
-
$logger.
|
33
|
+
$logger.info "using #{behaviour} as bot behaviour"
|
34
34
|
@behaviour = Botolo::Bot::Behaviour.new(@config)
|
35
35
|
@start_time = Time.now
|
36
36
|
rescue => e
|
37
37
|
$logger.err(e.message)
|
38
38
|
require 'botolo/bot/behaviour'
|
39
|
-
$logger.
|
39
|
+
$logger.info "reverting to default dummy behaviour"
|
40
40
|
@behaviour = Botolo::Bot::Behaviour.new(@config)
|
41
41
|
@start_time = Time.now
|
42
42
|
end
|
@@ -57,7 +57,7 @@ module Botolo
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def run
|
60
|
-
$logger.
|
60
|
+
$logger.info "entering main loop"
|
61
61
|
@tasks.each do |task|
|
62
62
|
@task_pids << Thread.start do
|
63
63
|
start_task(task['action'], task['schedule'])
|
@@ -68,7 +68,7 @@ module Botolo
|
|
68
68
|
def infinite_loop
|
69
69
|
loop do
|
70
70
|
sleep(3600) # => 1 h
|
71
|
-
$logger.
|
71
|
+
$logger.info " --- mark --- (bot: #{@behaviour.name}, uptime: #{uptime})"
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -99,11 +99,11 @@ module Botolo
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def stop
|
102
|
-
$logger.
|
102
|
+
$logger.info "shutting down threads"
|
103
103
|
@task_pids.each do |pid|
|
104
104
|
Thread.kill(pid)
|
105
105
|
sleep 0.5
|
106
|
-
$logger.
|
106
|
+
$logger.info "pid #{pid} killed" if ! pid.alive?
|
107
107
|
$logger.err "pid #{pid} not killed" if pid.alive?
|
108
108
|
end
|
109
109
|
|
data/lib/botolo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.70.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Perego
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: data_mapper
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dm-sqlite-adapter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description: botolo is a bot engine written in ruby
|
70
98
|
email:
|
71
99
|
- thesp0nge@gmail.com
|
@@ -93,7 +121,7 @@ files:
|
|
93
121
|
- lib/botolo/bot/engine.rb
|
94
122
|
- lib/botolo/logger.rb
|
95
123
|
- lib/botolo/version.rb
|
96
|
-
homepage:
|
124
|
+
homepage: https://codiceinsicuro.it
|
97
125
|
licenses:
|
98
126
|
- MIT
|
99
127
|
metadata: {}
|
@@ -113,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
141
|
version: '0'
|
114
142
|
requirements: []
|
115
143
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
144
|
+
rubygems_version: 2.6.11
|
117
145
|
signing_key:
|
118
146
|
specification_version: 4
|
119
147
|
summary: botolo is a bot engine written in ruby. With botolo you can focus on writing
|