mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-20 13:47:15 +08:00
fix: check if event is subscribe
This commit is contained in:
@@ -30,9 +30,12 @@ class Query:
|
|||||||
msg.event, msg.source
|
msg.event, msg.source
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
reply_text = subscribe_msg()
|
if msg.event in ["subscribe", "subscribe_scan"]:
|
||||||
replyPost = create_reply(reply_text, msg)
|
reply_text = subscribe_msg()
|
||||||
return replyPost.render()
|
replyPost = create_reply(reply_text, msg)
|
||||||
|
return replyPost.render()
|
||||||
|
else:
|
||||||
|
return "success"
|
||||||
wechatmp_msg = WeChatMPMessage(msg, client=channel.client)
|
wechatmp_msg = WeChatMPMessage(msg, client=channel.client)
|
||||||
if wechatmp_msg.ctype in [ContextType.TEXT, ContextType.IMAGE, ContextType.VOICE]:
|
if wechatmp_msg.ctype in [ContextType.TEXT, ContextType.IMAGE, ContextType.VOICE]:
|
||||||
from_user = wechatmp_msg.from_user_id
|
from_user = wechatmp_msg.from_user_id
|
||||||
|
|||||||
@@ -25,16 +25,18 @@ class Query:
|
|||||||
message = web.data() # todo crypto
|
message = web.data() # todo crypto
|
||||||
msg = parse_message(message)
|
msg = parse_message(message)
|
||||||
logger.debug("[wechatmp] Receive post data:\n" + message.decode("utf-8"))
|
logger.debug("[wechatmp] Receive post data:\n" + message.decode("utf-8"))
|
||||||
|
|
||||||
if msg.type == "event":
|
if msg.type == "event":
|
||||||
logger.info(
|
logger.info(
|
||||||
"[wechatmp] Event {} from {}".format(
|
"[wechatmp] Event {} from {}".format(
|
||||||
msg.event, msg.source
|
msg.event, msg.source
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
reply_text = subscribe_msg()
|
if msg.event in ["subscribe", "subscribe_scan"]:
|
||||||
replyPost = create_reply(reply_text, msg)
|
reply_text = subscribe_msg()
|
||||||
return replyPost.render()
|
replyPost = create_reply(reply_text, msg)
|
||||||
|
return replyPost.render()
|
||||||
|
else:
|
||||||
|
return "success"
|
||||||
|
|
||||||
wechatmp_msg = WeChatMPMessage(msg, client=channel.client)
|
wechatmp_msg = WeChatMPMessage(msg, client=channel.client)
|
||||||
if wechatmp_msg.ctype in [ContextType.TEXT, ContextType.IMAGE, ContextType.VOICE]:
|
if wechatmp_msg.ctype in [ContextType.TEXT, ContextType.IMAGE, ContextType.VOICE]:
|
||||||
|
|||||||
Reference in New Issue
Block a user