-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathephemeral.py
More file actions
30 lines (25 loc) · 1.04 KB
/
ephemeral.py
File metadata and controls
30 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from requests import post
from .base import Pushbullet, PushbulletException
# from re import match
class Sms(Pushbullet):
"""Initialize an SMS handler and format and sent SMS."""
def __init__(self, access_token):
super().__init__(access_token)
self.url = 'https://api.pushbullet.com/v2/ephemerals'
def send_sms(self, message, device, phone):
if (not self.me or
not device or
not phone):
raise PushbulletException('Missing required value (iden|device_id|phone)')
data = {'push': {
'package_name': 'com.pushbullet.android',
'type': 'messaging_extension_reply',
'conversation_iden': phone,
'source_user_iden': self.me['iden'],
'target_device_iden': device,
'message': message},
'type': 'push'}
response = post(url=self.url, headers=self.header, json=data)
if response.status_code == 200:
self.ratelimit(response)
return response