Spaces:
Runtime error
Runtime error
cloud26 commited on
Commit ·
0b4b9fd
1
Parent(s): 0cc1c40
fix index error
Browse files- wechat-server/web.py +4 -1
wechat-server/web.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
import os
|
|
|
|
| 4 |
from functools import lru_cache
|
| 5 |
from xml.etree.ElementTree import fromstring
|
| 6 |
|
|
@@ -37,6 +38,7 @@ wxcpt = WXBizMsgCrypt(WECHAT_TOKEN, WECHAT_AESKEY, WECHAT_CORPID)
|
|
| 37 |
|
| 38 |
# 先用个简单的字典存一下,后面可以考虑用 redis
|
| 39 |
last_reply_time = dict()
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
def access_token():
|
|
@@ -100,7 +102,8 @@ def handle_message(message_token: str):
|
|
| 100 |
print("message_block", message_block)
|
| 101 |
if message_block.get("msgtype", None) == "text":
|
| 102 |
content = message_block["text"]["content"]
|
| 103 |
-
|
|
|
|
| 104 |
text_message_blocks.append(message_block)
|
| 105 |
if message_block.get("msgtype", None) == "image":
|
| 106 |
content = message_block["image"]["media_id"]
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
import os
|
| 4 |
+
import time
|
| 5 |
from functools import lru_cache
|
| 6 |
from xml.etree.ElementTree import fromstring
|
| 7 |
|
|
|
|
| 38 |
|
| 39 |
# 先用个简单的字典存一下,后面可以考虑用 redis
|
| 40 |
last_reply_time = dict()
|
| 41 |
+
server_start_time = int(time.time())
|
| 42 |
|
| 43 |
|
| 44 |
def access_token():
|
|
|
|
| 102 |
print("message_block", message_block)
|
| 103 |
if message_block.get("msgtype", None) == "text":
|
| 104 |
content = message_block["text"]["content"]
|
| 105 |
+
# 限制一下要大于服务启动的时间
|
| 106 |
+
if message_block["send_time"] > last_reply_time.get(external_userid, server_start_time):
|
| 107 |
text_message_blocks.append(message_block)
|
| 108 |
if message_block.get("msgtype", None) == "image":
|
| 109 |
content = message_block["image"]["media_id"]
|