botolo 0.50.1 → 0.55.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: 7c056a9154f918d01201c929a490c128e05948a3
4
- data.tar.gz: 2053ec72550fa757df861b769e9c29ef6ff0ce42
3
+ metadata.gz: 6035a7556f519308cf1561e1a015b082479a7799
4
+ data.tar.gz: 9ba0bd8d09318d87edd5b5bcba69f40f5821618c
5
5
  SHA512:
6
- metadata.gz: 1e9be23278fe4f07801f7e0436326548a5623e6736902a676879e19402181aac16085c8fc74a162ecc0279490da167d24197f29631640251bdc2e183acb9b885
7
- data.tar.gz: ee7b4bddc504a28533361fb146184b597a95298d195bb54450e518247df1f46dc69283558baf06cd69e751f410e78f9fc7d79ed4438fba63dad749f80a256e27
6
+ metadata.gz: 879ded7647749091444b1baabb42065392f05fbc60ac21dd0272853927891afba5e243023eb539f9f5604931e3f02fc098f68895afa387e85d7e5fafcb93d905
7
+ data.tar.gz: 027fabc0b0b6002abe2c280b59ada46b6d7ecf941429244b702441a3c0d20e3629a7a6c73798eaade0092df8230c7446268284c87dac51d5dcc464a588ecb50f
data/README.md CHANGED
@@ -50,7 +50,7 @@ task:
50
50
 
51
51
  Botolo expects to find in the current directory a file named dummy-bot.rb
52
52
  implementing the two methods (say\_hello and say\_foo) it has to run based upon
53
- this schedule.
53
+ this schedule.
54
54
  There is a **big** constraint: your ruby file must be a Botolo::Bot::Behaviour
55
55
  class. It must also implement an initialize method with an Hash parameter
56
56
  engine will use to pass options to the bot.
data/bin/botolo CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'botolo'
4
4
  require 'openssl'
5
- require 'codesake-commons'
5
+ require 'logger'
6
6
  require 'getoptlong'
7
7
 
8
8
  opts = GetoptLong.new(
@@ -12,11 +12,13 @@ opts = GetoptLong.new(
12
12
  )
13
13
 
14
14
  DEFAULT_BEHAVIOUR = "./lib/botolo/bot/behaviour.rb"
15
- BOTOLO_PID = File.join(".", "botolo.pid")
15
+ BOTOLO_PID = File.join(".", "botolo.pid")
16
16
 
17
17
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
18
18
 
19
- $logger = Codesake::Commons::Logging.instance
19
+ $logger = Logger.new(STDOUT)
20
+ $logger.datetime_format = '%Y-%m-%d %H:%M:%S'
21
+
20
22
  trap("INT") { @bot.stop; $logger.bye; File.delete(BOTOLO_PID); Kernel.exit(0); }
21
23
 
22
24
  opts.quiet=true
@@ -47,7 +49,7 @@ config_file = ARGV[0] if ARGV.count == 1
47
49
 
48
50
  $logger.die "usage: botolo bot_configuration_file" if config_file.nil?
49
51
 
50
- $logger.helo "botolo", Botolo::VERSION, BOTOLO_PID
52
+ $logger.helo "botolo", Botolo::VERSION
51
53
 
52
54
  @bot = Botolo::Bot::Engine.new({:config=>config_file})
53
55
  $logger.log "#{@bot.name} is online" if @bot.online?
data/botolo.gemspec CHANGED
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_dependency "twitter", "~> 5.11.0"
27
- spec.add_dependency "codesake-commons", "~> 1.0.0"
27
+ spec.add_dependency "logger-colors"
28
28
  end
data/lib/botolo.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "botolo/logger"
1
2
  require "botolo/version"
2
3
  require "botolo/api/blog"
3
4
  require "botolo/api/tweet"
@@ -16,7 +16,6 @@ module Botolo
16
16
  a=Hash.new
17
17
  a[:name] = account['name']
18
18
  begin
19
- $logger.log "authenticating #{a[:name]}"
20
19
  a[:client] = Twitter::REST::Client.new do |config|
21
20
  config.consumer_key = account['consumer_key']
22
21
  config.consumer_secret = account['consumer_secret']
@@ -24,12 +23,14 @@ module Botolo
24
23
  config.access_token = account['access_token'] unless account['access_token'].nil?
25
24
  config.access_token_secret = account['access_token_secret'] unless account['access_token_secret'].nil?
26
25
  end
26
+ $logger.ok "#{a[:name]} authenticated successfully"
27
27
  rescue Exception => e
28
- $logger.err e.message
28
+ $logger.err "can't authenticate #{a[:name]} (#{e.message})"
29
29
  end
30
30
 
31
31
  @twitters << a
32
32
  end
33
+ $logger.debug "#{@twitters}"
33
34
 
34
35
  @twitters
35
36
  end
@@ -37,7 +38,12 @@ module Botolo
37
38
  def tweet(name=nil, msg)
38
39
  return nil if msg.empty?
39
40
  @twitters.each do |t|
40
- t[:client].update(msg) if (name.nil? or (!name.nil? and name == t[:name]))
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}"
46
+ end
41
47
  end
42
48
  return msg
43
49
  end
@@ -14,8 +14,8 @@ module Botolo
14
14
 
15
15
  if @config['twitter']['enabled']
16
16
  $twitter_api = Botolo::API::Tweet.instance
17
- $twitter_api.authenticate(@config['twitter'])
18
- @online unless $twitter_api.twitters.empty?
17
+ $twitter_api.authenticate(@config['twitter'])
18
+ @online = true unless $twitter_api.twitters.empty?
19
19
  end
20
20
 
21
21
  @tasks = @config['task']
@@ -0,0 +1,16 @@
1
+ require 'logger/colors'
2
+
3
+ class Logger
4
+ def helo(app, version)
5
+ @app = app
6
+ info "#{app} v#{version} is starting up"
7
+ end
8
+ def die(msg)
9
+ error(msg)
10
+ Kernel.exit(-1)
11
+ end
12
+ def bye
13
+ info "#{@app} is shutting down"
14
+ end
15
+
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Botolo
2
- VERSION = "0.50.1"
2
+ VERSION = "0.55.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.50.1
4
+ version: 0.55.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: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2016-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 5.11.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: codesake-commons
56
+ name: logger-colors
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.0
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.0
68
+ version: '0'
69
69
  description: botolo is a bot engine written in ruby
70
70
  email:
71
71
  - thesp0nge@gmail.com
@@ -91,6 +91,7 @@ files:
91
91
  - lib/botolo/api/tweet.rb
92
92
  - lib/botolo/bot/behaviour.rb
93
93
  - lib/botolo/bot/engine.rb
94
+ - lib/botolo/logger.rb
94
95
  - lib/botolo/version.rb
95
96
  homepage: http://codesake.com
96
97
  licenses:
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  version: '0'
113
114
  requirements: []
114
115
  rubyforge_project:
115
- rubygems_version: 2.2.2
116
+ rubygems_version: 2.5.1
116
117
  signing_key:
117
118
  specification_version: 4
118
119
  summary: botolo is a bot engine written in ruby. With botolo you can focus on writing