Skip to main content

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())

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async-bot-api-adapters-0.0.1.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file async-bot-api-adapters-0.0.1.tar.gz.

File metadata

  • Download URL: async-bot-api-adapters-0.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.1

File hashes

Hashes for async-bot-api-adapters-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d55e2edf100560cb2be057d1dd2ea7c78894e15d4800087c6e407c9e8949685e
MD5 6454126f62753195a2e8ce4494270424
BLAKE2b-256 4c3299927904017aafa5736e183e8f9e0f8da0a175457c07e90af31f3551fc26

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page