MarshalX / tgcalls

Voice chats, private incoming and outgoing calls in Telegram for Developers
https://t.me/tgcallslib
GNU Lesser General Public License v3.0
523 stars 93 forks source link

Sometimes not working. #92

Closed mojtabaasg closed 3 years ago

mojtabaasg commented 3 years ago

Sometimes after starting GroupCall, nothing happens, bot will stay mute, and after several seconds, bot will leave voicechat. I have to execute my code several times to make it play my music. raw file is ok and has no problems. i think this is a bug in pytgcalls thanks

MarshalX commented 3 years ago

How I can reproduce it?

Moji-Asg commented 3 years ago

I didn't get your point:(

RynKings commented 3 years ago

it because the bot not connected to the voice chat

try to add this code

group_call = GroupCall(app, 'etc/sample_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, 'Reconnect....')
        await group_call.reconnect()

or when you start it

group_call.start(chat_id)
if not group_call.is_connected:
    print('reconnecting')
    await asyncio.sleep(3)
    await group_call.reconnect()
group_call.set_is_mute(False)
MarshalX commented 3 years ago

it because the bot not connected to the voice chat

try to add this code

group_call = GroupCall(app, 'etc/sample_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, 'Reconnect....')
        await group_call.reconnect()

or when you start it

group_call.start(chat_id)
if not group_call.is_connected:
    print('reconnecting')
    await asyncio.sleep(3)
    await group_call.reconnect()
group_call.set_is_mute(False)

The second way looks bad(

MarshalX commented 3 years ago

it because the bot not connected to the voice chat

try to add this code

group_call = GroupCall(app, 'etc/sample_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, 'Reconnect....')
        await group_call.reconnect()

or when you start it

group_call.start(chat_id)
if not group_call.is_connected:
    print('reconnecting')
    await asyncio.sleep(3)
    await group_call.reconnect()
group_call.set_is_mute(False)

The first way will triggered even you try to call .stop() to leave the VC