Giter Site home page Giter Site logo

py-imessage's Introduction

No longer under active development.

py-imessage

License Downloads

py-imessage is a library to send iMessages from your Mac computer (it does not work on Windows/Linux). It was originally used to build an API for iMessages; however, Apple doesn't support third-parties using iMessage over a few hundred marketing messages per day.

Buy Me A Coffee

Installation

Run the following commands on the terminal

pip install py-imessage

# Disable system integrity protection in order to allow access to chat.db
csrutil disable

If running csrutil disable doesn't work. Try this stackoverflow post

Sample Usage

from py_imessage import imessage
import sleep

phone = "1234567890"

if not imessage.check_compatibility(phone):
    print("Not an iPhone")

guid = imessage.send(phone, "Hello World!")

# Let the recipient read the message
sleep(5)
resp = imessage.status(guid)

print(f'Message was read at {resp.get("date_read")}')

Documentation

Sending a message

Send a message to a new or an existing contact!

.send(phone, message)

Args

Phone | ten-digit phone number of string type format XXXXXXXXXXX i.e. "1234567890"

Response

Message | The message you plan to send. i.e. "Hi!"

Returns a string, the GUID
Type Description
string GUID unique to the message (used for checking on status)

Message status

Check whether a message you sent has been delivered and read (if read receipts turned on).

.status(guid)

Args

Guid | guid returned from sending a message

Response

Returns a dict, with following fields
Field Type Description Sample
guid string guid that was passed in to the function "3A146100-D269-4F35-BDB4-EB2FF7DBDF0F"
date_submitted datetime date message was submitted "Sun, 12 Apr 2020 05:46:48 GMT"
date_delivered datetime date message was delivered to recipient's phone "Sun, 12 Apr 2020 05:46:49 GMT"
date_read datetime date message was read on recipient's phone "Sun, 12 Apr 2020 05:47:38 GMT"

Checking iMessage compatibility

Check whether a phone number is registered to an iPhone or an Android device. NOTE: This method is exceptionally slow, so you should cache the response.

.check_compatibility(phone)

Args

Phone | ten-digit phone number of string type format XXXXXXXXXXX i.e. "1234567890"

Response

Returns a boolean, compatibility
Type Description
boolean Whether number supports receiving iMessages

Contributing

Please create an issue. Or feel free to add a PR!

py-imessage's People

Contributors

kadolis avatar rolstenhouse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py-imessage's Issues

when I run "pip3 install py-imessage", I got this. (normal when running install other package)

Collecting py-imessage
Downloading py-iMessage-1.7.tar.gz (6.3 kB)
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-HUY3wS/py-imessage/setup.py'"'"'; file='"'"'/private/tmp/pip-install-HUY3wS/py-imessage/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-p6vHkC
cwd: /private/tmp/pip-install-HUY3wS/py-imessage/
Complete output (5 lines):
Traceback (most recent call last):
File "", line 1, in
File "/private/tmp/pip-install-HUY3wS/py-imessage/setup.py", line 13, in
with open (join(dirname(file), 'requirements.txt'), 'r') as f:
IOError: [Errno 2] No such file or directory: '/private/tmp/pip-install-HUY3wS/py-imessage/requirements.txt'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

my OS is MAC 10.15 , and I run it in vmware

check_imessage.js 1234567890' returned non-zero exit status 2

hi I have run csrutil disable
but I got message is
"subprocess.CalledProcessError: Command 'osascript -l JavaScript /Users/danny/venv/lib/python3.8/site-packages/py_imessage/osascript/check_imessage.js 1234567890' returned non-zero exit status 2.
"

TypeError

Getting the following error when trying to send a message.

Error: TypeError: messagesApp.buddies.whose is not a function. (In 'messagesApp.buddies.whose({handle:{_contains: number}})', 'messagesApp.buddies.whose' is undefined) (-2700)

something is wrong with language

If the language switch is in the russian position, then when I send the message "привет" I get the correct message "привет"

If the language switch is set to english, then when I send a "привет" message, I get the message "aaaaaa"

osacript needs to be reworked for Big Sur

Current release does not work correctly with Big Sur. A lot easier to do this now without helper js files but requires knowing account id for the number you want to use which is specific to the machine you are using.

def send_imessage(phone,message):
    accountid = "ACCOUNT_ID"
    script = '''
	tell application "Messages"
        set theBuddy to participant "{}" of account id "{}"
        send "{}" to theBuddy
    end tell
        '''.format(phone,accountid,message)
    Popen(['osascript', '-e', script])

works for me and could be refactored to work with this package

IMessage doesn't send sms. No errors.

Hi,
I am on MacOS Capatlina 10.15.3. I get no errors, I was able to execute csrutil disable.

But For some reason, the script doesn't work. It opens Imessage sending menu ( screenshot: https://ibb.co/BB51qDW). Then script exits with code 0 and prints the read date of last message.

Code I use - pretty straightforward one from the example ( see screenshot).

Any hint on how to fix it?

getting response status and dictionary items throws an error

code is:

try:
guid = imessage.send(testing_phone, message_to_Send)

    sleep(5)
    resp = imessage.status(guid)
    print('status of message is: ', resp)
    sleep(5)
    print('Message was delivered at:', resp.get("date_delivered")

except Exception as e:
    print('ERROR: ', str(e))

Error message is:
"ERROR: unable to open database file"

Has this happened to anyone else or am I doing something wrong?
Any help would be appreciated :)

keyerror

Traceback (most recent call last):
File "c:/Users/Desktop/gmailpy/emailpyspam/spammer.py", line 59, in
from py_imessage import imessage
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py_imessage\imessage.py", line 1, in
from py_imessage import db_conn
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py_imessage\db_conn.py", line 11, in
home = os.environ['HOME']
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\os.py", line 675, in getitem
raise KeyError(key) from None
KeyError: 'HOME'
code is the same as in the readme

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.