Metadata-Version: 2.1
Name: TeleSendTime
Version: 0.1.2
Summary: Telegram Message Automation Module.
Home-page: https://gitlab.com/DarkSuniuM/TeleSendTime
Author: Alireza Ayinmehr
Author-email: alireza.ayinmehr@gmail.com
License: UNKNOWN
Project-URL: Code, https://gitlab.com/DarkSuniuM/TeleSendTime
Project-URL: Issue tracker, https://gitlab.com/DarkSuniuM/TeleSendTime/issues
Platform: UNKNOWN
Description-Content-Type: text/markdown
Requires-Dist: requests (>=2)

# TeleSendTime
TeleSendTime is a Python module for Telegram message automation.

## Installation

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

```bash
pip install TeleSendTime
# or using Git
pip install git+https://gitlab.com/DarkSuniuM/TeleSendTime.git
```

## Usage

```
# template.txt
# "$" prefixed words are variables
BTC Rate (USD): $rate
```

```python
# app.py

import requests

from tele_sendtime import Automation
from tele_sendtime import load_template


automation = Automation('MY_BOT_TOKEN')


# chat_id => Chat ID or Channel Username (Note: You can use username only for channels)
# interval in seconds.
@automation.job(chat_id='@my_channel_username', template=load_template('template.txt'), interval=60)
def send_btc_rate_in_usd():
    # Sample API Call
    req = requests.get('https://api.coindesk.com/v1/bpi/currentprice/USD.json')
    rate = req.json()['bpi']['USD']['rate_float']

    # return type should be a list of strings or dictianories
    # Use dict when there is a template
    return [{'rate': rate}] 


@automation.job(chat_id='@my_channel_username', interval=60)
def send_btc_rate_in_eur():
    # Sample API Call
    req = requests.get('https://api.coindesk.com/v1/bpi/currentprice/EUR.json')
    rate = req.json()['bpi']['EUR']['rate_float']

    # When using String, Template get's ignored!
    return [f'BTC Price (EURO): {rate}']


# Run the automation bot.
automation.run()
```

## To Do
* Add Documentation
* Improve Concurrency
* Add Logging
* Add support for other message types (photo, audio, document)
* Add Tests


## 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
[GNU LGPLv3](https://choosealicense.com/licenses/lgpl-3.0/)

