mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-19 21:38:18 +08:00
fix: fix 'NoneType' object does not support item assignment error (#2525)
### Problem Description When `context` is `None`, it should not be used for assignment operations. ### Solution Adjusted the code logic to ensure that `context` is not `None` before performing any item assignment.
This commit is contained in:
@@ -146,6 +146,7 @@ class ChatChannel(Channel):
|
|||||||
elif context["origin_ctype"] == ContextType.VOICE: # 如果源消息是私聊的语音消息,允许不匹配前缀,放宽条件
|
elif context["origin_ctype"] == ContextType.VOICE: # 如果源消息是私聊的语音消息,允许不匹配前缀,放宽条件
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
logger.info("[chat_channel]receive single chat msg, but checkprefix didn't match")
|
||||||
return None
|
return None
|
||||||
content = content.strip()
|
content = content.strip()
|
||||||
img_match_prefix = check_prefix(content, conf().get("image_create_prefix",[""]))
|
img_match_prefix = check_prefix(content, conf().get("image_create_prefix",[""]))
|
||||||
|
|||||||
@@ -156,11 +156,11 @@ class WebChannel(ChatChannel):
|
|||||||
from_user_id=user_id,
|
from_user_id=user_id,
|
||||||
other_user_id = user_id
|
other_user_id = user_id
|
||||||
))
|
))
|
||||||
context["isgroup"] = False
|
|
||||||
# context["session"] = web.storage(session_id=user_id)
|
|
||||||
|
|
||||||
if not context:
|
if not context:
|
||||||
return json.dumps({"status": "error", "message": "Failed to process message"})
|
return json.dumps({"status": "error", "message": "Failed to process message"})
|
||||||
|
|
||||||
|
context["isgroup"] = False
|
||||||
|
# context["session"] = web.storage(session_id=user_id)
|
||||||
|
|
||||||
self.produce(context)
|
self.produce(context)
|
||||||
return json.dumps({"status": "success", "message": "Message received"})
|
return json.dumps({"status": "success", "message": "Message received"})
|
||||||
@@ -176,7 +176,6 @@ class WebChannel(ChatChannel):
|
|||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
def startup(self):
|
def startup(self):
|
||||||
logger.setLevel("WARN")
|
|
||||||
print("\nWeb Channel is running, please visit http://localhost:9899/chat")
|
print("\nWeb Channel is running, please visit http://localhost:9899/chat")
|
||||||
|
|
||||||
urls = (
|
urls = (
|
||||||
|
|||||||
Reference in New Issue
Block a user