├── .gitignore ├── LICENSE ├── Pipfile ├── Pipfile.lock ├── README.md ├── setup.py └── termtext /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Muhammad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | docopt = "==0.6.2" 8 | twilio = "*" 9 | 10 | [dev-packages] 11 | 12 | [requires] 13 | python_version = "3.6" 14 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "6b3136be47897ccf91c55f3c1063c0e554e02b291d8939c7a36a14f132e73945" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.6" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": { 19 | "certifi": { 20 | "hashes": [ 21 | "sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50", 22 | "sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef" 23 | ], 24 | "version": "==2019.9.11" 25 | }, 26 | "chardet": { 27 | "hashes": [ 28 | "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", 29 | "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" 30 | ], 31 | "version": "==3.0.4" 32 | }, 33 | "docopt": { 34 | "hashes": [ 35 | "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" 36 | ], 37 | "index": "pypi", 38 | "version": "==0.6.2" 39 | }, 40 | "idna": { 41 | "hashes": [ 42 | "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", 43 | "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" 44 | ], 45 | "version": "==2.8" 46 | }, 47 | "pyjwt": { 48 | "hashes": [ 49 | "sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e", 50 | "sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96" 51 | ], 52 | "version": "==1.7.1" 53 | }, 54 | "pysocks": { 55 | "hashes": [ 56 | "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299", 57 | "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5", 58 | "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0" 59 | ], 60 | "markers": "python_version >= '3.0'", 61 | "version": "==1.7.1" 62 | }, 63 | "pytz": { 64 | "hashes": [ 65 | "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d", 66 | "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be" 67 | ], 68 | "version": "==2019.3" 69 | }, 70 | "requests": { 71 | "hashes": [ 72 | "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", 73 | "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" 74 | ], 75 | "markers": "python_version >= '3.0'", 76 | "version": "==2.22.0" 77 | }, 78 | "six": { 79 | "hashes": [ 80 | "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", 81 | "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" 82 | ], 83 | "version": "==1.12.0" 84 | }, 85 | "twilio": { 86 | "hashes": [ 87 | "sha256:372db8745c923c59ba9c48e44d359e81029bc6be0a6dffd1f1d299406691b1f2", 88 | "sha256:c8844de8e1b3e653d970e9f13925de148d13dd78d865a07c91833fd74135e8a4" 89 | ], 90 | "index": "pypi", 91 | "version": "==6.19.2" 92 | }, 93 | "urllib3": { 94 | "hashes": [ 95 | "sha256:4c291ca23bbb55c76518905869ef34bdd5f0e46af7afe6861e8375643ffee1a0", 96 | "sha256:9a247273df709c4fedb38c711e44292304f73f39ab01beda9f6b9fc375669ac3" 97 | ], 98 | "index": "pypi", 99 | "version": "==1.24.2" 100 | } 101 | }, 102 | "develop": {} 103 | } 104 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Terminal Text 2 | A simple python module that allows you send text messages to your phone. 3 | 4 | ### Installation 5 | - `pip install terminal-text` install the module 6 | - export `EMAIL = Your Email` 7 | - export `PASS = Your login password` 8 | - export `SMTP` , smtp setting from your email for example `smtp.gmail.com` 9 | - export `PORT` , SMTP port 10 | - export `SMS_GATEWAY` the sms gateway of your carrier. 11 | - export `IMAP_HOST` 12 | ### SMS GATEWAYS 13 | - AT&T: [number]@txt.att.net 14 | - Sprint: [number]@messaging.sprintpcs.com or [number]@pm.sprint.com 15 | - T-Mobile: [number]@tmomail.net 16 | - Verizon: [number]@vtext.com 17 | - Boost Mobile: [number]@myboostmobile.com 18 | - Cricket: [number]@sms.mycricket.com 19 | - Metro PCS: [number]@mymetropcs.com 20 | - Tracfone: [number]@mmst5.tracfone.com 21 | - U.S. Cellular: [number]@email.uscc.net 22 | - Virgin Mobile: [number]@vmobl.com 23 | - Google Fi: [number]@msg.fi.google.com 24 | - Ting: [number]@message.ting.com 25 | - Telus Mobile: [number]@msg.telus.com 26 | - Viaero: [number]@viaerosms.com 27 | 28 | **NOTE**: Make sure to add **+1** before the number. 29 | 30 | ### Usage 31 | - `termtext -m "Enter Message\n"` 32 | - `termtext notify` to see whether you received a message 33 | 34 | 35 | ### Contribution 36 | - This module is available under MIT license. 37 | - if you would like to contribute to this module feel free to fork and create a PR. 38 | 39 | 40 | # NOTE THIS REPO HAS BEEN MOVED TO [MTDEVSS](https://github.com/mtdevss) AND NEW UPDATE COMING SOON 41 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | with open("README.md", "r") as fh: 3 | long_description = fh.read() 4 | setup( 5 | name='terminal-text', 6 | version='1.2', 7 | scripts=['termtext'], 8 | description='Its a simple commandline tool that allows you send text messages and mms to your phone using terminal', 9 | install_requires=[ 10 | "docopt", 11 | ], 12 | classifiers=[ 13 | 'Environment :: Console', 14 | 'Intended Audience :: Developers', 15 | 'Natural Language :: English', 16 | 'Programming Language :: Python', 17 | 'Programming Language :: Python :: 3.6' 18 | ], 19 | long_description=long_description, 20 | long_description_content_type='text/markdown' 21 | ) 22 | -------------------------------------------------------------------------------- /termtext: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | """termtext 3 | 4 | Usage: 5 | termtext -m 6 | termtext notify 7 | termtext -h --help for more info 8 | FOR SMS GATEWAYS LOOK AT THE DOCS AT 9 | https://github.com/mraza007/terminal-text/ 10 | 11 | Options: 12 | -h --help Show this screen. 13 | --version Show version. 14 | 15 | """ 16 | 17 | from docopt import docopt 18 | import os , imaplib , email ,subprocess 19 | import smtplib 20 | from email.mime.text import MIMEText 21 | from email.mime.multipart import MIMEMultipart 22 | 23 | 24 | 25 | def mail_server(email,sms_gateway,text): 26 | email = os.environ["EMAIL"] 27 | pas = os.environ["PASS"] 28 | smtp = os.environ["SMTP"] 29 | port = int(os.environ['PORT']) 30 | server = smtplib.SMTP(smtp,port) 31 | server.starttls() 32 | server.login(email,pas) 33 | server.sendmail(email,sms_gateway,text) 34 | server.quit() 35 | 36 | def send_text(text): 37 | msg = MIMEMultipart() 38 | email = os.environ["EMAIL"] 39 | sms_gateway = os.environ["SMS_GATEWAY"] 40 | msg['From'] = email 41 | msg['To'] = sms_gateway 42 | msg['Subject'] = "TEXT SENT FROM TERMINAL\n" 43 | body = text 44 | msg.attach(MIMEText(body, 'plain')) 45 | sms = msg.as_string() 46 | mail_server(email,sms_gateway,sms) 47 | 48 | def notify(): 49 | imap_host = os.environ['IMAP_HOST'] 50 | imap_user = os.environ["EMAIL"] 51 | imap_pass = os.environ["PASS"] 52 | imap = imaplib.IMAP4_SSL(imap_host) 53 | imap.login(imap_user, imap_pass) 54 | imap.select('Inbox') 55 | result,data = imap.uid('search',None,"ALL") 56 | inbox_item = data[0].split() 57 | most_recent = inbox_item[-1] 58 | result2,email_data = imap.uid('fetch',most_recent,'(RFC822)') 59 | raw_email = email_data[0][1].decode("utf-8") 60 | b = email.message_from_string(raw_email) 61 | if b['From'] == os.environ["SMS_GATEWAY"]: 62 | subprocess.Popen(['notify-send', 'You Recieved a message from: ' + b['From']]) 63 | else: 64 | subprocess.Popen(['notify-send', 'Sorry No Message']) 65 | 66 | 67 | 68 | 69 | 70 | 71 | if __name__ == '__main__': 72 | 73 | arguments = docopt(__doc__,version='Terminal Text-1.0') 74 | 75 | if arguments['-m']: 76 | send_text(arguments['']) 77 | elif arguments['notify']: 78 | notify() 79 | --------------------------------------------------------------------------------