Tiny asyncio-based telgram api wrapper library
Project description
# aiotelegram
Tiny asyncio-based telgram api wrapper library.
## Reasons
* [aiotg](https://github.com/szastupov/aiotg) is framework, not library and have no proxy support.
* Raw api calls translation is better for understanding and will not break if telegram api will be changed.
* `snake_case`
## Features:
* Simple as telegram api is.
* Based on [`aiohttp`](https://github.com/KeepSafe/aiohttp).
* Proxy available (via [`aiohttp`](https://github.com/KeepSafe/aiohttp) [`ProxyConnector`](http://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ProxyConnector)).
* `snake_case` api converted to telegram `camelCase`.
* Polling `offset` handled for you via `get_updates` method.
* Source code is [short and simple](https://github.com/pohmelie/aiotelegram/blob/master/aiotelegram.py).
## Usage
### Polling updates
```python
import aiotelegram
async def ...(...):
api = aiotelegram.Api(token)
while True:
response = await api.get_updates()
if not response["ok"]:
...
else:
for update in response["result"]:
...
await asyncio.sleep(delay)
```
### Sending message
```python
async def ...(...):
await api.send_message(
chat_id=123456,
text="*foobar*",
parse_mode="Markdown",
)
```
Tiny asyncio-based telgram api wrapper library.
## Reasons
* [aiotg](https://github.com/szastupov/aiotg) is framework, not library and have no proxy support.
* Raw api calls translation is better for understanding and will not break if telegram api will be changed.
* `snake_case`
## Features:
* Simple as telegram api is.
* Based on [`aiohttp`](https://github.com/KeepSafe/aiohttp).
* Proxy available (via [`aiohttp`](https://github.com/KeepSafe/aiohttp) [`ProxyConnector`](http://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ProxyConnector)).
* `snake_case` api converted to telegram `camelCase`.
* Polling `offset` handled for you via `get_updates` method.
* Source code is [short and simple](https://github.com/pohmelie/aiotelegram/blob/master/aiotelegram.py).
## Usage
### Polling updates
```python
import aiotelegram
async def ...(...):
api = aiotelegram.Api(token)
while True:
response = await api.get_updates()
if not response["ok"]:
...
else:
for update in response["result"]:
...
await asyncio.sleep(delay)
```
### Sending message
```python
async def ...(...):
await api.send_message(
chat_id=123456,
text="*foobar*",
parse_mode="Markdown",
)
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiotelegram-0.1.0.tar.gz
(2.2 kB
view details)
Built Distribution
File details
Details for the file aiotelegram-0.1.0.tar.gz
.
File metadata
- Download URL: aiotelegram-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b73b1d0ba29623d68bf990e67a50fdfa05ab12e4048214064d4c7f9883988129 |
|
MD5 | f41d667e4c6adc03c550f14181ad6569 |
|
BLAKE2b-256 | 162ca17b7f797c433b54a9d48a3ff3800368dca16daa2cb223767c0a3dfc48da |
File details
Details for the file aiotelegram-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: aiotelegram-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2398b934c4279358fbc65b09b89036f158c4ddd8027bc02515190361929563c |
|
MD5 | 0a6d093797cfb3746cf506b46c0c071b |
|
BLAKE2b-256 | 7ec061a34d620bfaada623e0b530a5e5263f59e8b2255fad9a3cbef28d7acc59 |