瀏覽代碼

Adapt to changes in telegram's api

drymer 2 年之前
父節點
當前提交
002df9336e
共有 3 個檔案被更改,包括 14 行新增4 行删除
  1. 9
    2
      jabbergram.py
  2. 2
    2
      requirements.txt
  3. 3
    0
      seeIdGroups.py

+ 9
- 2
jabbergram.py 查看文件

@@ -111,6 +111,10 @@ class Jabbergram(sleekxmpp.ClientXMPP):
111 111
                     name = ''
112 112
                     size = 0
113 113
 
114
+                    if update.edited_message:
115
+                        update_id = update.update_id + 1
116
+                        continue
117
+
114 118
                     if update.message.from_user:
115 119
                         user = str(update.message.from_user.username)
116 120
 
@@ -176,7 +180,7 @@ class Jabbergram(sleekxmpp.ClientXMPP):
176 180
                                       'but the XMPP server doesn\'t support H'\
177 181
                                       'TTP Upload.'
178 182
 
179
-                    elif update.message.new_chat_member:
183
+                    elif update.message.new_chat_members:
180 184
                         message = 'This user has joined the group.'
181 185
                     elif update.message.left_chat_member:
182 186
                         message = 'This user has left the group.'
@@ -203,7 +207,10 @@ class Jabbergram(sleekxmpp.ClientXMPP):
203 207
                     else:
204 208
                         msg = user + ": " + message
205 209
 
206
-                    chat = '@' + update.message.chat.username
210
+                    if update.message.chat.type == 'supergroup':
211
+                        chat = '@' + update.message.chat.username
212
+                    else:
213
+                        chat = str(update.message.chat.id)
207 214
 
208 215
                     if chat not in self.groups:
209 216
                         chat = str(update.message.chat_id)

+ 2
- 2
requirements.txt 查看文件

@@ -1,3 +1,3 @@
1
-sleekxmpp >= 1.3.1
2
-python-telegram-bot >= 4.0.3
1
+sleekxmpp >= 1.3.2
2
+python-telegram-bot >= 6.1.0
3 3
 requests >= 2.11.1

+ 3
- 0
seeIdGroups.py 查看文件

@@ -30,6 +30,9 @@ printed = []
30 30
 while True:
31 31
     try:
32 32
         for update in bot.getUpdates(offset=update_id, timeout=10):
33
+            if update.edited_message:
34
+                update_id = update.update_id + 1
35
+                continue
33 36
             chat_id = update.message.chat_id
34 37
             chat_title = update.message
35 38
             if chat_id not in printed:

Loading…
取消
儲存