Преглед на файлове

Adapt to telegram-bot api's change

drymer преди 2 години
родител
ревизия
2679ad6f2e
променени са 1 файла, в които са добавени 7 реда и са изтрити 7 реда
  1. 7
    7
      jabbergram.py

+ 7
- 7
jabbergram.py Целия файл

@@ -116,16 +116,15 @@ class Jabbergram(sleekxmpp.ClientXMPP):
116 116
                         continue
117 117
 
118 118
                     if update.message.from_user:
119
-                        user = str(update.message.from_user.username)
119
+                        user = update.message.from_user.username
120 120
 
121 121
                         # sometimes there's no user. weird, but it happens
122 122
                         if not user:
123
-                            user = str(update.message.from_user.first_name)
123
+                            user = update.message.from_user.first_name
124 124
 
125
-                        # even weirder is that username or first_name exists
126
-                        # let's take last_name
127
-                        if not user:
128
-                            user = str(update.message.from_user.last_name)
125
+                    # sometimes there's no user. weird, but it happens
126
+                    elif update.message['from']:
127
+                        user = str(update.message['from'].first_name)
129 128
 
130 129
                     if update.message.audio or update.message.document or \
131 130
                        update.message.photo or update.message.video \
@@ -207,7 +206,8 @@ class Jabbergram(sleekxmpp.ClientXMPP):
207 206
                     else:
208 207
                         msg = user + ": " + message
209 208
 
210
-                    if update.message.chat.type == 'supergroup':
209
+                    if update.message.chat.type == 'supergroup' and \
210
+                       update.message.chat.username:
211 211
                         chat = '@' + update.message.chat.username
212 212
                     else:
213 213
                         chat = str(update.message.chat.id)

Loading…
Отказ
Запис