Sha256: 08de87485b4ea4a26629e8ef322bd06fc1d93a206b0b700690b7201c2ac0a9bc
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'washbullet' require 'pokeplot/helpers/time' module Pokeplot class Pushbullet def initialize(api_key, pokemon = []) @pokemon = pokemon @client = Washbullet::Client.new(api_key) end def started(event) if event.command.has_key?('insert') if event.command.fetch('insert') == 'encounters' if @pokemon.include?(event.command.fetch('documents')[0][:pokemon]) text = "Found a #{event.command.fetch('documents')[0][:pokemon]}! " time = Helpers::Time.to_s(Time.now.to_i - ((event.command.fetch('documents')[0][:current_timestamp_ms].to_i / 1000) -(event.command.fetch('documents')[0][:time_till_hidden_ms].to_i / 1000))) text += "It expires in #{time}. " text += "Google maps: http://www.google.com/maps/place/#{event.command.fetch('documents')[0][:latitude]},#{event.command.fetch('documents')[0][:longitude]}" @client.devices.each do |device| @client.push_note( receiver: :device, identifier: device.body['iden'], params: { title: 'Pokeplot', body: text } ) end end end end end def failed(_); end def succeeded(_); end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pokeplot-0.2.1beta | lib/pokeplot/pushbullet.rb |
pokeplot-0.2.0beta | lib/pokeplot/pushbullet.rb |