def __init__(self, api_key, device_identifier): super().__init__(device_identifier) self._api_key = api_key self._notification_service = Pushbullet(self._api_key) self._device = self.get_device()
from pushbullet.pushbullet import Pushbullet #import wolframalpha import json import tungsten pb = Pushbullet(api_key="PUSHBULLET_API_KEY") wolf_api = "WOLFRAMALPHA_API_KEY" #client = wolframalpha.Client(wolf_api) client = tungsten.Tungsten(wolf_api) pushes = pb.get_pushes() f = open("sent.json") sent = json.loads(f.read()) f.close() for push in pushes: if 'body' in push.keys() and push['body'].startswith( 'Hey Jarvis') and push['iden'] not in sent: try: sent.append(push['iden']) res = client.query(push['body'][11:]) if res.success: print "Success" print[pod.format['plaintext'][0] for pod in res.pods] results = [ pod.format['plaintext'][0] for pod in res.pods if type(pod.format['plaintext'][0]) is not None ] if len(results) != 0: pb.push_note(title=push['body'][11:],