rateless_bot 0.3.4 → 0.4.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: 681255f2f64c85057ab049a02a61a91b379ce33f
4
- data.tar.gz: 0365d6efb69a2e2beb28c91f6b90d70420aabf15
3
+ metadata.gz: 57d540564a5f2f8bd75167c80cffb8c21f2dd04b
4
+ data.tar.gz: e3b9cbb713a88f49672443e40f337e120ce64258
5
5
  SHA512:
6
- metadata.gz: daff30d17678e8a0548346bd6df3e225d6b2f50f794660d84df689c80b9e5b24d69213b750d55b57c5b456b0272c2fcf75830605e89df7fecf9bb60681e5a081
7
- data.tar.gz: fd1dd9c9f7716e6d467e61084ce9dd10718094c1a96d72ae3bd7fea3921f2b5ab911f147568b91be082080949286cd8f9e7df3e211fc614298041e539cfad6f3
6
+ metadata.gz: 4d2f83928c8cd82c3605412d4cc4009a5ab582203f5c7a54f1540709927153bc45177bb2dc8fd02495ec44e55d8103e7434f7cc1eabfa4d83742aa8b9dfbeb73
7
+ data.tar.gz: dffbf6589b89b9a69eddd2b7f5375a5d3efe3befe38dc9770cd54a0315f9777d1905e1b4b115571d71525f84019c8beac8227fcb18e0b65c55776d8d069d53fb
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rateless_bot.gemspec
4
4
  gemspec
5
-
6
- gem 'video_info', github: 'thibaudgg/video_info'
data/Gemfile.lock CHANGED
@@ -1,53 +1,41 @@
1
- GIT
2
- remote: git://github.com/thibaudgg/video_info.git
3
- revision: 8fd843d64cad63a2b8077010032c526078e27272
4
- specs:
5
- video_info (2.4.2)
6
- addressable
7
- htmlentities
8
- iso8601
9
- multi_json (~> 1.11)
10
- oga
11
- open_uri_redirections
12
-
13
1
  PATH
14
2
  remote: .
15
3
  specs:
16
- rateless_bot (0.3.3)
17
- cinch
18
- lastfm
4
+ rateless_bot (0.3.4)
5
+ cinch (= 2.3.2)
6
+ lastfm (= 1.27.1)
7
+ open-weather (~> 0.12)
8
+ video_info (= 2.6.1)
19
9
 
20
10
  GEM
21
11
  remote: https://rubygems.org/
22
12
  specs:
23
- activesupport (4.2.3)
13
+ activesupport (5.0.0.1)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
24
15
  i18n (~> 0.7)
25
- json (~> 1.7, >= 1.7.7)
26
16
  minitest (~> 5.1)
27
- thread_safe (~> 0.3, >= 0.3.4)
28
17
  tzinfo (~> 1.1)
29
- addressable (2.3.8)
30
18
  ansi (1.5.0)
31
- ast (2.1.0)
32
- cinch (2.2.6)
33
- htmlentities (4.3.4)
34
- httparty (0.13.5)
35
- json (~> 1.8)
19
+ ast (2.3.0)
20
+ cinch (2.3.2)
21
+ concurrent-ruby (1.0.2)
22
+ httparty (0.14.0)
36
23
  multi_xml (>= 0.5.2)
37
24
  i18n (0.7.0)
38
- iso8601 (0.8.6)
25
+ iso8601 (0.9.1)
39
26
  json (1.8.3)
40
- lastfm (1.27.0)
27
+ lastfm (1.27.1)
41
28
  activesupport (>= 3.2.0)
42
29
  httparty
43
30
  xml-simple
44
- minitest (5.8.0)
45
- multi_json (1.11.2)
31
+ minitest (5.8.3)
46
32
  multi_xml (0.5.5)
47
- oga (1.2.1)
33
+ net_http_timeout_errors (0.3.0)
34
+ oga (2.6)
48
35
  ast
49
36
  ruby-ll (~> 2.1)
50
- open_uri_redirections (0.2.1)
37
+ open-weather (0.12.0)
38
+ json (~> 1)
51
39
  rake (10.4.2)
52
40
  ruby-ll (2.1.2)
53
41
  ansi
@@ -55,6 +43,10 @@ GEM
55
43
  thread_safe (0.3.5)
56
44
  tzinfo (1.2.2)
57
45
  thread_safe (~> 0.1)
46
+ video_info (2.6.1)
47
+ iso8601 (~> 0.9)
48
+ net_http_timeout_errors (~> 0.3.0)
49
+ oga (~> 2.2)
58
50
  xml-simple (1.1.5)
59
51
 
60
52
  PLATFORMS
@@ -64,7 +56,6 @@ DEPENDENCIES
64
56
  bundler (~> 1.9)
65
57
  rake (~> 10.0)
66
58
  rateless_bot!
67
- video_info!
68
59
 
