MarshalX / tgcalls

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

Add "participant_list_updated" event #143

Closed MarshalX closed 3 years ago

MarshalX commented 3 years ago

Should be occurred on MTProto update after comparing with group call instance by call id and so on. Callback should get 2 args: group call instance to easy access to method and filed, wrapped updated participants list.

enum name: PARTICIPANT_LIST_UPDATED. this event is common so should be related to base GroupCall class

need to extend already existed participant wrapper for bridges

MarshalX commented 3 years ago

Ways to register a callback:

1:

async def participants_are_updated(group_call, participants):
    print(f'Updated participant list: {participants}')

group_call.on_participant_list_updated(participants_are_updated)

2:

@group_call.on_participant_list_updated
async def participants_are_updated(gc, participants):
    print(f'Updated participant list: {participants}')

3:

async def participants_are_updated(gc, participants):
        print(f'Updated participant list: {participants}')

group_call.add_handler(participants_are_updated, GroupCallAction.PARTICIPANT_LIST_UPDATED)

Telethon output:

Updated participant list: [<GroupCallParticipantWrapper>({'peer': <telethon.tl.types.PeerChannel object at 0x10eb4a5b0>, 'date': datetime.datetime(2021, 8, 22, 15, 35, 51, tzinfo=datetime.timezone.utc), 'source': 1382476690, 'muted': True, 'left': False, 'can_self_unmute': True, 'just_joined': False, 'versioned': False, 'min': False, 'muted_by_you': False, 'volume_by_admin': True, 'is_self': False, 'video_joined': False, 'active_date': None, 'volume': None, 'about': '🧑🏻\u200d💻DEV. More info inside...', 'raise_hand_rating': None})]

Pyrogram output:

Updated participant list: [<GroupCallParticipantWrapper>({'peer': pyrogram.raw.types.PeerChannel(channel_id=1359572958), 'date': 1629646551, 'source': 1382476690, 'muted': True, 'left': False, 'can_self_unmute': True, 'just_joined': False, 'versioned': False, 'min': False, 'muted_by_you': False, 'volume_by_admin': True, 'is_self': False, 'video_joined': None, 'active_date': None, 'volume': None, 'about': '🧑🏻\u200d💻DEV. More info inside...', 'raise_hand_rating': None})]