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 continue
if update.message.from_user: 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 # sometimes there's no user. weird, but it happens
if not user: 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 # sometimes there's no user. weird, but it happens
# let's take last_name elif update.message['from']:
if not user: user = str(update.message['from'].first_name)
user = str(update.message.from_user.last_name)
if update.message.audio or update.message.document or \ if update.message.audio or update.message.document or \
update.message.photo or update.message.video \ update.message.photo or update.message.video \
@ -207,7 +206,8 @@ class Jabbergram(sleekxmpp.ClientXMPP):
else: else:
msg = user + ": " + message 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 chat = '@' + update.message.chat.username
else: else:
chat = str(update.message.chat.id) chat = str(update.message.chat.id)