Skip to content

Instantly share code, notes, and snippets.

@heywoodlh
Created February 27, 2018 22:51
Show Gist options
  • Save heywoodlh/da9d86f80f021db9114d868b774ed078 to your computer and use it in GitHub Desktop.
Save heywoodlh/da9d86f80f021db9114d868b774ed078 to your computer and use it in GitHub Desktop.
Pushbullet SMS Scripts

Credit for the foundation of this program goes to Pushbullet.py: https://github.com/randomchars/pushbullet.py

Installation:

Download the repository: git clone https://github.com/heywoodlh/pushbullet-sms-cli

Install the dependencies: pip3 install -r requirements.txt

Configuration:

Edit the api_token and device_id variable in pb-messages.py to reflect the appropriate Pushbullet API Key and Pushbullet device ID.

If you do not know the device ID just make sure that the api_token variable is properly set and run pb-messages.py to list all the devices:

./pb-messages.py

Usage examples:

Help:

./pb-messages.py -h

Send SMS to a phone number:

./pb-messages.py text +12223334444 'this is my message'

#!/usr/bin/env python3
from pushbullet import Pushbullet
import sys
## Edit these variables -- leave device_id blank if you aren't sure what it is ##
api_token = ''
device_id = ''
## Do not edit below this line ##
try:
commands = ['text']
if sys.argv[1] == '-h':
print('Syntax: ' + sys.argv[0] + ' ' + str(commands))
sys.exit(0)
except IndexError:
pass
if api_token == '':
print('Please enter valid api_token value in ' + sys.argv[0])
sys.exit(1)
pb = Pushbullet(api_token)
if device_id == '':
print('\n')
print("Please copy the correct device ID name and set the device_id variable in " + sys.argv[0])
print('\n')
print(str(pb.devices))
sys.exit(0)
device = pb.get_device(device_id)
if sys.argv[1] == 'text':
try:
if sys.argv[2] and sys.argv[3]:
push = pb.push_sms(device, sys.argv[2], sys.argv[3])
except IndexError:
print("Syntax: " + sys.argv[0] + " text +12223334444 'this is my message'")
#!/usr/bin/env python3
from pushbullet import Pushbullet
import sys
import time
## Edit these variables -- leave device_id blank if you aren't sure what it is ##
api_token = ''
device_id = ''
message = 'Spamming is illegal: https://www.consumer.ftc.gov/articles/0350-text-message-spam'
if api_token == '':
print('Please enter valid api_token value in ' + sys.argv[0])
sys.exit(1)
pb = Pushbullet(api_token)
if device_id == '':
print('\n')
print("Please copy the correct device ID name and set the device_id variable in " + sys.argv[0])
print('\n')
print(str(pb.devices))
sys.exit(1)
device = pb.get_device(device_id)
if len(sys.argv[1:]) < 1:
print('Usage: ' + sys.argv[0] + ' +1234567890 +1234567890')
sys.exit(1)
for phones in sys.argv[1:]:
try:
while (True):
push = pb.push_sms(device, phones, message)
time.sleep(1)
except KeyboardInterrupt:
print('Exiting.')
certifi==2017.7.27.1
chardet==3.0.4
idna==2.5
pushbullet.py==0.11.0
python-magic==0.4.13
requests==2.18.3
six==1.10.0
urllib3==1.22
websocket-client==0.44.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment