zetabot 2.1.0 → 2.1.1
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 +4 -4
 - data/Gemfile.lock +1 -1
 - data/README.md +17 -9
 - data/lib/Zeta/config.rb +2 -0
 - data/lib/Zeta/plugins/darkscience.rb +10 -10
 - data/lib/Zeta/plugins/weather.rb +5 -46
 - data/lib/Zeta/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0b53140618ee18e26da975b11636994b8e2e1d1b0a706d2f71bf4a5056d6bbec
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 72d919a4e0df285f135ebc1aece8077cf8de4e44fb2fe990bbae98decb5ab173
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: db34a813f6c4770564e2b68f30be17f677269c9e175952464693e817376e69564bbc1f28880c05ef2cf96e1792d7bcb531cab5f63d605dcec7f377e32a01a116
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 88078ed8cfa8bb1beae4d5b56bb103ed6aabfbb527c5c80a3d261b64da3a2b3a4040b90b20cbca7e82bb14617eb1ecde3823fa7dbf1b9e691a63e4ed1793cec0
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -3,23 +3,31 @@ Cinch IRC bot written with plenty of help. I will not claim any of the plugins 
     | 
|
| 
       3 
3 
     | 
    
         
             
            And will try to get the correct credits in source
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            # Installation
         
     | 
| 
       6 
     | 
    
         
            -
            Zeta requires ruby >= 2. 
     | 
| 
      
 6 
     | 
    
         
            +
            Zeta requires ruby >= 2.7.6 and rubygems. Installation beyond that is simple
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            _Steps_
         
     | 
| 
       9 
9 
     | 
    
         
             
            * gem install zetabot
         
     | 
| 
       10 
10 
     | 
    
         
             
            * zetabot
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            _Docker_
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Zeta will need its config file mounted in the `.zeta/config.rb` image for her to function. 
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ```dockerfile
         
     | 
| 
      
 18 
     | 
    
         
            +
            FROM docker.io/ruby:2.7.6
         
     | 
| 
      
 19 
     | 
    
         
            +
            RUN useradd zeta -m
         
     | 
| 
      
 20 
     | 
    
         
            +
            USER zeta
         
     | 
| 
      
 21 
     | 
    
         
            +
            WORKDIR /home/zeta/
         
     | 
| 
      
 22 
     | 
    
         
            +
            RUN mkdir .zeta .zeta/cache .zeta/log && \
         
     | 
| 
      
 23 
     | 
    
         
            +
                gem install zetabot
         
     | 
| 
      
 24 
     | 
    
         
            +
            # Run zeta
         
     | 
| 
      
 25 
     | 
    
         
            +
            CMD [ "zetabot"]
         
     | 
| 
      
 26 
     | 
    
         
            +
            ```
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       12 
28 
     | 
    
         
             
            _Plugins_
         
     | 
| 
       13 
29 
     | 
    
         
             
            All plugins are automatically loaded that are in the plugins directory
         
     | 
| 
       14 
30 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            # Upgrade
         
     | 
| 
       16 
     | 
    
         
            -
            _Steps_
         
     | 
| 
       17 
     | 
    
         
            -
            * git pull
         
     | 
| 
       18 
     | 
    
         
            -
            * bundle
         
     | 
| 
       19 
     | 
    
         
            -
            * update config files to new examples
         
     | 
| 
       20 
     | 
    
         
            -
            * ruby ./migrate.rb
         
     | 
| 
       21 
     | 
    
         
            -
            * ruby ./zeta.rb
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
31 
     | 
    
         
             
            ## Commands
         
     | 
| 
       24 
32 
     | 
    
         
             
            roles: owner,admin,operator,halfop,voice,nobody
         
     | 
| 
       25 
33 
     | 
    
         
             
            prefix: ?
         
     | 
    
        data/lib/Zeta/config.rb
    CHANGED
    
    
| 
         @@ -34,7 +34,7 @@ module Plugins 
     | 
|
| 
       34 
34 
     | 
    
         
             
                        RestClient.post(
         
     | 
| 
       35 
35 
     | 
    
         
             
                            'https://darchoods.net/api/irc/channel/view',
         
     | 
| 
       36 
36 
     | 
    
         
             
                            {
         
     | 
| 
       37 
     | 
    
         
            -
                              auth_token: Config. 
     | 
| 
      
 37 
     | 
    
         
            +
                              auth_token: Config.quotes_api_key,
         
     | 
| 
       38 
38 
     | 
    
         
             
                              channel: chan,
         
     | 
| 
       39 
39 
     | 
    
         
             
                            }
         
     | 
| 
       40 
40 
     | 
    
         
             
                        )
         
     | 
