Skip to main content

A python binding for tgcalls

Project description

tgcalls
Voice chats, private incoming and outgoing calls in Telegram for Developers
Examples Channel Chat

Telegram WebRTC (VoIP)

from pyrogram import Client, filters
from pytgcalls import GroupCall

app = Client('pytgcalls')
group_call = GroupCall(app, 'input.raw')


@app.on_message(filters.private & filters.command('join'))
async def join(client, message):
    if len(message.command) < 2:
        await message.reply_text('You forgot to input chat id')
    else:
        chat_id = message.command[1]
        await group_call.start(chat_id)


app.run()

This project consists of two main parts: tgcalls, pytgcalls. The first is a C++ Python extension. The second uses the extension along with Pyrogram. All together, it allows you to create userbots that can record and broadcast in voice chats, make and receive private calls.

Features

  • Python solution.
  • Join to voice chats.
  • Payout from file.
  • Output (recording) to file.
  • Change files at runtime.
  • Speaking status with levels inside and outside of VC.
  • Stop payout/output.
  • Multiply chats.

Requirements

  • Python 3.6 or higher.
  • A Telegram API key.
  • x86_64 platform and Unix system (WSL for Windows).

TODO list

  • Incoming and Outgoing calls (already there and working, but not in release).
  • Video calls (video from/to a file etc).
  • Additional things for working with ffmpeg.
  • Convenient callbacks and methods.
  • Windows and macOS Python wheels and more...

Installing

pip3 install pytgcalls

tgcalls
PyPi Sources

tgcalls

The first part of the project is C++ extensions for Python. Pybind11 was used to write it. Binding occurs to the tgcalls library by Telegram, which is used in all clients. To implement the library, the code of official clients (tdesktop and android) was studied. Changes have been made to the Telegram library. All modified code is available as a subtree in this repository. The main idea of the changes is to add the ability to play from other sources (from a file, for example) and improve the sound quality by making the minimum number of code edits for a simple update. In addition to changes in the Telegram library, a minimal change was made to the WebRTC, also available as a subtree.

How to build

Also you can investigate into manylinux builds.

Documentation

Temporarily, instead of documentation, you can use an example along with MTProto.


pytgcalls
PyPi Sources

pytgcalls

This project is for the most part an example for using tgcalls Python binding together with MTProto. A Pyrogram was chosen as a library for working with MTProto. You can easily write your own implementation to work with Telethon.

Documentation

Temporarily, instead of documentation, you can use an example describing the methods. There are not many of them.

Audio file formats

RAW files are now used. You will have to convert to this format yourself using ffmpeg. This procedure may become easier in the future.

From mp3 to raw (to play in voice chat):

ffmpeg -i input.mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw

From raw to mp3 (files with recordings):

ffmpeg -f s16le -ac 2 -ar 48000 -acodec pcm_s16le -i output.raw clear_output.mp3

For playout live stream you can use this one:

ffmpeg -y -i http://stream2.cnmns.net/hope-mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw

For YouTube videos and live streams you can use youtube-dl:

ffmpeg -i "$(youtube-dl -x -g "https://youtu.be/xhXq9BNndhw")" -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw

And set input.raw as input filename.


Getting help

You can get help in several ways:

Contributing

Contributions of all sizes are welcome.

Special thanks to

License

You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL-3. Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL-3, but applications that use the library don't have to be.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tgcalls-0.0.5-cp39-cp39-manylinux2014_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.9

tgcalls-0.0.5-cp39-cp39-manylinux2014_aarch64.whl (8.4 MB view details)

Uploaded CPython 3.9

tgcalls-0.0.5-cp38-cp38-manylinux2014_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.8

tgcalls-0.0.5-cp38-cp38-manylinux2014_aarch64.whl (8.4 MB view details)

Uploaded CPython 3.8

tgcalls-0.0.5-cp37-cp37m-manylinux2014_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.7m

tgcalls-0.0.5-cp37-cp37m-manylinux2014_aarch64.whl (8.4 MB view details)

Uploaded CPython 3.7m

tgcalls-0.0.5-cp36-cp36m-manylinux2014_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.6m

tgcalls-0.0.5-cp36-cp36m-manylinux2014_aarch64.whl (8.4 MB view details)

Uploaded CPython 3.6m

File details

Details for the file tgcalls-0.0.5-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.1 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 884e4c0685d5edd9c67aa8a6d6e1e19ef3a3acd635cb045919d58a0d7f91f55b
MD5 5c7c9fcdbebc607cd6481fb222737b65
BLAKE2b-256 cb7efa3221461dc0fc5de70d45ca6695297aed5128af4e929e86112b8a4683d1

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp39-cp39-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 72ec1b0a26651db93cf21b705048137fe365bf70ae02895af32409b8642cbd99
MD5 0e194008b545f03cf4cf7f96897c8440
BLAKE2b-256 6db8fcda791c3c6b527489a32f8b83bc017f7b373d352facaa2039d2af4db8f6

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.1 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 05b3b02faae74cd3bf33936997097842f825ed4f7b7f2b9ab1655242c4440339
MD5 cf8f81b953fa9a6ac2dfac870cdd6439
BLAKE2b-256 40b1458c1a5e57bb1ab54330dfb966722ae7027baab47044dd838ce3dcc26627

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp38-cp38-manylinux2014_aarch64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp38-cp38-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp38-cp38-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8cd17bbda937d427b35c24a3cc6af69d287c21c4e010d7e0b265bdd13e0d1b54
MD5 cc6c5973af895a931dee582663068d49
BLAKE2b-256 fa288530c1706d4eace01b488538f56f444958e5e6b17089fd0f55b970de3380

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.1 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bbf5e33c234ca9d5c38ca4636eb768674ac8871dc4487b24651aa556a0523ba5
MD5 2b7fda5f4333ec1eb74720a8f4799722
BLAKE2b-256 2312833b1cc2dd0572635994b647263d95f9389a41b571811b8f9a9257c21b28

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp37-cp37m-manylinux2014_aarch64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp37-cp37m-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp37-cp37m-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 37a272ba33845111cd7c1bf19a7d9d165021fe382e8515d38e040bb04dc0270d
MD5 5762f0c34e3c0787b02400fb995539fa
BLAKE2b-256 77f35c10cebb8c4a0ba35338043a0c5d9fcb5ae682232f8d8ce9def5d65c728c

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd8bd4cdf1692918f77423d8404ca77a534bfd8a9b8d5e571a1c2649759d9702
MD5 ff60708d1c70d2aa625b78d16de2518d
BLAKE2b-256 30c0f0f67464688972d1db1a7a34375d95b0c8eb9835d2344d2c3d15c4179038

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.5-cp36-cp36m-manylinux2014_aarch64.whl.

File metadata

  • Download URL: tgcalls-0.0.5-cp36-cp36m-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.5-cp36-cp36m-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 efcbf16647b735465e069b7f2cd95197614a48a36e277a2babfd67ad14567460
MD5 f9f2b9e418650f94c8089ae4781ded9f
BLAKE2b-256 0b856c5448a86594f54e0616cfad2375c8ef75564e83e3e97dde1d06642847ed

See more details on using hashes here.

Supported by

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