diff --git a/jabbergram.py b/jabbergram.py index dfde2bc..828ca3b 100755 --- a/jabbergram.py +++ b/jabbergram.py @@ -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)