Skip to main content

A python binding for tgcalls

Project description

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

Telegram WebRTC (VoIP)

from pyrogram import Client, filters
from pyrogram.utils import MAX_CHANNEL_ID

from pytgcalls import GroupCall

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


@group_call.on_network_status_changed
async def on_network_changed(gc: GroupCall, is_connected: bool):
    chat_id = MAX_CHANNEL_ID - gc.full_chat.id
    if is_connected:
        await app.send_message(chat_id, 'Successfully joined!')
    else:
        await app.send_message(chat_id, 'Disconnected from voice chat..')


@app.on_message(filters.outgoing & filters.command('join'))
async def join(_, message):
    await group_call.start(message.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

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).
  • Private and group video calls.
  • Windows and macOS Python wheels and more...

Installing

pip3 install pytgcalls -U

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
Documentation PyPi Sources

pytgcalls

This project is implementation of using tgcalls Python binding together with MTProto. A Pyrogram was chosen as a library for working with Telegram Mobile Protocol. You can write your own implementation to work with Telethon or other libraries.

Learning by example

Visit this page to discover the official examples.

Documentation

pytgcalls's documentation lives at tgcalls.org.

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

tgcalls-0.0.12-cp39-cp39-manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.9

tgcalls-0.0.12-cp39-cp39-manylinux2014_aarch64.whl (7.6 MB view details)

Uploaded CPython 3.9

tgcalls-0.0.12-cp39-cp39-macosx_11_0_arm64.whl (7.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

tgcalls-0.0.12-cp39-cp39-macosx_10_12_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

tgcalls-0.0.12-cp38-cp38-manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.8

tgcalls-0.0.12-cp38-cp38-manylinux2014_aarch64.whl (7.6 MB view details)

Uploaded CPython 3.8

tgcalls-0.0.12-cp38-cp38-macosx_10_12_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.8macOS 10.12+ x86-64

tgcalls-0.0.12-cp37-cp37m-manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.7m

tgcalls-0.0.12-cp37-cp37m-manylinux2014_aarch64.whl (7.6 MB view details)

Uploaded CPython 3.7m

tgcalls-0.0.12-cp37-cp37m-macosx_10_12_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.7mmacOS 10.12+ x86-64

tgcalls-0.0.12-cp36-cp36m-manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.6m

tgcalls-0.0.12-cp36-cp36m-manylinux2014_aarch64.whl (7.6 MB view details)

Uploaded CPython 3.6m

tgcalls-0.0.12-cp36-cp36m-macosx_10_12_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.6mmacOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0960da6c48e5462b424805750ca975fd0d332b7a184e11c993ca98e5f8476829
MD5 9eeb599ae07ca1647d5e4dccc13183f5
BLAKE2b-256 91b2294512716090894b897d5e1fad00ddec7b6356752c60add02836545fd117

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp39-cp39-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 12775fa38a1690849c2f3d079324bb07efa50d032f1772cfc52cf706b1503fb6
MD5 ce51f37f67385471155e9206971a57a7
BLAKE2b-256 50045bf4051de96ca027c9f88477bd51d11f7ed3943a5b83fb6bc19384184379

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.12-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tgcalls-0.0.12-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for tgcalls-0.0.12-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 10e5e5582010369db7d71e3e5ddcedf947a3bb2cef8890c64afbeb1028cca7cf
MD5 d1f622cf181e760e645f9ad746f504a4
BLAKE2b-256 06a70c019823a7a9d2d46becacba1fb4598c9b16a0c354e56f603f2ad491768a

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.12-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.12-cp39-cp39-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.9, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cf9bd62b45dda8e62531c645f04986908f1556adb3f4820b1a06637357821032
MD5 de78142174a19c61fb03da4691067e44
BLAKE2b-256 e96b9fefdc786d0c1d7ffba961cc9526b8c5a5dbd82a93b465f08689e834b534

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1dd86305d8f205be1ef193dde9cd529db832ea7fc50fb7d2aab1df378c385618
MD5 b9503749bc64d68f0117bc7f9250a278
BLAKE2b-256 a68f1adaaf3d39eeb2046833869e3f753502e5a2d72c2a5b0f8fb54dba7b1e2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp38-cp38-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp38-cp38-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6c1dd4f68ab1e7733fdf11c34c42d4d0c034e5d0137ab0b0397ef1bffc61da1d
MD5 28ba7f9c4169310e53dbcc611cf25194
BLAKE2b-256 242fdfe6ec301658644261d2d43e3499d229c00f12976625fa697ebd53aea0c0

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.12-cp38-cp38-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.12-cp38-cp38-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.8, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d3780499deee29241030271e1f386710bb5e842356bb0b0b594342a7b5ba14f1
MD5 2f2b76e00e67ca0a4f2fee3f510a787d
BLAKE2b-256 27587ac90182fd649b3dbd8a7ff8033a58f9fc4a539a39fe393599c5afb08cd7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 588c18df3a2bf91c8e9f5520bcc5000b107ef7813b6971e9ab42685e2162c6ff
MD5 58ffa65ee8b27ed0888d637ede9602f6
BLAKE2b-256 ab96421a7222c7d82762964f31974d428726c692777dc5b312f04bc5a54b11e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp37-cp37m-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp37-cp37m-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b91bea7f311d299704285925d9677ed966bced6982d0f502316475318d254dc7
MD5 43305b408af47a94103296372b0d3654
BLAKE2b-256 d93b55ac27a29f3e63b1e47fc2ce14a961ab20f8dfe8de9ebe3c4539e4f956f7

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.12-cp37-cp37m-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.12-cp37-cp37m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.7m, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 42192c845c4765d986110448174f220f14682124be1287453528df9db30092fa
MD5 1b7627ba6671cc5d648392e5fc1d0aa9
BLAKE2b-256 d0fd8e16bbdad516ae9adbe3a6b367f00a07f74c9d803a626729910731472def

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a599eb9768f130c7bfd217edacff48efc1c85fcb0621bdcbbe25d2a65963e5c
MD5 ba17010d2c09f67901771158d9643ab2
BLAKE2b-256 3503742337e031420b2b0dd7643af5d91213cc37a6ddce560ddeeffca0302aaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12-cp36-cp36m-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp36-cp36m-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aeb9a3e84733213210cf22a298837428ab005a3172373c69a007832426cf4695
MD5 c8740143760f81a73fd80f40a98015be
BLAKE2b-256 e05a5f2b2c02a42e0844eba4d73bca3244d78054e80f128dfcf9dc52f149353b

See more details on using hashes here.

File details

Details for the file tgcalls-0.0.12-cp36-cp36m-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tgcalls-0.0.12-cp36-cp36m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.6m, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for tgcalls-0.0.12-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e3cc964654124255d76bc0d4fa08a0687483e151a347ef2739f17b53269de21d
MD5 d27949e97f5e72998e587fc0e76d7e59
BLAKE2b-256 aa298f010274aea4817eee7b03bccd6eaec86eb0208948f8459d1800b96f985c

See more details on using hashes here.

Supported by

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