Common interface for vk/telegram api calls
Project description
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.
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for async-bot-api-adapters-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d55e2edf100560cb2be057d1dd2ea7c78894e15d4800087c6e407c9e8949685e |
|
MD5 | 6454126f62753195a2e8ce4494270424 |
|
BLAKE2b-256 | 4c3299927904017aafa5736e183e8f9e0f8da0a175457c07e90af31f3551fc26 |