69
60
  BUNDLED WITH
70
- 1.10.6
61
+ 1.13.1
data/exe/rateless_bot CHANGED
@@ -28,11 +28,16 @@ OptionParser.new do |opts|
28
28
  options[:lastfm_api_secret] = secret
29
29
  end
30
30
 
31
+ opts.on("--open-weather-map-api-key KEY", "OpenWeatherMap API key") do |weather_key|
32
+ options[:open_weather_map_api_key] = weather_key
33
+ end
34
+
31
35
  opts.on("-h", "--help", "Prints this help") do
32
36
  puts opts
33
37
  exit
34
38
  end
35
39
  end.parse!
40
+
36
41
  puts options
37
42
 
38
43
  bot = Cinch::Bot.new do
@@ -46,13 +51,15 @@ bot = Cinch::Bot.new do
46
51
  Help,
47
52
  LastFM,
48
53
  MagicEightBall,
49
- VideoTitle]
54
+ VideoTitle,
55
+ Weather]
50
56
 
51
57
  c.plugins.options = {
52
58
  LastFM => {
53
59
  :api_key => options[:lastfm_api_key],
54
60
  :api_secret => options[:lastfm_api_secret]
55
- }
61
+ },
62
+ Weather => { :api_key => options[:open_weather_map_api_key] }
56
63
  }
57
64
  end
58
65
  end
@@ -6,3 +6,4 @@ require_relative 'plugins/help'
6
6
  require_relative 'plugins/magic_eight_ball'
7
7
  require_relative 'plugins/video_title'
8
8
  require_relative 'plugins/lastfm'
9
+ require_relative 'plugins/weather'
@@ -0,0 +1,44 @@
1
+ require 'cinch'
2
+ require 'open_weather'
3
+
4
+ class Weather
5
+ def help
6
+ '!weather CITY/ZIP - gets the current temperature for a given city/zip'
7
+ end
8
+
9
+ include Cinch::Plugin
10
+
11
+ def initialize(*args)
12
+ super
13
+ @options = { units: 'metric', APPID: config[:api_key] }
14
+ end
15
+
16
+ match /weather [^\s-]/
17
+
18
+ def execute(m)
19
+ city = m.message.split('!weather ')[1]
20
+
21
+ current_weather = OpenWeather::Current.city(city, @options)
22
+
23
+ m.reply make_current_weather_str(current_weather)
24
+ end
25
+
26
+ def make_current_weather_str(current_weather)
27
+ if current_weather['cod'] == '404'
28
+ return 'Error: City not found'
29
+ elsif current_weather['cod'] != 200 # number is not a string; report bug
30
+ return "Error: response code #{current_weather['cod']}"
31
+ end
32
+
33
+ city = current_weather['name']
34
+ country = current_weather['sys']['country']
35
+ humidity = current_weather['main']['humidity']
36
+ temp_celsius = current_weather['main']['temp'].round(1)
37
+ temp_fahrenheit = (temp_celsius * 1.8 + 32).round(1)
38
+ weather_description = current_weather['weather'][0]['description']
39
+
40
+ s = "Weather for #{city} (#{country}): "
41
+ s += "#{temp_celsius}°C (#{temp_fahrenheit}°F); #{humidity}% humidity; "
42
+ s += "#{weather_description}"
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module RatelessBot
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
data/rateless_bot.gemspec CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.9"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
 
25
- spec.add_dependency "cinch"
26
- spec.add_dependency "lastfm"
25
+ spec.add_dependency "cinch", "2.3.2"
26
+ spec.add_dependency "lastfm", "1.27.1"
27
+ spec.add_dependency "open-weather", "~> 0.12"
28
+ spec.add_dependency "video_info", "2.6.1"
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rateless_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Heuken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-08 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,30 +42,58 @@ dependencies:
42
42
  name: cinch
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.3.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.3.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: lastfm
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.27.1
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: '0'
68
+ version: 1.27.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: open-weather
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.12'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: video_info
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.6.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.6.1
69
97
  description:
70
98
  email:
71
99
  - me@vincentheuken.com
@@ -91,6 +119,7 @@ files:
91
119
  - lib/rateless_bot/plugins/lastfm.rb
92
120
  - lib/rateless_bot/plugins/magic_eight_ball.rb
93
121
  - lib/rateless_bot/plugins/video_title.rb
122
+ - lib/rateless_bot/plugins/weather.rb
94
123
  - lib/rateless_bot/version.rb
95
124
  - rateless_bot.gemspec
96
125
  homepage: https://github.com/vheuken/rateless_bot
@@ -113,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
142
  version: '0'
114
143
  requirements: []
115
144
  rubyforge_project:
116
- rubygems_version: 2.4.8
145
+ rubygems_version: 2.5.1
117
146
  signing_key:
118
147
  specification_version: 4
119
148
  summary: An IRC Bot