mirror of
https://github.com/zhayujie/bot-on-anything.git
synced 2026-02-20 17:59:44 +08:00
企业微信wechatcom
This commit is contained in:
25
README.md
25
README.md
@@ -18,7 +18,7 @@
|
||||
- [x] [个人微信](https://github.com/zhayujie/bot-on-anything#2%E4%B8%AA%E4%BA%BA%E5%BE%AE%E4%BF%A1)
|
||||
- [x] [订阅号](https://github.com/zhayujie/bot-on-anything#3%E4%B8%AA%E4%BA%BA%E8%AE%A2%E9%98%85%E5%8F%B7)
|
||||
- [x] [服务号](https://github.com/zhayujie/bot-on-anything#4%E4%BC%81%E4%B8%9A%E6%9C%8D%E5%8A%A1%E5%8F%B7)
|
||||
- [ ] 企业微信
|
||||
- [x] 企业微信
|
||||
- [x] [Telegram](https://github.com/zhayujie/bot-on-anything#6telegram)
|
||||
- [x] [QQ](https://github.com/zhayujie/bot-on-anything#5qq)
|
||||
- [x] [钉钉](https://github.com/zhayujie/bot-on-anything#10%E9%92%89%E9%92%89)
|
||||
@@ -590,6 +590,29 @@ pip3 install requests flask
|
||||
3. 订阅菜单添加事件(接收消息v2.0) 配置请求地址(配置中的对外地址如 https://xx.xx.com:8081)
|
||||
4. 版本管理与发布中上架应用,app中会收到审核信息,通过审核后在群里添加自建应用
|
||||
|
||||
### 12.企业微信
|
||||
|
||||
**需要:** 一个服务器、一个已认证的企业微信。
|
||||
|
||||
企业微信的 `config.json` 配置只需修改type为`wechat_com`,默认接收消息服务器URL:http://ip:8888/wechat
|
||||
|
||||
```bash
|
||||
"channel": {
|
||||
"type": "wechat_com",
|
||||
|
||||
"wechat_mp": {
|
||||
"wechat_token": "YOUR TOKEN", # token值
|
||||
"port": "8888", # 程序启动监听的端口
|
||||
"app_id": "YOUR APP ID", # app ID
|
||||
"app_secret": "YOUR APP SECRET" # app secret
|
||||
"wechat_corp_id": "YOUR CORP ID"
|
||||
"wechat_encoding_aes_key": "YOUR AES KEY"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
注意:需将服务器ip地址配置在 "企业可信IP" 内,否则用户将收不到主动推送的消息。
|
||||
|
||||
### 通用配置
|
||||
|
||||
+ `clear_memory_commands`: 对话内指令,主动清空前文记忆,字符串数组可自定义指令别名。
|
||||
|
||||
@@ -27,7 +27,7 @@ def handler_msg():
|
||||
return WechatEnterpriseChannel().handle()
|
||||
|
||||
|
||||
_conf = conf().get("wechat_com")
|
||||
_conf = conf().get("channel").get("wechat_com")
|
||||
|
||||
|
||||
class WechatEnterpriseChannel(Channel):
|
||||
@@ -42,7 +42,7 @@ class WechatEnterpriseChannel(Channel):
|
||||
|
||||
def startup(self):
|
||||
# start message listener
|
||||
app.run(host='0.0.0.0', port=8888)
|
||||
app.run(host='0.0.0.0', port=_conf.get('port'))
|
||||
|
||||
def send(self, msg, receiver):
|
||||
logger.info('[WXCOM] sendMsg={}, receiver={}'.format(msg, receiver))
|
||||
@@ -86,9 +86,8 @@ class WechatEnterpriseChannel(Channel):
|
||||
abort(403)
|
||||
msg = parse_message(message)
|
||||
if msg.type == 'text':
|
||||
reply = '收到,思考中...'
|
||||
thread_pool.submit(self._do_send, msg.content, msg.source)
|
||||
else:
|
||||
reply = 'Can not handle this for now'
|
||||
self.client.message.send_text(self.AppId, msg.source, reply)
|
||||
self.client.message.send_text(self.AppId, msg.source, reply)
|
||||
return 'success'
|
||||
|
||||
@@ -46,11 +46,12 @@
|
||||
"port": "80"
|
||||
},
|
||||
"wechat_com": {
|
||||
"wechat_token": "",
|
||||
"wechat_encoding_aes_key":"",
|
||||
"wechat_corp_id":"",
|
||||
"appid":"",
|
||||
"secret":""
|
||||
"wechat_token": "",
|
||||
"wechat_encoding_aes_key":"",
|
||||
"wechat_corp_id":"",
|
||||
"appid":"",
|
||||
"secret":"",
|
||||
"port": "8888"
|
||||
},
|
||||
|
||||
"gmail": {
|
||||
|
||||
Reference in New Issue
Block a user