Sha256: 8c3ebb5a1784e6cc67cc899e67a1702d83ff2e1e93e5ec83c0bdb35031b6c8c6
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# -*- coding: utf-8 -*- require 'cinch' require 'cinch/cooldown' require 'time-lord' require 'weather-underground' module Cinch::Plugins class Weatherman include Cinch::Plugin enforce_cooldown self.help = "Use .w <location> to see information on the weather. (e.g. .w 94062)" match /w (.*)/ match /weather (.*)/ def execute(m, query) m.reply get_weather(query) end private def get_weather(query) location, temp_f, conditions, updated = get_forcast(query) message = "In #{location} it is #{conditions} " message << "and #{temp_f}°F " message << "(last updated about #{updated})" return message rescue ArgumentError return "Sorry, couldn't find #{query}." end def get_forcast(query) data = WeatherUnderground::Base.new.CurrentObservations(query) weather = [ data.display_location.first.full, data.temp_f, data.weather.downcase, Time.parse(data.observation_time).ago.to_words ] return weather end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cinch-weatherman-1.0.1 | lib/cinch/plugins/weatherman/weatherman.rb |