Ver código fonte

feat:modify wechatcom to wechatcom_app

lanvent 3 anos atrás
pai
commit
2ec5374765
3 arquivos alterados com 11 adições e 10 exclusões
  1. 1 1
      channel/channel_factory.py
  2. 9 8
      channel/wechatcom/wechatcomapp_channel.py
  3. 1 1
      config.py

+ 1 - 1
channel/channel_factory.py

@@ -29,7 +29,7 @@ def create_channel(channel_type):
         from channel.wechatmp.wechatmp_channel import WechatMPChannel
 
         return WechatMPChannel(passive_reply=False)
-    elif channel_type == "wechatcom":
+    elif channel_type == "wechatcom_app":
         from channel.wechatcom.wechatcomapp_channel import WechatComAppChannel
 
         return WechatComAppChannel()

+ 9 - 8
channel/wechatcom/wechatcomapp_channel.py

@@ -131,12 +131,12 @@ class Query:
     def GET(self):
         channel = WechatComAppChannel()
         params = web.input()
-        signature = params.msg_signature
-        timestamp = params.timestamp
-        nonce = params.nonce
-        echostr = params.echostr
-        print(params)
+        logger.info("[wechatcom] receive params: {}".format(params))
         try:
+            signature = params.msg_signature
+            timestamp = params.timestamp
+            nonce = params.nonce
+            echostr = params.echostr
             echostr = channel.crypto.check_signature(
                 signature, timestamp, nonce, echostr
             )
@@ -147,10 +147,11 @@ class Query:
     def POST(self):
         channel = WechatComAppChannel()
         params = web.input()
-        signature = params.msg_signature
-        timestamp = params.timestamp
-        nonce = params.nonce
+        logger.info("[wechatcom] receive params: {}".format(params))
         try:
+            signature = params.msg_signature
+            timestamp = params.timestamp
+            nonce = params.nonce
             message = channel.crypto.decrypt_message(
                 web.data(), signature, timestamp, nonce
             )

+ 1 - 1
config.py

@@ -86,7 +86,7 @@ available_setting = {
     # chatgpt指令自定义触发词
     "clear_memory_commands": ["#清除记忆"],  # 重置会话指令,必须以#开头
     # channel配置
-    "channel_type": "wx",  # 通道类型,支持:{wx,wxy,terminal,wechatmp,wechatmp_service}
+    "channel_type": "wx",  # 通道类型,支持:{wx,wxy,terminal,wechatmp,wechatmp_service,wechatcom_app}
     "debug": False,  # 是否开启debug模式,开启后会打印更多日志
     "appdata_dir": "",  # 数据目录
     # 插件配置