luckydonald / pytg

Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
MIT License
369 stars 76 forks source link

May need to update example command_who_am_i.py #100

Closed Shatnerz closed 7 years ago

Shatnerz commented 7 years ago

The problem

in command_who_am_i.py

res = s.get_self()
username = res.username  # this will raise a key error
print res.keys()

# [u'first_name',
#  u'print_name',
#  u'peer_type',
#  u'when',
#  u'phone',
#  u'last_name',
#  u'flags',
#  u'peer_id',
#  u'id']

I don't know the inner working of pytg and tg, but I suspect Telegram changed the response slightly and username is no longer used. It may be worth updating the examples. I may get around to a pull request with the changes.

Your environment

OS: Ubuntu 14.04 Python: 2.7 pytg: 0.4.10

luckydonald commented 7 years ago

Does the account of you bot has a @username? If you have not set a username, this field might not be present.

Shatnerz commented 7 years ago

Oh okay. I was checking out a user, not a bot. They may have been the problem.

luckydonald commented 7 years ago

I assume this is resolved?

Shatnerz commented 7 years ago

Yes

On Jan 9, 2017 11:14 AM, "Luckydonald" notifications@github.com wrote:

I assume this is resolved?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/luckydonald/pytg/issues/100#issuecomment-271327982, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGzR1RAs1DdI-0pQrpH_ShWawIqcZcLks5rQlzygaJpZM4K0WQt .