async-bot-api-adapters-0.0.1
توضیحات
Common interface for vk/telegram api calls
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | async-bot-api-adapters-0.0.1 |
| نام | async-bot-api-adapters |
| نسخه کتابخانه | 0.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Sergey Konik |
| ایمیل نویسنده | s.konik.job@gmail.com |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/async-bot-api-adapters/ |
| مجوز | - |
⚕ WIP: Async Bot API Adapters ⚕
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This package allows to interact with vk and telegram API using the same
interface.
It's main purpose is to simply switch 🕹 between services while
developing bots.
Setup
-----
Firstly you should export environment variables. Create ``.env`` file
and fill vars:
::
TELEGRAM_TOKEN=telegram_token
VK_TOKEN=vk_token
Example
-------
Upload Images to vk and tg.
.. code:: python
import asyncio
import aiofiles
from adapters.factory import create_adapter
from adapters.enums import AdapterType
from dotenv import load_dotenv
load_dotenv()
tg_adapter = create_adapter(adapter_type=AdapterType.TELEGRAM)
vk_adapter = create_adapter(adapter_type=AdapterType.VK)
async def main():
async with aiofiles.open('test.png', mode='rb') as data:
content = await data.read()
await asyncio.gather(*[
tg_adapter.send_image(chat_id=-195789610, image=content),
vk_adapter.send_image(chat_id=2000000006, image=content)
])
asyncio.run(main())
نحوه نصب
نصب پکیج whl async-bot-api-adapters-0.0.1:
pip install async-bot-api-adapters-0.0.1.whl
نصب پکیج tar.gz async-bot-api-adapters-0.0.1:
pip install async-bot-api-adapters-0.0.1.tar.gz