Adapt to telegram-bot api's change

This commit is contained in:
drymer 2017-07-18 22:38:36 +02:00
parent 002df9336e
commit 2679ad6f2e
1 changed files with 7 additions and 7 deletions

View File

@ -116,16 +116,15 @@ class Jabbergram(sleekxmpp.ClientXMPP):
continue
if update.message.from_user:
user = str(update.message.from_user.username)
user = update.message.from_user.username
# sometimes there's no user. weird, but it happens
if not user:
user = str(update.message.from_user.first_name)
user = update.message.from_user.first_name
# even weirder is that username or first_name exists
# let's take last_name
if not user:
user = str(update.message.from_user.last_name)
# sometimes there's no user. weird, but it happens
elif update.message['from']:
user = str(update.message['from'].first_name)
if update.message.audio or update.message.document or \
update.message.photo or update.message.video \
@ -207,7 +206,8 @@ class Jabbergram(sleekxmpp.ClientXMPP):
else:
msg = user + ": " + message
if update.message.chat.type == 'supergroup':
if update.message.chat.type == 'supergroup' and \
update.message.chat.username:
chat = '@' + update.message.chat.username
else:
chat = str(update.message.chat.id)