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

TODO list

  • Incoming and Outgoing calls (already there and working, but not in release).
  • Private and group video calls.
  • Python binary wheels for Windows 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

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

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

Uploaded CPython 3.9macOS 11.0+ ARM64

tgcalls-0.0.12.dev1-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.dev1-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.dev1-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.dev1-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.dev1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tgcalls-0.0.12.dev1-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.dev1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dabec5fbe668e5fcd2aa9b1cc9e2d3ae6c269e0786d3e29b75627a8c6a8a881a
MD5 ce3e1b14f7e87cb2bd0b027db6e76b96
BLAKE2b-256 ff51762b179213c7b9339a6d84d037b7a2689cac79c33bd682c9c8c4402da4c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12.dev1-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.dev1-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 25109023d6e6988e0f52845b23942c4e0b4d5aa7fa95a80566439f83171afcc3
MD5 e0dc47f9690e839389099e2340573498
BLAKE2b-256 8955974b1e301b6e7116d9a7dcda68ecfd9122a8cd49cfe666572ba7297bc34a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12.dev1-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.dev1-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d99934d2d23b72e733cbb54ffbe4391a89fe87d49a79b4c28bec58f6b6ff2aea
MD5 f7e39deedf92d6337e4581c2a701d873
BLAKE2b-256 0ce558a7503e83e32952486c244a532713c93cfdb482ed54906bd362a917a17a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12.dev1-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.dev1-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a3d2bc5e444c96f1f1d30fe03b8a249a389b1ebbc6c58b770762096259c90dfe
MD5 4e419db252dc74b6f757bc8ed013b112
BLAKE2b-256 307b28428f030278cc5599c648bf09e21d0aa9ed6d4a550ff2948c3ad71bdc80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgcalls-0.0.12.dev1-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.dev1-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4b667d57406dfdc11813ae7e597573501b98bedd71a3072def26eab4bf5bebd2
MD5 315e920662435af7f03a9497a2a3790a
BLAKE2b-256 57fd45a6aca8a60cd55c14a407e3d49e306cff75f9ea90ca9b304b9db430dec8

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