pythontextnow


Namepythontextnow JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryA Python wrapper for TextNow.
upload_time2023-01-20 16:24:10
maintainer
docs_urlNone
authorJoey Greco
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

<br>
<br>
<img src="https://raw.githubusercontent.com/joeyagreco/pythontextnow/main/img/pythontextnow_logo_.png" alt="pythontextnow logo" width="450"/>

A Python wrapper for TextNow.

[TextNow Website](https://www.textnow.com/)

<a target="_blank" href="https://www.python.org/downloads/" title="Python version"><img src="https://img.shields.io/badge/python-%3E=_3.10-teal.svg"></a>
![Main Build](https://github.com/joeyagreco/pythontextnow/actions/workflows/main-build.yml/badge.svg)
![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/pythontextnow)
</div>

### Table of Contents

- [Installation](https://github.com/joeyagreco/pythontextnow#installation)
- [Usage](https://github.com/joeyagreco/pythontextnow#usage)
    - [Configure Client](https://github.com/joeyagreco/pythontextnow#configure-client)
    - [Get Messages](https://github.com/joeyagreco/pythontextnow#get-messages)
    - [Send a Message](https://github.com/joeyagreco/pythontextnow#send-a-message)
    - [Send Media](https://github.com/joeyagreco/pythontextnow#send-media)
    - [Mark a Message as Read](https://github.com/joeyagreco/pythontextnow#mark-a-message-as-read)
    - [Delete a Message](https://github.com/joeyagreco/pythontextnow#delete-a-message)
    - [Delete a Conversation](https://github.com/joeyagreco/pythontextnow#delete-a-conversation)
- [Setup](https://github.com/joeyagreco/pythontextnow#setup)
    - [Obtaining Your Username](https://github.com/joeyagreco/pythontextnow#obtaining-your-username)
    - [Obtaining Your Cookies](https://github.com/joeyagreco/pythontextnow#obtaining-your-cookies)
- [Running Tests](https://github.com/joeyagreco/pythontextnow#running-tests)
- [Contributing](https://github.com/joeyagreco/pythontextnow#contributing)
- [License](https://github.com/joeyagreco/pythontextnow#license)

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install.

```bash
pip install pythontextnow
```

## Usage

Make sure you have the following before you begin:

- TextNow username
- SID cookie

For a guide on how to obtain these for your account, check [here](https://github.com/joeyagreco/pythontextnow#setup).

### Configure Client

Before you can call any methods, you must first set up your client config.

```python3
from pythontextnow import Client

USERNAME = "{your_username}"
SID_COOKIE = "{your_sid_cookie}"

Client.set_client_config(username=USERNAME, sid_cookie=SID_COOKIE)
```

The ConversationService is how you will perform any action.

It takes a list of phone numbers which define the conversation you would like to perform your actions on.

<!---
// @formatter:off
-->
**All phone numbers must be given in [E.164 format](https://help.aircall.io/en/articles/4350988-what-is-e-164-format).**
<!---
// @formatter:on
-->

```python3
from pythontextnow import ConversationService

PHONE_NUMBER_1 = "{some_phone_number}"
PHONE_NUMBER_2 = "{some_other_phone_number}"
conversation_service = ConversationService(conversation_phone_numbers=[PHONE_NUMBER_1, PHONE_NUMBER_2])
```

### Get Messages

The `get_messages()` method will return a [generator object](https://docs.python.org/3/glossary.html#term-generator).

This will return the messages from most -> least recent.

You can call `next()` with the returned generator each time you want to get the next group of messages.

```python3
messages_generator = conversation_service.get_messages()

messages = next(messages_generator)
```

You can also use a for loop to get all messages in a conversation.

```python3
messages_generator = conversation_service.get_messages()

all_messages = list()
for message_list in messages_generator:
    all_messages += message_list
```

You can specify how many messages back you would like to be retrieved by using the `num_messages` keyword argument.

```python3
messages_generator = conversation_service.get_messages(num_messages=10)

last_10_messages = list()
for message_list in messages_generator:
    last_10_messages += message_list
```

### Send a Message

To send a text message, use the `send_message()` method.

```python3
conversation_service.send_message(message="Hello World!")
```

### Send Media

To send media, use the `send_media()` method.

You can send:

- Images
- Videos
- GIFs

```python3
conversation_service.send_message(file_path="C:\\my_media.png")
```

### Mark a Message as Read

To mark a message as read, use the `mark_as_read()` method.

Mark a single message as read.

```python3
# assume you had a Message object saved to the variable "message_obj"

conversation_service.mark_as_read(message=message_obj)
```

Mark a list of messages as read.

```python3
# assume you had a list of Message objects saved to the variable "message_list"

conversation_service.mark_as_read(messages=message_list)
```

### Delete a Message

To delete a message, use the `delete_message()` method.

Delete a message by its ID.

```python3
conversation_service.delete_message(message_id="123456")
```

<!---
// @formatter:off
-->
Delete a message with its [Message](https://github.com/joeyagreco/pythontextnow/blob/main/pythontextnow/model/Message.py) object.
<!---
// @formatter:on
-->

```python3
# assume you had a Message object saved to the variable "message_obj"

conversation_service.delete_message(message=message_obj)
```

### Delete a Conversation

To delete a conversation, use the `delete_conversation()` method.

```python3
conversation_service.delete_conversation()
```

## Setup

### Obtaining Your Username

You will need to know your TextNow username to utilize this library.

This is the same username that you would use to log in.

To find this username:

- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in)
- Click "Settings"
- Your username will be listed under "Account"

### Obtaining Your Cookie

You will need an SID cookie to utilize this library.

To find this cookie:

- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in to your account)

> In **Chrome**:
> - Access [Developer Tools](https://developer.chrome.com/docs/devtools/open/) in your browser
> - Click on the "Application" tab
> - Click on the "Network" tab
> - Find a request under "Fetch/XHR"
> - Go to the "Headers" tab in the given request
> - Find the "Request Headers" section
> - Locate the "Cookie" field

> In **Firefox**
> - Access [Developer Tools](https://firefox-source-docs.mozilla.org/devtools-user/) in your browser
> - Click on the "Network" tab
> - Find a request under "XHR"
> - Go to the "Headers" tab in the given request
> - Find the "Request Headers" section
> - Locate the "Cookie" field

- Locate the "connect.sid" field, the value will be your SID cookie

## Running Tests

To run tests, run the following command:

```bash
  pytest
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License

[MIT](https://choosealicense.com/licenses/mit/)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pythontextnow",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Joey Greco",
    "author_email": "joeyagreco@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/51/08/58cdfc5df77185988779acf5bdc63565e9dfcfd18da57d882b38a585e3a6/pythontextnow-1.0.1.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n\r\n<br>\r\n<br>\r\n<img src=\"https://raw.githubusercontent.com/joeyagreco/pythontextnow/main/img/pythontextnow_logo_.png\" alt=\"pythontextnow logo\" width=\"450\"/>\r\n\r\nA Python wrapper for TextNow.\r\n\r\n[TextNow Website](https://www.textnow.com/)\r\n\r\n<a target=\"_blank\" href=\"https://www.python.org/downloads/\" title=\"Python version\"><img src=\"https://img.shields.io/badge/python-%3E=_3.10-teal.svg\"></a>\r\n![Main Build](https://github.com/joeyagreco/pythontextnow/actions/workflows/main-build.yml/badge.svg)\r\n![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/pythontextnow)\r\n</div>\r\n\r\n### Table of Contents\r\n\r\n- [Installation](https://github.com/joeyagreco/pythontextnow#installation)\r\n- [Usage](https://github.com/joeyagreco/pythontextnow#usage)\r\n    - [Configure Client](https://github.com/joeyagreco/pythontextnow#configure-client)\r\n    - [Get Messages](https://github.com/joeyagreco/pythontextnow#get-messages)\r\n    - [Send a Message](https://github.com/joeyagreco/pythontextnow#send-a-message)\r\n    - [Send Media](https://github.com/joeyagreco/pythontextnow#send-media)\r\n    - [Mark a Message as Read](https://github.com/joeyagreco/pythontextnow#mark-a-message-as-read)\r\n    - [Delete a Message](https://github.com/joeyagreco/pythontextnow#delete-a-message)\r\n    - [Delete a Conversation](https://github.com/joeyagreco/pythontextnow#delete-a-conversation)\r\n- [Setup](https://github.com/joeyagreco/pythontextnow#setup)\r\n    - [Obtaining Your Username](https://github.com/joeyagreco/pythontextnow#obtaining-your-username)\r\n    - [Obtaining Your Cookies](https://github.com/joeyagreco/pythontextnow#obtaining-your-cookies)\r\n- [Running Tests](https://github.com/joeyagreco/pythontextnow#running-tests)\r\n- [Contributing](https://github.com/joeyagreco/pythontextnow#contributing)\r\n- [License](https://github.com/joeyagreco/pythontextnow#license)\r\n\r\n## Installation\r\n\r\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install.\r\n\r\n```bash\r\npip install pythontextnow\r\n```\r\n\r\n## Usage\r\n\r\nMake sure you have the following before you begin:\r\n\r\n- TextNow username\r\n- SID cookie\r\n\r\nFor a guide on how to obtain these for your account, check [here](https://github.com/joeyagreco/pythontextnow#setup).\r\n\r\n### Configure Client\r\n\r\nBefore you can call any methods, you must first set up your client config.\r\n\r\n```python3\r\nfrom pythontextnow import Client\r\n\r\nUSERNAME = \"{your_username}\"\r\nSID_COOKIE = \"{your_sid_cookie}\"\r\n\r\nClient.set_client_config(username=USERNAME, sid_cookie=SID_COOKIE)\r\n```\r\n\r\nThe ConversationService is how you will perform any action.\r\n\r\nIt takes a list of phone numbers which define the conversation you would like to perform your actions on.\r\n\r\n<!---\r\n// @formatter:off\r\n-->\r\n**All phone numbers must be given in [E.164 format](https://help.aircall.io/en/articles/4350988-what-is-e-164-format).**\r\n<!---\r\n// @formatter:on\r\n-->\r\n\r\n```python3\r\nfrom pythontextnow import ConversationService\r\n\r\nPHONE_NUMBER_1 = \"{some_phone_number}\"\r\nPHONE_NUMBER_2 = \"{some_other_phone_number}\"\r\nconversation_service = ConversationService(conversation_phone_numbers=[PHONE_NUMBER_1, PHONE_NUMBER_2])\r\n```\r\n\r\n### Get Messages\r\n\r\nThe `get_messages()` method will return a [generator object](https://docs.python.org/3/glossary.html#term-generator).\r\n\r\nThis will return the messages from most -> least recent.\r\n\r\nYou can call `next()` with the returned generator each time you want to get the next group of messages.\r\n\r\n```python3\r\nmessages_generator = conversation_service.get_messages()\r\n\r\nmessages = next(messages_generator)\r\n```\r\n\r\nYou can also use a for loop to get all messages in a conversation.\r\n\r\n```python3\r\nmessages_generator = conversation_service.get_messages()\r\n\r\nall_messages = list()\r\nfor message_list in messages_generator:\r\n    all_messages += message_list\r\n```\r\n\r\nYou can specify how many messages back you would like to be retrieved by using the `num_messages` keyword argument.\r\n\r\n```python3\r\nmessages_generator = conversation_service.get_messages(num_messages=10)\r\n\r\nlast_10_messages = list()\r\nfor message_list in messages_generator:\r\n    last_10_messages += message_list\r\n```\r\n\r\n### Send a Message\r\n\r\nTo send a text message, use the `send_message()` method.\r\n\r\n```python3\r\nconversation_service.send_message(message=\"Hello World!\")\r\n```\r\n\r\n### Send Media\r\n\r\nTo send media, use the `send_media()` method.\r\n\r\nYou can send:\r\n\r\n- Images\r\n- Videos\r\n- GIFs\r\n\r\n```python3\r\nconversation_service.send_message(file_path=\"C:\\\\my_media.png\")\r\n```\r\n\r\n### Mark a Message as Read\r\n\r\nTo mark a message as read, use the `mark_as_read()` method.\r\n\r\nMark a single message as read.\r\n\r\n```python3\r\n# assume you had a Message object saved to the variable \"message_obj\"\r\n\r\nconversation_service.mark_as_read(message=message_obj)\r\n```\r\n\r\nMark a list of messages as read.\r\n\r\n```python3\r\n# assume you had a list of Message objects saved to the variable \"message_list\"\r\n\r\nconversation_service.mark_as_read(messages=message_list)\r\n```\r\n\r\n### Delete a Message\r\n\r\nTo delete a message, use the `delete_message()` method.\r\n\r\nDelete a message by its ID.\r\n\r\n```python3\r\nconversation_service.delete_message(message_id=\"123456\")\r\n```\r\n\r\n<!---\r\n// @formatter:off\r\n-->\r\nDelete a message with its [Message](https://github.com/joeyagreco/pythontextnow/blob/main/pythontextnow/model/Message.py) object.\r\n<!---\r\n// @formatter:on\r\n-->\r\n\r\n```python3\r\n# assume you had a Message object saved to the variable \"message_obj\"\r\n\r\nconversation_service.delete_message(message=message_obj)\r\n```\r\n\r\n### Delete a Conversation\r\n\r\nTo delete a conversation, use the `delete_conversation()` method.\r\n\r\n```python3\r\nconversation_service.delete_conversation()\r\n```\r\n\r\n## Setup\r\n\r\n### Obtaining Your Username\r\n\r\nYou will need to know your TextNow username to utilize this library.\r\n\r\nThis is the same username that you would use to log in.\r\n\r\nTo find this username:\r\n\r\n- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in)\r\n- Click \"Settings\"\r\n- Your username will be listed under \"Account\"\r\n\r\n### Obtaining Your Cookie\r\n\r\nYou will need an SID cookie to utilize this library.\r\n\r\nTo find this cookie:\r\n\r\n- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in to your account)\r\n\r\n> In **Chrome**:\r\n> - Access [Developer Tools](https://developer.chrome.com/docs/devtools/open/) in your browser\r\n> - Click on the \"Application\" tab\r\n> - Click on the \"Network\" tab\r\n> - Find a request under \"Fetch/XHR\"\r\n> - Go to the \"Headers\" tab in the given request\r\n> - Find the \"Request Headers\" section\r\n> - Locate the \"Cookie\" field\r\n\r\n> In **Firefox**\r\n> - Access [Developer Tools](https://firefox-source-docs.mozilla.org/devtools-user/) in your browser\r\n> - Click on the \"Network\" tab\r\n> - Find a request under \"XHR\"\r\n> - Go to the \"Headers\" tab in the given request\r\n> - Find the \"Request Headers\" section\r\n> - Locate the \"Cookie\" field\r\n\r\n- Locate the \"connect.sid\" field, the value will be your SID cookie\r\n\r\n## Running Tests\r\n\r\nTo run tests, run the following command:\r\n\r\n```bash\r\n  pytest\r\n```\r\n\r\n## Contributing\r\n\r\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\nPlease make sure to update tests as appropriate.\r\n\r\n## License\r\n\r\n[MIT](https://choosealicense.com/licenses/mit/)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python wrapper for TextNow.",
    "version": "1.0.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "510858cdfc5df77185988779acf5bdc63565e9dfcfd18da57d882b38a585e3a6",
                "md5": "8c7dbd30e0abb52d1507704894b3cece",
                "sha256": "3a4983c46108952e992fe2107b74a1e173882aae32bd58c76f13f1b307594887"
            },
            "downloads": -1,
            "filename": "pythontextnow-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8c7dbd30e0abb52d1507704894b3cece",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18333,
            "upload_time": "2023-01-20T16:24:10",
            "upload_time_iso_8601": "2023-01-20T16:24:10.750668Z",
            "url": "https://files.pythonhosted.org/packages/51/08/58cdfc5df77185988779acf5bdc63565e9dfcfd18da57d882b38a585e3a6/pythontextnow-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-20 16:24:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "pythontextnow"
}
        
Elapsed time: 0.03228s