Commit eef4d241 authored by Liothen's avatar Liothen
Browse files

Update to 2.0.0

- Modified Seen plugin
- Updated Weather Plugin
-- Removed WeatherUnground (discontinued API)
-- Updated math on air pressure
- Updated bin commands
- Updated dependancies
parent 84c157a5
Pipeline #236 failed with stages
in 55 seconds
source 'https://rubygems.org'
# Specify your gem's dependencies in Zeta.gemspec
gemspec
PATH
remote: .
specs:
zetabot (1.0.2)
zetabot (1.1.0)
actionview
chronic
chronic_duration
......@@ -42,18 +42,18 @@ GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.0.3)
actionview (5.2.1)
activesupport (= 5.2.1)
actionview (5.2.2)
activesupport (= 5.2.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activesupport (5.2.1)
activesupport (5.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
afm (0.2.2)
ansi (1.5.0)
......@@ -72,17 +72,17 @@ GEM
cinch (~> 2.0)
cinch-toolbox (1.1.6)
nokogiri (~> 1.6)
clipboard (1.1.2)
clipboard (1.3.3)
code (0.9.2)
coderay (~> 1.1)
method_source (~> 0.9)
coderay (1.1.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.4)
connection_pool (2.2.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4)
daemons (1.2.6)
daemons (1.3.1)
debugging (1.1.1)
binding.repl (~> 3.0)
paint (>= 0.9, < 3.0)
......@@ -90,7 +90,7 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
destructor (0.1.0)
diff-lcs (1.3)
discourse_api (0.27.0)
discourse_api (0.33.0)
faraday (~> 0.9)
faraday_middleware (~> 0.10)
rack (>= 1.6)
......@@ -100,18 +100,18 @@ GEM
dronebl.rb (0.1.0.0)
httparty (~> 0.13)
nokogiri (~> 1.6)
erubi (1.7.1)
erubi (1.8.0)
every_day_irb (2.0.0)
cd (~> 1.0)
fancy_irb (1.1.0)
paint (>= 0.9, < 3.0)
unicode-display_width (~> 1.1)
faraday (0.12.2)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.12.2)
faraday_middleware (0.13.1)
faraday (>= 0.7.4, < 1.0)
ffi (1.9.25)
geocoder (1.5.0)
ffi (1.10.0)
geocoder (1.5.1)
gist (5.0.0)
github_api (0.18.2)
addressable (~> 2.4)
......@@ -127,10 +127,11 @@ GEM
hirb (0.7.3)
http-cookie (1.0.3)
domain_name (~> 0.5)
httparty (0.16.2)
httparty (0.16.4)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
humanize-bytes (2.2.0)
i18n (1.1.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
instance (0.2.0)
interactive_editor (0.0.11)
......@@ -157,9 +158,9 @@ GEM
ruby_version (~> 1.0)
wirb (~> 2.0)
iso8601 (0.9.1)
jwt (1.5.6)
jwt (2.1.0)
liner (0.2.4)
loofah (2.2.2)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mechanize (2.7.6)
......@@ -174,12 +175,12 @@ GEM
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_locator (0.0.4)
method_source (0.9.0)
method_source (0.9.2)
methodfinder (2.2.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_portile2 (2.3.0)
mini_portile2 (2.4.0)
minitest (5.11.3)
mkfifo (0.1.1)
multi_json (1.13.1)
......@@ -190,13 +191,13 @@ GEM
connection_pool (~> 2.2)
net_http_timeout_errors (0.3.3)
netrc (0.11.0)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
ntlm-http (0.1.1)
numerizer (0.1.1)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
......@@ -205,9 +206,9 @@ GEM
ruby-ll (~> 2.1)
ori (0.1.0)
os (1.0.0)
paint (2.0.1)
paint (2.1.0)
parslet (1.8.2)
pdf-reader (2.1.0)
pdf-reader (2.2.0)
Ascii85 (~> 1.0.0)
afm (~> 0.2.1)
hashery (~> 2.0)
......@@ -215,7 +216,7 @@ GEM
ttfunk
persist (1.0.0)
public_suffix (3.0.3)
rack (2.0.5)
rack (2.0.6)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
......@@ -233,7 +234,7 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
......@@ -247,14 +248,14 @@ GEM
ruby_engine (1.0.1)
ruby_info (1.0.1)
ruby_version (1.0.1)
safe_yaml (1.0.4)
safe_yaml (1.0.5)
signed_multiset (0.2.1)
spoon (0.0.6)
ffi
tag_formatter (0.0.3)
temple (0.8.0)
temple (0.8.1)
thread_safe (0.3.6)
tilt (2.0.8)
tilt (2.0.9)
time-lord (1.0.1)
ttfunk (1.5.1)
tzinfo (1.2.5)
......@@ -262,7 +263,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)
unicode-display_width (1.5.0)
unitwise (2.2.0)
liner (~> 0.2)
memoizable (~> 0.4)
......@@ -291,4 +292,4 @@ DEPENDENCIES
zetabot!
BUNDLED WITH
1.16.1
1.17.2
# Zeta
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/Zeta`. To experiment with that code, run `bin/console` for an interactive prompt.
TODO: Delete this and the text above, and describe your gem
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'Zeta'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install Zeta
## Usage
TODO: Write usage instructions here
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Zeta.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
# Zbot
Cinch IRC bot written with plenty of help. I will not claim any of the plugins
And will try to get the correct credits in source
# Installation
Zeta requires ruby >= 2.5.0 and rubygems. Installation beyond that is simple
_Steps_
* gem install zetabot
* zetabot
_Plugins_
All plugins are automatically loaded that are in the plugins directory
# Upgrade
_Steps_
* git pull
* bundle
* update config files to new examples
* ruby ./migrate.rb
* ruby ./zeta.rb
## Commands
roles: owner,admin,operator,halfop,voice,nobody
prefix: ?
### Admin
_Channel_
** Role Required: admin/owner **
* ?join (\#channel) - admin
* ?part (\#channel) - admin
* ?quit (\#channel) - owner
_Plugins_
** Role Required: admin **
* ?plugin load (plugin)
* ?plugin unload (plugin)
* ?plugin reload (plugin)
* ?plugin set (plugin)
_Developer_
** Role Required: owner **
* ?die (msg) // Kills the bot
* ?e code // (alias: eval) Evaluate command
* ?em code // (alias: eval) Evaluate command send in msg
* ?er code // (alias: evalreply) Evaluate command and send to channel
_Ignore_
** Role Required: operator **
* ?ignore (user)
* ?unignore (user)
_Channel_
** Role Required: operator **
* ?disable (channel) // can omit channel to use current
* ?enable (channel) // enalbed a channel that has been disabled
_Access_
** Role Required: voice **
* ?setaccess (user) (level) // Levels: nobody,voice,halfop,operator,admin,owner,founder
* ?access (user) // Show current access level
_Uptime_
** Role Required: admin **
* ?uptime // Bot uptime
* ?sysuptime // grabs the uptime from current system
* ?users // shows users currently logged into shell
### Macros
Macros are prefixed by a period and are loaded from locales/macros.yml
example. typing in ".dnf" in channel will cause the bot to respond with "Duke Nukem Forever came out. Your argument is invalid."
### FIFO
Zeta will open a named pipe under bot/zeta.io messages sent to this pipe will be directly sent to the irc server
### Plugins
_Utility_
* ?calc (query) - Returns a wolframalpha solution
* ?wiki (term) - Returns a wikipedia entry
_Code Runner_
* ?run (lang) (code)
* ?langs - lists all of the languages that are supported
_Seen_
* ?seen (user)
_Misc_
* ?attack (target)
* ?info (plugin)
* ?fnord
* ?xmas - days till christmas
* ?mayan - current day in the mayan calendar
* ?newyear - days until new years
* ?heavymetalise (message) - styles the vowles of the text
* ?rainbow (text) - colorizes your text
* ?eyerape (text) - even worse then rainbow
* ?rr (nick) - Play a game of Russian Rullete
* ?fml - Returns a "F*ck My Life"
_GifMe_
* ?randomgif - grabs a random gif from gifme
* ?gif (term) - returns the best match from gifme
_Movie_
* ?movie (movie name) :year - the year is optional but must be prefixed with a colon
_Urban Dictionary_
* ?ud (definition) - returns a definition
* ?wotd - World of the day
_Weather_
* ?w (location)
* ?wx (location)
* ?setw (location) - Sets your current location so the bot will remember if you do ?w
* ?hurricane - gets current hurricane activity
* ?forecast (location)
_PDF Info_
This plugin grabs the metadata from a pdf that is linked in channel
_DBZ_
responds when you say certain keywords
### Network Specific Plugins
#### FlagRun Networks
_URL Grabber_
Grabs metadata from url in channel
#### DarkScience
_API_
* ?finger (nick) - pulls nickname information from the DarkScience API
* ?stats (nick) - pulls statistics information for a nick from the DarkScience API
* ?peek (channel) - pulls channel information from Darkscience API
_QDB_
* ?addquote (text) - submits quote to DarkScience API
* ?quote (id) - grabs the quote matching that ID for the specific channel
* ?quote - grabs random quote for channel
_LibSecure_
** only works in \#libsecure channel **
* ?latest - grabs the latest post from libsecure
GEM
specs:
PLATFORMS
ruby
DEPENDENCIES
BUNDLED WITH
1.16.1
......@@ -6,7 +6,6 @@ module Plugins
def to_s
# "[#{time.asctime}] #{who} was seen in #{where} last saying #{what}"
time_ago = time_ago_in_words(Time.at(time))
# "[ \x1F#{where.to_s.upcase}\x0F ] \x0304#{who}\x0F: \"\x0303#{what[0..300]}\x0F\" \x02#{time_ago}\x0F ago"
if where.to_s.upcase == 'STAFF' || where.to_s.upcase == 'SERVICES'
return ''
end
......
......@@ -39,17 +39,17 @@ module Plugins
# Lookup user from pstore
if !@store[msg.user.to_s].nil? && query.nil?
stored_location, stored_source = @store[msg.user.to_s].split('::')
stored_source = @api_src.include?(stored_source) ? stored_source : 'wu'
stored_source = @api_src.include?(stored_source) ? stored_source : 'darksky'
data = send("#{stored_source}_src", stored_location)
# location = geolookup(@store[msg.user.to_s])
# data = wunderground_src(stored_location, false)
elsif query.nil?
return msg.reply 'No location set. ?setw <location> :(wu|darkscy|noaa|apixu|owm)'
return msg.reply 'No location set. ?setw <location> :(darksky|noaa|apixu|owm)'
else
# data = wu_src(query, true)
src = query[/:\w+/].gsub(/:/, '') if query[/:\w+/]
query = query.gsub(/:\w+/, '').strip if query
true_src = @api_src.include?(src) ? src : 'wu'
true_src = @api_src.include?(src) ? src : 'darksky'
data = send("#{true_src}_src", query)
end
return msg.reply "No results found for #{query} with #{true_src} source." if data.nil?
......@@ -64,7 +64,7 @@ module Plugins
query = query.gsub(/:\w+/, '').strip if query
# Sanity Check
true_src = @api_src.include?(src) ? src : 'wu'
true_src = @api_src.include?(src) ? src : 'darksky'
data = send("#{true_src}_src", query)
# Error
......@@ -76,106 +76,13 @@ module Plugins
msg.reply "Your location is now set to #{data.ac.name}, #{data.ac.c}!"
end
# ?hurricane
def hurricane(msg)
url = URI.encode "http://api.wunderground.com/api/#{Zsec.wunderground}/currenthurricane/view.json"
location = JSON.parse(
# RestClient.get(url)
open(url).read
)
return msg.reply "No results found for #{query}." if location.nil?
reply_msg = "∴ #{location['currenthurricane'][0]['stormInfo']['stormName_Nice']} " \
"(#{location['currenthurricane'][0]['stormInfo']['stormNumber']}) "\
"≈ Category #{location['currenthurricane'][0]['Current']['SaffirSimpsonCategory']} " \
"≈ Wind #{location['currenthurricane'][0]['Current']['WindSpeed']['Mph']} mph " \
"(#{location['currenthurricane'][0]['Current']['WindSpeed']['Kph']} kph) " \
"≈ Wind Gust #{location['currenthurricane'][0]['Current']['WindGust']['Mph']} mph " \
"(#{location['currenthurricane'][0]['Current']['WindGust']['Kph']} kph) " \
"≈ #{location['currenthurricane'][0]['Current']['Time']['pretty']} ∴"
msg.reply(reply_msg)
end
# ?almanac <location>
def almanac(msg, locale)
autocomplete = JSON.parse(open(URI.encode("http://autocomplete.wunderground.com/aq?query=#{locale}")).read)
url = URI.encode("http://api.wunderground.com/api/#{Config.secrets[:wunderground]}/almanac/#{autocomplete['RESULTS'][0]['l']}.json")
location = JSON.parse(
# RestClient.get(url)
open(url).read
)
return msg.reply "No results found for #{query}." if location.nil?
time = Time.now()
data = OpenStruct.new(
date: time.strftime('%B, %d %Y (%A) '),
airport: location['almanac']['airport_code'],
high_norm_f: location['almanac']['temp_high']['normal']['F'],
high_norm_c: location['almanac']['temp_high']['normal']['C'],
high_record_y: location['almanac']['temp_high']['recordyear'],
high_record_f: location['almanac']['temp_high']['record']['F'],
high_record_c: location['almanac']['temp_high']['normal']['C'],
low_norm_f: location['almanac']['temp_low']['normal']['F'],
low_norm_c: location['almanac']['temp_low']['normal']['C'],
low_record_y: location['almanac']['temp_low']['recordyear'],
low_record_f: location['almanac']['temp_low']['record']['F'],
low_record_c: location['almanac']['temp_low']['normal']['C'],
)
reply_msg = "∴ Almanac #{data.date} ≈ Airport #{data.airport} " \
"≈ Normal #{data.high_norm_f} F (#{data.high_norm_c} C) | #{data.low_norm_f} F (#{data.low_norm_c} C) " \
"≈ High #{data.high_record_f} F (#{data.high_record_c} C) [#{data.high_record_y}] " \
"≈ Low #{data.low_record_f} F (#{data.low_record_c} C) [#{data.low_record_y}] ∴"
msg.reply(reply_msg)
end
# -private
private
#### Weather Sources
# Weather Underground - https://wunderground.com
def wu_src(location)
# Fuzzy location lookup
ac = JSON.parse(
open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
object_class: OpenStruct
)
return nil if ac.RESULTS.empty?
ac = ac.RESULTS[0]
geolookup = JSON.parse(
open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{ac.l}.json")).read,
object_class: OpenStruct
).location.l rescue nil
# Get Data
data = JSON.parse(
open("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/alerts/conditions#{geolookup}.json").read,
object_class: OpenStruct
)
debug "DATA: #{data}"
data.ac = ac
current = data.current_observation
alerts = data.alerts.empty? ? 'none' : data.alerts.map {|l| l['type']}.join(',')
# pressure_si = Unitwise((current.pressure_in.to_f)+14.7, '[psi]').convert_to('kPa').to_f.round(2)
data.reply = "WU ∴ #{ac.name}, #{ac.c} " \
"≈ #{current.weather} #{current.temperature_string} " \
"≈ Feels like #{current.feelslike_string} " \
"≈ Humidity: #{current.relative_humidity} " \
"≈ Pressure: #{current.pressure_in} in/Hg (#{current.pressure_mb} mbar) " \
"≈ Wind: #{current.wind_string} ≈ Alerts: #{alerts} ∴"
return data
# rescue
# return nil
end
# Open Weather map - https://openweathermap.org/api
def owm_src(location)
ac = JSON.parse(
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
open(URI.encode("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}")).read,
object_class: OpenStruct
)
......@@ -194,13 +101,14 @@ module Plugins
)
temp = Unitwise(data.main.temp, 'K') # Data is given in kelvin
pressure = Unitwise((data.main.pressure.to_f/10)+101, 'kPa')
pressure = Unitwise(data.main.pressure.to_f, 'mbar')
wind = Unitwise(data.wind.speed, 'kilometer')
data.reply = "OWM ∴ #{ac.formatted_address} " \
"≈ #{data.weather[0].description}, #{temp.convert_to('[degF]').to_i.round(2)} F (#{temp.convert_to('Cel').to_i.round(2)} C) " \
"≈ Humidity: #{data.main.humidity}% " \
"≈ Pressure: #{pressure.convert_to('[psi]').to_f.round(2)} in/Hg (#{data.main.pressure} mbar) " \
"≈ Pressure: #{pressure.convert_to('[in_i\'Hg]').to_f.round(2)} in/Hg " \
"(#{pressure.convert_to("kPa").to_f.round(2)} kPa) " \
"≈ Wind: #{wind.convert_to('mile').to_i.round(2)} mph (#{wind.to_i.round(2)} km/h) ∴"
return data
......@@ -210,7 +118,7 @@ module Plugins
# DarkSky - https://darksky.net/dev
def darksky_src(location)
ac = JSON.parse(
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
open(URI.encode("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}")).read,
object_class: OpenStruct
)
return nil if ac.results.nil? ## Unable to locate
......@@ -230,7 +138,7 @@ module Plugins
alerts = data.alerts.count rescue 0
c = Unitwise(current.temperature, '[degF]').convert_to('Cel').to_i
c_feels = Unitwise(current.apparentTemperature, '[degF]').convert_to('Cel').to_i
p = Unitwise((current.pressure.to_f/10)+101, 'kPa')
p = Unitwise(current.pressure.to_f, 'mbar')
gusts = Unitwise(current.windGust, 'mile').convert_to('kilometer').to_i
tempstring = "#{current.temperature.to_i} F (#{c} C)"
......@@ -240,7 +148,8 @@ module Plugins
"≈ #{current.summary} #{tempstring} " \
"≈ Feels like #{feelslike} " \
"≈ Humidity: #{current.relative_humidity} " \
"≈ Pressure: #{p.convert_to('[psi]').to_f.round(2)} in/Hg (#{current.pressure} mbar) " \
"≈ Pressure: #{p.convert_to('[in_i\'Hg]').to_f.round(2)} in/Hg " \
"(#{p.convert_to("kPa").to_f.round(2)} kPa) " \
"≈ Wind: gusts upto #{current.windGust} mph (#{gusts} km/h) ≈ Alerts: #{alerts} ∴"
return data
......@@ -251,7 +160,7 @@ module Plugins
# NOAA - https://graphical.weather.gov/xml/
def noaa_src(location)
ac = JSON.parse(
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
open(URI.encode("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}")).read,
object_class: OpenStruct
)
return nil if ac.results.nil? ## Unable to locate
......@@ -278,13 +187,14 @@ module Plugins
temp = "#{f.round(2)} F (#{data.temperature.value.to_i.round(2)} C) "
wind = "Gusts: #{data.windGust.value} avg: #{data.windSpeed.value.to_i.round(2)}"
feelslike = "#{data.windChill.value.to_i.round(2)} C"
pressure = Unitwise(data.barometricPressure.value.to_f+101325, 'Pa')
pressure = Unitwise(data.barometricPressure.value.to_f, 'Pa')
data.reply = "NOAA ∴ #{ac.formatted_address} " \
"≈ #{data.textDescription} #{temp} " \
"≈ Feels like #{feelslike} " \
"≈ Humidity: #{data.relativeHumidity.value.round(2)} " \
"≈ Pressure: #{pressure.convert_to('[psi]').to_f.round(2)} in/Hg (#{pressure.convert_to('kPa').to_f} mbar) " \
"≈ Pressure: #{pressure.convert_to('[in_i\'Hg]').to_f.round(2)} in/Hg " \
"(#{pressure.convert_to("kPa").to_f.round(2)} kPa) " \
"≈ Wind: #{wind} ≈ Alerts: ∴"
return data
# rescue
......
module Zeta
VERSION = '1.1.0'
VERSION = '2.0.0'
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment