MarshalX/tgcalls

Implement Telethon MTProto bridge

MarshalX opened this issue · 8 comments

Ability to implement custom mtproto client was added in #96

Whats need to know:

  1. Code with mtproto bridges available https://github.com/MarshalX/tgcalls/tree/add-custom-mtproto-clients-support branch
  2. File for Telethon bridge already created https://github.com/MarshalX/tgcalls/blob/add-custom-mtproto-clients-support/pytgcalls/pytgcalls/mtproto/telethon_bridge.py. You just need to implement methods in this class
  3. As an example of bridge implementation you can use Pyrogram bridge https://github.com/MarshalX/tgcalls/blob/add-custom-mtproto-clients-support/pytgcalls/pytgcalls/mtproto/pyrogram_bridge.py
  4. After implementing (or during) to test u need to delete this line to enable TelethonBridge support
    raise NotImplementedError('Telethon bridge not ready yet. Soon.')

Snippet how to create factory with Telethon MTProto bridge:

from pytgcalls import GroupCallFactory
telethon_group_call_factory = GroupCallFactory(
        client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON, enable_logs_to_console=False
)

there client is Telethon app.

After that you can create file, device or raw group call instance:

file_group_call = group_call_factory.get_file_group_call('input.raw')
device_group_call = group_call_factory.get_device_group_call(audio_output_device='External Headphones')
# and so on...

ParticipantWrapper renamed to GroupCallParticipantWrapper

To install pytgcalls version with Telethon support:

pip3 install -U git+https://github.com/MarshalX/tgcalls@add-custom-mtproto-clients-support#subdirectory=pytgcalls

also u need to install the last version of Telethon:

pip3 install -U telethon

some code snippet to run:

from telethon import TelegramClient
from pytgcalls import GroupCallFactory
client = TelegramClient(session_name, api_id, api_hash)
client.start()
group_call_factory = GroupCallFactory(client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON)
group_call = group_call_factory.get_file_group_call('input.raw')
await group_call.start('@tgcallschat')
# and some idle here

nice

@MarshalX commented on Jul 16, 2021, 4:58 PM GMT+3:

To install pytgcalls version with Telethon support:

pip3 install -U git+https://github.com/MarshalX/tgcalls@add-custom-mtproto-clients-support#subdirectory=pytgcalls

also u need to install the last version of Telethon:

pip3 install -U telethon

some code snippet to run:

from telethon import TelegramClient
from pytgcalls import GroupCallFactory
client = TelegramClient(session_name, api_id, api_hash)
client.start()
group_call_factory = GroupCallFactory(client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON)
group_call = group_call_factory.get_file_group_call('input.raw')
await group_call.start('@tgcallschat')
# and some idle here

from telethon import TelegramClient
from pytgcalls import GroupCallFactory

import asyncio
async def main():
    await client.start()
    group_call_factory = GroupCallFactory(client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON)
    group_call = group_call_factory.get_file_group_call('input.raw')
    await group_call.start('@tgcallschat')

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Superb