Получение идентификатора пользователя в TwitchIOPython

Программы на Python
Anonymous
Получение идентификатора пользователя в TwitchIO

Сообщение Anonymous »


I'm writing a Twitch bot. I'd like to be able to store ranking of number of comments posted. So I'd like to label users by their Twitch ID in DB.

I wrote this get function :

5 def getId(chatter : Union[twitchio.Chatter, twitchio.PartialChatter]): 6 if isinstance(chatter,twitchio.chatter.Chatter): 7 8 userVar = chatter.channel.user() 9 print("NormalChatter", type(userVar)) 10 11 return userVar 12 #return chatter.channel.user().id 13 #return chatter.id 14 15 elif isinstance(chatter, twitchio.PartialChatter): 16 return chatter.user().id 17 else: 18 print("NoneBoy") While getting chatters from Channel object I end up with Chatter object as tested by print in line 9. Chatter object should have "id" attribute as per [https://twitchio.dev/en/stable/referenc ... io.Chatter] It has the attribute, but he attribute is NULL.

I tried to get ID by using channel and "user()" coroutine, but it seems like it does not return anything other than itself (chatter.channel.user().id causes 'AttributeError: 'coroutine' object has no attribute 'id' ') I did it because I thought maybe it's some inheritance from PartialChatter obj.

Does anyone knows how to get this user ID ?


Источник: https://stackoverflow.com/questions/772 ... n-twitchio

Вернуться в «Python»