mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
feat(wechatmp): add support for message encryption
- Add support for message encryption in WeChat MP channel. - Add `wechatmp_aes_key` configuration item to `config.json`.
This commit is contained in:
@@ -16,6 +16,7 @@ from channel.chat_channel import ChatChannel
|
||||
from channel.wechatmp.common import *
|
||||
from channel.wechatmp.wechatmp_client import WechatMPClient
|
||||
from wechatpy.exceptions import WeChatClientException
|
||||
from wechatpy.crypto import WeChatCrypto
|
||||
|
||||
import web
|
||||
# If using SSL, uncomment the following lines, and modify the certificate path.
|
||||
@@ -34,7 +35,12 @@ class WechatMPChannel(ChatChannel):
|
||||
self.NOT_SUPPORT_REPLYTYPE = []
|
||||
appid = conf().get("wechatmp_app_id")
|
||||
secret = conf().get("wechatmp_app_secret")
|
||||
token = conf().get("wechatmp_token")
|
||||
aes_key = conf().get("wechatmp_aes_key")
|
||||
self.client = WechatMPClient(appid, secret)
|
||||
self.crypto = None
|
||||
if aes_key:
|
||||
self.crypto = WeChatCrypto(token, aes_key, appid)
|
||||
if self.passive_reply:
|
||||
# Cache the reply to the user's first message
|
||||
self.cache_dict = dict()
|
||||
|
||||
Reference in New Issue
Block a user