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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db0ee673fb56a2a0c509d370ca3b403569569f9b
4
- data.tar.gz: 04183cff6e85ca7265612f231e455ef0e0c71937
3
+ metadata.gz: db7a2bf1606a13aa29d86ae0be2b1b999a1c5e00
4
+ data.tar.gz: ff0e8cedabffe412f5a47d2137d8567a5c9d78bb
5
5
  SHA512:
6
- metadata.gz: e49f04edc7eec957c23d82073417cba35c6a3241513fed61593d5608cdd505add1d332b13503343f8dc07f0876122a32ba21e6ed5fad4eeb03ac9b79d1ef0d95
7
- data.tar.gz: 7d5471760ea0e1137fd36ade851b48fe1be5badecd2dd2ef1fabd0819c8078738ead2985a8e1d673377f4618391b77a60e5d8965cf7b71bdc0892606b9428985
6
+ metadata.gz: 02c183271b79ddf8c6191cd924804e31fb90edd19847521af833280ace4b4fbb19cc198de5568c8d39b684b1ac38166528d29dfb7c77b1fa2af3077fab4f00a9
7
+ data.tar.gz: 2826e7fa26ace011326209376d222ba1d8cc043afccbc00e6eac0604dbdfbecf33b44b42b0fa03b5ed8f910e692aa13429cafb79b37cbb49add89e3340c205b1
@@ -1 +1 @@
1
- ruby-2.1.3
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; $logger.bye; File.delete(BOTOLO_PID); Kernel.exit(0); }
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.log "#{@bot.name} is online" if @bot.online?
56
- $logger.log "#{@bot.name} is offline" unless @bot.online?
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"
@@ -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 = "http://codesake.com"
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
@@ -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.log "#{@feed.size} elements loaded from feed"
23
+ $logger.info "#{@feed.size} elements loaded from feed"
24
24
  end
25
25
 
26
26
  def tweet_random_posts(limit = 3, hashtags="")
@@ -28,50 +28,50 @@ module Botolo
28
28
  $logger.err "can't authenticate #{a[:name]} (#{e.message})"
29
29
  end
30
30
 
31
- @twitters << a
32
- end
33
- $logger.debug "#{@twitters}"
31
+ @twitters << a
32
+ end
34
33
 
35
- @twitters
36
- end
34
+ @twitters
35
+ end
37
36
 
38
- def tweet(name=nil, msg)
39
- return nil if msg.empty?
40
- @twitters.each do |t|
41
- $logger.debug "#{t[:name]} sending #{msg}"
42
- begin
43
- t[:client].update(msg) if (name.nil? or (!name.nil? and name == t[:name]))
44
- rescue => e
45
- $logger.err "#{e.message}"
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
- def retweet(name=nil, msg)
52
- return nil if msg.empty?
53
- @twitters.each do |t|
54
- t[:client].retweet(msg) if (name.nil? or (!name.nil? and name == t[:name]))
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
- def find_and_retweet_topic(limit = 5, topic)
60
- list = []
61
- @twitters.each do |tt|
62
- list << tt[:client].search("#appsec").to_a
63
- end
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
- unless list.nil?
66
- (0..limit-1).each do |l|
67
- t = list[SecureRandom.random_number(list.count)]
68
- $logger.debug "retwitting #{t["from_user"]}: #{t["text"]}"
69
- begin
70
- @twitters.each do |t|
71
- t[:client].retweet(msg) if (name.nil? or (!name.nil? and name == t[:name]))
72
- end
73
- rescue => e
74
- $logger.err("error tweeting #{t["text"]}: #{e.message}")
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
@@ -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.log "#{@tasks.size} tasks loaded"
29
+ $logger.info "#{@tasks.size} tasks loaded"
30
30
 
31
31
  begin
32
32
  load behaviour
33
- $logger.log "using #{behaviour} as bot behaviour"
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.log "reverting to default dummy behaviour"
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.log "entering main loop"
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.log " --- mark --- (bot: #{@behaviour.name}, uptime: #{uptime})"
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.log "shutting down threads"
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.log "pid #{pid} killed" if ! pid.alive?
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
 
@@ -1,3 +1,3 @@
1
1
  module Botolo
2
- VERSION = "0.55.2"
2
+ VERSION = "0.70.0"
3
3
  end
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.55.2
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: 2016-12-29 00:00:00.000000000 Z
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: http://codesake.com
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.5.1
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