class PushBulletSender(Sender): def __init__(self, setting): super(PushBulletSender, self).__init__(setting) self.pushbullet = PushBullet(self.config_api) if hasattr(self, 'config_channel'): self.pushbullet = self.pushbullet.get_channel(self.config_channel) def post(self, title, message, url): if url: message = '{}\n{}'.format(message, url) self.pushbullet.push_note(title, message)
class PB_Alarm(Alarm): def __init__(self, api_key): self.client = PushBullet(api_key) log.info("PB_Alarm intialized.") push = self.client.push_note("PokeAlarm activated!", "We will alert you about pokemon.") def pokemon_alert(self, pokemon): #notification_text = "A wild " + pokemon['name'].title() + " has appeared!" # Or retrieve a channel by its channel_tag. Note that an InvalidKeyError is raised if the channel_tag does not exist #your pushbullet channelname my_channel = self.client.get_channel('YOURCHANNELNAME') google_maps_link = gmaps_link(pokemon["lat"], pokemon["lng"]) time_text = pkmn_time_text(pokemon['disappear_time']) notification_text = "("+ pokemon['name'].title() + " found" +"! "+" " + time_text + "." push = self.client.push_link(notification_text, google_maps_link, body=time_text) #send to channel push = self.client.push_link(notification_text, google_maps_link, body=time_text, channel=my_channel)
if uid in checked: continue checked.append(uid) yield dict(id=uid, title=title, description=SoditChannel.SODIT_FUND_URL + url) curr += 1 if self.max_item <= 0: continue if curr >= self.max_item: raise StopIteration bullet = PushBullet(CONFIG.PUSHBULLET_API) if CONFIG.PUSHBULLET_CHANNEL: bullet = bullet.get_channel(CONFIG.PUSHBULLET_CHANNEL) def push(title, message): bullet.push_note(title, message) channels = [ (u'탱커펀드', TankerFundChannel), (u'테라펀딩', TeraFundChannel), (u'루프펀딩', RoofFundChannel), (u'빌리', VillyChannel), (u'소딧', SoditChannel), ]