rateless_bot 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecae8fd604a1d1efd7ae39b9ab6ec73ee4fc0592
4
- data.tar.gz: b6557e9095456c57a9df47fa0aa66a3926016414
3
+ metadata.gz: 1afd0f0f226de0939b6d63f901740003e936a9d5
4
+ data.tar.gz: c9d644125b2eea0c6b5d97291a7f6fbabc0aa0e7
5
5
  SHA512:
6
- metadata.gz: a98e1481bdab573c6cb14a21043ca235e61573608b3b6bf02e43142695d43596ae43505706df3e8ae0ea379f86a1de88665b7a1c22738b4c8dbddf0b0c7c685f
7
- data.tar.gz: 0d0369b5a9140f644a78ef75a49d685b7cdd564d869086c43655387d1c60f7b4a839bc3c56bd1265d1003b8d522709df125ccfe1a25d75a1f4148e5e30fa24fa
6
+ metadata.gz: 3dc300b8625b19a2176affabbc6d1e852b67dd89107708c25c6bdcc6b99edd38224a8cc1f3f0478a9cab17872a335d83bc1e01cd77c024f683e579ab6c26326f
7
+ data.tar.gz: 0cd08b179156cea5d69a63dc66ea70774560e58a4c8c8a9db00be25b3abbddd961fc03f6ebb5dae39636458fb8f116ea1eb90c947e8805db89007f4b92ea4ed7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rateless_bot (0.4.0)
4
+ rateless_bot (0.4.1)
5
5
  cinch (= 2.3.2)
6
6
  countries (= 1.2.5)
7
7
  lastfm (= 1.27.1)
data/README.md CHANGED
@@ -15,11 +15,13 @@ Launch Options:
15
15
 
16
16
  $ rateless_bot -h
17
17
  Usage: rateless_bot [options]
18
- --nick NICK Bot's nick (required)
19
- --server SERVER IRC server (required)
20
- --channel CHANNEL IRC channel (required)
21
- --lastfm-api-key KEY LastFM API key
22
- --lastfm-api-secret SECRET LastFM secret API key
18
+ --nick NICK Bot's nick (required)
19
+ --server SERVER IRC server (required)
20
+ --channel CHANNEL IRC channel (required)
21
+ --lastfm-api-key KEY LastFM API key
22
+ --lastfm-api-secret SECRET LastFM secret API key
23
+ --open-weather-map-api-key KEY OpenWeatherMap API key
24
+
23
25
  -h, --help Prints this help
24
26
 
25
27
  Interacting with the bot:
@@ -30,7 +32,8 @@ Interacting with the bot:
30
32
  -Rateless-Bot- !roll XdY - rolls dice (replace X with number of dice and Y with number of sides)
31
33
  -Rateless-Bot- !lastfm USERNAME - gets the most recently listened-to track for a given user
32
34
  -Rateless-Bot- !8ball - Magic Eight Ball
33
-
35
+ -Rateless-Bot- !weather CITY/ZIP - gets the current temperature for a given city/zip
36
+
34
37
  ## Development
35
38
 
36
39
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -24,6 +24,8 @@ class Weather
24
24
  m.reply make_current_weather_str(current_weather)
25
25
  end
26
26
 
27
+ private
28
+
27
29
  def make_current_weather_str(current_weather)
28
30
  if current_weather['cod'] == '404'
29
31
  return 'Error: City not found'
@@ -36,10 +38,53 @@ class Weather
36
38
  humidity = current_weather['main']['humidity']
37
39
  temp_celsius = current_weather['main']['temp'].round(1)
38
40
  temp_fahrenheit = (temp_celsius * 1.8 + 32).round(1)
41
+ wind_speed_mps = current_weather['wind']['speed']
42
+ wind_speed_mph = (wind_speed_mps * 0.000621371 * 60**2).round(2)
43
+ wind_direction_degrees = current_weather['wind']['deg']
44
+ cardinal_wind_direction = degrees_to_cardinal(wind_direction_degrees)
39
45
  weather_description = current_weather['weather'][0]['description']
40
46
 
41
47
  s = "Weather for #{city} (#{country}): "
42
48
  s += "#{temp_celsius}°C (#{temp_fahrenheit}°F); #{humidity}% humidity; "
49
+ s += "#{wind_speed_mps}m/s (#{wind_speed_mph}mph) winds "
50
+ s += "blowing #{cardinal_wind_direction} (#{wind_direction_degrees}°); "
43
51
  s += "#{weather_description}"
44
52
  end
53
+
54
+ def degrees_to_cardinal(degree)
55
+ case degree
56
+ when ((degree >= 348.75) or 0..11.25)
57
+ 'North'
58
+ when 11.25..33.75
59
+ 'North-Northeast'
60
+ when 33.75..56.25
61
+ 'Northeast'
62
+ when 56.25..78.75
63
+ 'East-Northeast'
64
+ when 78.75..101.25
65
+ 'East'
66
+ when 101.25..123.75
67
+ 'East-Southeast'
68
+ when 123.75..146.25
69
+ 'Southeast'
70
+ when 146.25..168.75
71
+ 'South-Southeast'
72
+ when 168.75..191.25
73
+ 'South'
74
+ when 191.25..213.75
75
+ 'South-Southwest'
76
+ when 213.75..236.25
77
+ 'Southwest'
78
+ when 236.25..258.75
79
+ 'West-Southwest'
80
+ when 258.75..281.25
81
+ 'West'
82
+ when 281.25..303.75
83
+ 'West-Northwest'
84
+ when 303.75..326.25
85
+ 'Northwest'
86
+ when 326.25..348.75
87
+ 'North-Northwest'
88
+ end
89
+ end
45
90
  end
@@ -1,3 +1,3 @@
1
1
  module RatelessBot
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rateless_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Heuken