| 
         @@ -67,7 +67,7 @@ module Plugins 
     | 
|
| 
       67 
67 
     | 
    
         
             
                        RestClient.post(
         
     | 
| 
       68 
68 
     | 
    
         
             
                            'https://darchoods.net/api/irc/user/view',
         
     | 
| 
       69 
69 
     | 
    
         
             
                            {
         
     | 
| 
       70 
     | 
    
         
            -
                              auth_token: Config. 
     | 
| 
      
 70 
     | 
    
         
            +
                              auth_token: Config.quotes_api_key,
         
     | 
| 
       71 
71 
     | 
    
         
             
                              username: nick,
         
     | 
| 
       72 
72 
     | 
    
         
             
                            }
         
     | 
| 
       73 
73 
     | 
    
         
             
                        )
         
     | 
| 
         @@ -106,9 +106,9 @@ module Plugins 
     | 
|
| 
       106 
106 
     | 
    
         
             
                  begin
         
     | 
| 
       107 
107 
     | 
    
         
             
                    data = JSON.parse(
         
     | 
| 
       108 
108 
     | 
    
         
             
                        RestClient.post(
         
     | 
| 
       109 
     | 
    
         
            -
                             
     | 
| 
      
 109 
     | 
    
         
            +
                            "https://#{Config.quotes_api_url}/api/irc/user/view",
         
     | 
| 
       110 
110 
     | 
    
         
             
                            {
         
     | 
| 
       111 
     | 
    
         
            -
                              auth_token: Config. 
     | 
| 
      
 111 
     | 
    
         
            +
                              auth_token: Config.quotes_api_key,
         
     | 
| 
       112 
112 
     | 
    
         
             
                              username: nick,
         
     | 
| 
       113 
113 
     | 
    
         
             
                            }
         
     | 
| 
       114 
114 
     | 
    
         
             
                        )
         
     | 
| 
         @@ -141,9 +141,9 @@ module Plugins 
     | 
|
| 
       141 
141 
     | 
    
         
             
                  begin
         
     | 
| 
       142 
142 
     | 
    
         
             
                    request = JSON.parse(
         
     | 
| 
       143 
143 
     | 
    
         
             
                        RestClient.post(
         
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
      
 144 
     | 
    
         
            +
                          "https://#{Config.quotes_api_url}/api/qdb/create",
         
     | 
| 
       145 
145 
     | 
    
         
             
                            {
         
     | 
| 
       146 
     | 
    
         
            -
                              auth_token: Config. 
     | 
| 
      
 146 
     | 
    
         
            +
                              auth_token: Config.quotes_api_key,
         
     | 
| 
       147 
147 
     | 
    
         
             
                              channel: m.channel,
         
     | 
| 
       148 
148 
     | 
    
         
             
                              author: m.user,
         
     | 
| 
       149 
149 
     | 
    
         
             
                              quote: quote
         
     | 
| 
         @@ -164,9 +164,9 @@ module Plugins 
     | 
|
| 
       164 
164 
     | 
    
         
             
                  begin
         
     | 
| 
       165 
165 
     | 
    
         
             
                    request = JSON.parse(
         
     | 
| 
       166 
166 
     | 
    
         
             
                        RestClient.post(
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 167 
     | 
    
         
            +
                          "https://#{Config.quotes_api_url}/api/qdb/search/byId",
         
     | 
| 
       168 
168 
     | 
    
         
             
                            {
         
     | 
| 
       169 
     | 
    
         
            -
                              auth_token: Config. 
     | 
| 
      
 169 
     | 
    
         
            +
                              auth_token: Config.quotes_api_key,
         
     | 
| 
       170 
170 
     | 
    
         
             
                              channel: m.channel,
         
     | 
| 
       171 
171 
     | 
    
         
             
                              quote_id: search
         
     | 
| 
       172 
172 
     | 
    
         
             
                            }
         
     | 
| 
         @@ -189,8 +189,8 @@ module Plugins 
     | 
|
| 
       189 
189 
     | 
    
         
             
                  begin
         
     | 
| 
       190 
190 
     | 
    
         
             
                    request = JSON.parse(
         
     | 
| 
       191 
191 
     | 
    
         
             
                        RestClient.post(
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
                            { auth_token: Config. 
     | 
| 
      
 192 
     | 
    
         
            +
                          "https://#{Config.quotes_api_url}/api/qdb/random",
         
     | 
| 
      
 193 
     | 
    
         
            +
                            { auth_token: Config.quotes_api_key,
         
     | 
| 
       194 
194 
     | 
    
         
             
                              channel: m.channel
         
     | 
| 
       195 
195 
     | 
    
         
             
                            }
         
     | 
| 
       196 
196 
     | 
    
         
             
                        )
         
     | 
    
        data/lib/Zeta/plugins/weather.rb
    CHANGED
    
    | 
         @@ -29,7 +29,7 @@ module Plugins 
     | 
|
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                #####
         
     | 
| 
       31 
31 
     | 
    
         
             
                def initialize(*args)
         
     | 
| 
       32 
     | 
    
         
            -
                  @api_src = %w{ 
     | 
| 
      
 32 
     | 
    
         
            +
                  @api_src = %w{noaa owm}
         
     | 
| 
       33 
33 
     | 
    
         
             
                  @store = Persist.new(File.join(Dir.home, '.zeta', 'cache', 'weather.pstore'))
         
     | 
| 
       34 
34 
     | 
    
         
             
                  super
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
         @@ -40,17 +40,17 @@ module Plugins 
     | 
|
| 
       40 
40 
     | 
    
         
             
                  # Lookup user from pstore
         
     | 
| 
       41 
41 
     | 
    
         
             
                  if !@store[msg.user.to_s].nil? && query.nil?
         
     | 
| 
       42 
42 
     | 
    
         
             
                    stored_location, stored_source = @store[msg.user.to_s].split('::')
         
     | 
| 
       43 
     | 
    
         
            -
                    stored_source = @api_src.include?(stored_source) ? stored_source : ' 
     | 
| 
      
 43 
     | 
    
         
            +
                    stored_source = @api_src.include?(stored_source) ? stored_source : 'owm'
         
     | 
| 
       44 
44 
     | 
    
         
             
                    data = send("#{stored_source}_src", stored_location)
         
     | 
| 
       45 
45 
     | 
    
         
             
                    # location = geolookup(@store[msg.user.to_s])
         
     | 
| 
       46 
46 
     | 
    
         
             
                    # data = wunderground_src(stored_location, false)
         
     | 
| 
       47 
47 
     | 
    
         
             
                  elsif query.nil?
         
     | 
| 
       48 
     | 
    
         
            -
                    return msg.reply 'No location set. ?setw <location> :( 
     | 
| 
      
 48 
     | 
    
         
            +
                    return msg.reply 'No location set. ?setw <location> :(noaa|owm)'
         
     | 
| 
       49 
49 
     | 
    
         
             
                  else
         
     | 
| 
       50 
50 
     | 
    
         
             
                    # data = wu_src(query, true)
         
     | 
| 
       51 
51 
     | 
    
         
             
                    src = query[/:\w+/].gsub(/:/, '') if query[/:\w+/]
         
     | 
| 
       52 
52 
     | 
    
         
             
                    query = query.gsub(/:\w+/, '').strip if query
         
     | 
| 
       53 
     | 
    
         
            -
                    true_src = @api_src.include?(src) ? src : ' 
     | 
| 
      
 53 
     | 
    
         
            +
                    true_src = @api_src.include?(src) ? src : 'owm'
         
     | 
| 
       54 
54 
     | 
    
         
             
                    data = send("#{true_src}_src", query)
         
     | 
| 
       55 
55 
     | 
    
         
             
                  end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
         @@ -67,7 +67,7 @@ module Plugins 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  query = query.gsub(/:\w+/, '').strip if query
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
69 
     | 
    
         
             
                  # Sanity Check
         
     | 
| 
       70 
     | 
    
         
            -
                  true_src = @api_src.include?(src) ? src : ' 
     | 
| 
      
 70 
     | 
    
         
            +
                  true_src = @api_src.include?(src) ? src : 'owm'
         
     | 
| 
       71 
71 
     | 
    
         
             
                  data = send("#{true_src}_src", query)
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
73 
     | 
    
         
             
                  # Error
         
     | 
| 
         @@ -119,47 +119,6 @@ module Plugins 
     | 
|
| 
       119 
119 
     | 
    
         
             
                  return data
         
     | 
| 
       120 
120 
     | 
    
         
             
                end
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                # DarkSky - https://darksky.net/dev
         
     | 
| 
       123 
     | 
    
         
            -
                def darksky_src(location)
         
     | 
| 
       124 
     | 
    
         
            -
                  location = CGI.escape(location)
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
                  ac = JSON.parse(
         
     | 
| 
       127 
     | 
    
         
            -
                    RestClient.get("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}").body,
         
     | 
| 
       128 
     | 
    
         
            -
                    object_class: OpenStruct
         
     | 
| 
       129 
     | 
    
         
            -
                  )
         
     | 
| 
       130 
     | 
    
         
            -
                  return nil if ac.results.nil? ## Unable to locate
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                  ac = ac.results[0]
         
     | 
| 
       133 
     | 
    
         
            -
                  lat = ac.geometry.location.lat
         
     | 
| 
       134 
     | 
    
         
            -
                  lon = ac.geometry.location.lng
         
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
                  data = JSON.parse(
         
     | 
| 
       137 
     | 
    
         
            -
                    RestClient.get("https://api.darksky.net/forecast/#{Config.secrets[:darksky]}/#{lat},#{lon}").body,
         
     | 
| 
       138 
     | 
    
         
            -
                    object_class: OpenStruct
         
     | 
| 
       139 
     | 
    
         
            -
                  )
         
     | 
| 
       140 
     | 
    
         
            -
                  data.ac = ac
         
     | 
| 
       141 
     | 
    
         
            -
                  current = data.currently
         
     | 
| 
       142 
     | 
    
         
            -
                  alerts = data.alerts.count rescue 0
         
     | 
| 
       143 
     | 
    
         
            -
                  c = Unitwise(current.temperature, '[degF]').convert_to('Cel').to_i
         
     | 
| 
       144 
     | 
    
         
            -
                  c_feels = Unitwise(current.apparentTemperature, '[degF]').convert_to('Cel').to_i
         
     | 
| 
       145 
     | 
    
         
            -
                  p = Unitwise(current.pressure.to_f, 'mbar')
         
     | 
| 
       146 
     | 
    
         
            -
                  gusts = Unitwise(current.windGust, 'mile').convert_to('kilometer').to_i
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                  tempstring = "#{current.temperature.to_i} F (#{c} C)"
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
                  data.reply = "DS ∴ #{ac.formatted_address} " \
         
     | 
| 
       151 
     | 
    
         
            -
                              "≈ #{TZInfo::Timezone.get(data.timezone).now.strftime("%c")} " \
         
     | 
| 
       152 
     | 
    
         
            -
                              "≈ #{current.summary} #{tempstring} " \
         
     | 
| 
       153 
     | 
    
         
            -
                              "≈ Humidity: #{(current.humidity * 100).round(2)}% " \
         
     | 
| 
       154 
     | 
    
         
            -
                              "≈ Pressure: #{p.convert_to('[in_i\'Hg]').to_f.round(2)} in/Hg " \
         
     | 
| 
       155 
     | 
    
         
            -
                              "(#{p.convert_to("kPa").to_f.round(2)} kPa) " \
         
     | 
| 
       156 
     | 
    
         
            -
                              "≈ Wind: gusts upto #{current.windGust} mph (#{gusts} km/h) ≈ Alerts: #{alerts} ∴"
         
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
                  return data
         
     | 
| 
       159 
     | 
    
         
            -
                  # rescue
         
     | 
| 
       160 
     | 
    
         
            -
                  #   return nil
         
     | 
| 
       161 
     | 
    
         
            -
                end
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
122 
     | 
    
         
             
                # NOAA - https://graphical.weather.gov/xml/
         
     | 
| 
       164 
123 
     | 
    
         
             
                def noaa_src(location)
         
     | 
| 
       165 
124 
     | 
    
         
             
                  location = CGI.escape(location)
         
     | 
    
        data/lib/Zeta/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: zetabot
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Liothen
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-04-30 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -658,7 +658,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       658 
658 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       659 
659 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       660 
660 
     | 
    
         
             
            requirements: []
         
     | 
| 
       661 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 661 
     | 
    
         
            +
            rubygems_version: 3.3.7
         
     | 
| 
       662 
662 
     | 
    
         
             
            signing_key:
         
     | 
| 
       663 
663 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       664 
664 
     | 
    
         
             
            summary: Zeta is a IRC bot written in ruby using the Cinch Framework
         
     |