wechaty-web-panel 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +14 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/vcs.xml +6 -0
  7. package/.idea/wechaty-web-panel.iml +12 -0
  8. package/.prettierrc +8 -0
  9. package/LICENSE +21 -0
  10. package/README.md +175 -0
  11. package/doc/img/async.png +0 -0
  12. package/doc/img/event.png +0 -0
  13. package/doc/img/everyday.png +0 -0
  14. package/doc/img/func.jpeg +0 -0
  15. package/doc/img/group.jpeg +0 -0
  16. package/doc/img/index.png +0 -0
  17. package/doc/img/material.png +0 -0
  18. package/doc/img/news.jpeg +0 -0
  19. package/doc/img/qrcode-s.png +0 -0
  20. package/doc/img/qrcode.png +0 -0
  21. package/doc/img/roomasync.png +0 -0
  22. package/doc/img/schedule.png +0 -0
  23. package/doc/img/user-center.png +0 -0
  24. package/package.json +67 -0
  25. package/src/common/aiDb.js +23 -0
  26. package/src/common/configDb.js +86 -0
  27. package/src/common/index.js +321 -0
  28. package/src/common/reply.js +24 -0
  29. package/src/common/roomAvatarDb.js +24 -0
  30. package/src/common/userDb.js +24 -0
  31. package/src/handlers/on-error.js +13 -0
  32. package/src/handlers/on-friend.js +45 -0
  33. package/src/handlers/on-heartbeat.js +12 -0
  34. package/src/handlers/on-login.js +35 -0
  35. package/src/handlers/on-logout.js +11 -0
  36. package/src/handlers/on-message.js +127 -0
  37. package/src/handlers/on-ready.js +18 -0
  38. package/src/handlers/on-roomjoin.js +36 -0
  39. package/src/handlers/on-roomleave.js +6 -0
  40. package/src/handlers/on-roomtopic.js +5 -0
  41. package/src/handlers/on-scan.js +16 -0
  42. package/src/index.js +45 -0
  43. package/src/lib/index.js +816 -0
  44. package/src/lib/nedb.js +87 -0
  45. package/src/proxy/aibotk.js +351 -0
  46. package/src/proxy/api.js +582 -0
  47. package/src/proxy/config.js +9 -0
  48. package/src/proxy/mqtt.js +91 -0
  49. package/src/proxy/superagent.js +117 -0
  50. package/src/proxy/tencent.js +40 -0
  51. package/src/service/event-dispatch-service.js +147 -0
  52. package/src/service/msg-filter-service.js +76 -0
  53. package/src/service/msg-filters.js +175 -0
  54. package/src/service/room-async-service.js +395 -0
  55. package/src/task/index.js +233 -0
  56. package/verpub.config.js +6 -0
package/.eslintignore ADDED
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ /node_modules/**
3
+ test
4
+ test/**
package/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ env: {
3
+ node: true,
4
+ es6: true,
5
+ },
6
+ extends: ['prettier', 'plugin:prettier/recommended'],
7
+ plugins: ['prettier'],
8
+ parser: 'babel-eslint',
9
+ // add your custom rules here
10
+ rules: {
11
+ 'no-unused-vars': 'off',
12
+ 'no-console': 'off',
13
+ },
14
+ }
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/wechaty-web-panel.iml" filepath="$PROJECT_DIR$/.idea/wechaty-web-panel.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "printWidth": 300,
3
+ "tabWidth": 2,
4
+ "semi": false,
5
+ "arrowParens": "always",
6
+ "singleQuote": true,
7
+ "bracketSpacing": true
8
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Leo_chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # Wechaty Web Panel
2
+
3
+ [![Wechaty Plugin Web Panel](https://img.shields.io/badge/Wechaty%20Plugin-WebPanel-brightgreen.svg)](https://github.com/gengchen528/wechaty-web-panel)
4
+ [![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://github.com/Wechaty/wechaty)
5
+
6
+ Wechaty Web Panel 插件,让你的 wechaty 机器人快速接入 web 控制面板
7
+
8
+ ## 面板主要功能
9
+
10
+ - [x] 微信每日说,定时给女朋友发送每日天气提醒,以及每日一句
11
+
12
+ * 定时提醒
13
+
14
+ - [x] 当天定时提醒 例:"提醒 我 18:00 下班了,记得带好随身物品"
15
+ - [x] 每天定时提醒 例:"提醒 我 每天 18:00 下班了,记得带好随身物品"
16
+ - [x] 指定日期提醒 例:"提醒 我 2019-05-10 8:00 还有 7 天是女朋友生日了,准备一下"
17
+
18
+ * 智能机器人
19
+
20
+ - [x] 天行机器人
21
+ - [x] 图灵机器人
22
+ - [x] 腾讯闲聊机器人
23
+ - [ ] 更多
24
+
25
+ * 群定时任务
26
+
27
+ - [x] 群新闻定时发送
28
+ - [x] 群消息定时发送
29
+ - [ ] 更多功能等你来 pr
30
+
31
+ * 关键词
32
+
33
+ - [x] 关键词加好友
34
+ - [x] 关键词加群
35
+ - [x] 关键词回复
36
+ - [x] 关键词事件
37
+ - [x] 天气查询 例:"上海天气"
38
+ - [x] 垃圾分类 例:"?香蕉皮"
39
+ - [x] 名人名言 例: "名人名言"
40
+ - [x] 老黄历查询 例: "黄历 2019-6-13"
41
+ - [x] 姓氏起源 例: "姓陈"
42
+ - [x] 星座运势 例: "\*双子座"
43
+ - [x] 神回复 例: "神回复"
44
+ - [x] 获取表情包 例: "表情包你好坏"
45
+ - [x] 获取美女图 例: "美女图"
46
+ - [x] 群合影 例: "群合影"
47
+ - [x] 牛年头像 例: "牛气冲天"
48
+ - [ ] 更多待你发现
49
+ - [x] 进群自动欢迎
50
+ - [x] 加好友自动回复
51
+
52
+ * 自动更新配置文件,无需重启
53
+
54
+ - [x] 默认给机器人发送 ‘更新’ 触发拉取新配置文件操作,可在面板`小助手配置->关键词回复->关键词事件`进行修改关键词
55
+
56
+ * 特色功能
57
+
58
+ - [x] 群合影
59
+ - [x] 主动发送消息
60
+ - [x] 主动更新配置
61
+ - [x] 主动同步好友和群列表
62
+ - [x] 多群消息同步
63
+
64
+ 更多详情介绍:[传送门](https://www.xkboke.com/web-inn/secretary/client.html#%E5%B0%8F%E5%8A%A9%E6%89%8B%E5%8A%9F%E8%83%BD%E4%B8%80%E8%A7%88)
65
+
66
+ ## 提前准备
67
+
68
+ ### 注册智能微秘书管理账号
69
+
70
+ 1. 注册:[智能微秘书](https://wechat.aibotk.com/#/signup)
71
+
72
+ 2. 初始化配置文件`小助手配置->基础配置`,修改后保存
73
+
74
+ 3. 个人中心获取`APIKEY`和`APISECRET`,后续配置用到
75
+
76
+ ![](./doc/img/user-center.png)
77
+
78
+ ### 注册天行数据账号
79
+
80
+ 由于本项目大部分定时资讯和一些天气接口来自于天行数据,所以需要提前准备好天行数据的账号,同时申请好相关接口的权限
81
+
82
+ 1、注册: [天行数据](https://www.tianapi.com/source/865c0f3bfa)
83
+
84
+ 2、申请接口权限
85
+
86
+ 必选接口
87
+ * [天行机器人](https://www.tianapi.com/apiview/47)
88
+ * [天气](https://www.tianapi.com/apiview/72)
89
+ * [新闻](https://www.tianapi.com/apiview/51)
90
+ * [垃圾分类](https://www.tianapi.com/apiview/97)
91
+
92
+ 可选接口(如果想使用相应的功能还是必须申请的),但是如果默认使用了天行机器人,以下功能接口无需申请也可以,机器人会直接返回对应信息
93
+
94
+ * [土味情话](https://www.tianapi.com/apiview/80)
95
+ * [名人名言](https://www.tianapi.com/apiview/92)
96
+ * [星座运势](https://www.tianapi.com/apiview/78)
97
+ * [姓氏起源](https://www.tianapi.com/apiview/94)
98
+ * [顺口溜](https://www.tianapi.com/apiview/54)
99
+ * [老黄历](https://www.tianapi.com/apiview/45)
100
+ * [神回复](https://www.tianapi.com/apiview/39)
101
+ * [歇后语](https://www.tianapi.com/apiview/38)
102
+ * [绕口令](https://www.tianapi.com/apiview/37)
103
+ * [疫情](https://www.tianapi.com/apiview/169)
104
+ * [网络取名](https://www.tianapi.com/apiview/36)
105
+
106
+ ## 开始
107
+
108
+ ### Step 1: 安装
109
+
110
+ ```
111
+ $ npm install wechaty-web-panel@latest wechaty@latest --save
112
+ ```
113
+
114
+ 如果安装长时间没有反应,可以尝试
115
+
116
+ ```
117
+ npm install wechaty-web-panel@latest wechaty@latest --save --canvas_binary_host_mirror=https://npm.taobao.org/mirrors/node-canvas-prebuilt/
118
+ ```
119
+
120
+ ### Step 2: 创建机器人并配置插件的`apiKey`和`apiSecret`
121
+
122
+ ```
123
+ $ vim mybot.js
124
+
125
+ const { Wechaty } = require('wechaty');
126
+ const WechatyWebPanelPlugin = require('wechaty-web-panel');
127
+ const name = 'wechat-assistant'
128
+ const bot = new Wechaty({
129
+ name, // generate xxxx.memory-card.json and save login data for the next login
130
+ puppet: 'wechaty-puppet-wechat',
131
+ });
132
+
133
+ bot
134
+ .use(WechatyWebPanelPlugin({apiKey:'', apiSecret: ''}))
135
+ .start()
136
+ .catch((e) => console.error(e));
137
+
138
+ ```
139
+
140
+ ### Step 3: 运行
141
+
142
+ ```
143
+ $ node mybot.js
144
+ ```
145
+
146
+ ### Step 4: 扫码进入
147
+
148
+ 进入面板`小助手配置->登录状态`扫码登录,或直接扫码控制台二维码登录
149
+
150
+ ![](./doc/img/qrcode-s.png)
151
+
152
+ ## 面板预览
153
+
154
+ ![](./doc/img/index.png)
155
+ ![](./doc/img/roomasync.png)
156
+ ![](./doc/img/everyday.png)
157
+ ![](./doc/img/schedule.png)
158
+ ![](./doc/img/event.png)
159
+ ![](./doc/img/material.png)
160
+
161
+ ## 功能预览
162
+
163
+ ![](./doc/img/news.jpeg)
164
+
165
+ 个人定时与群定时任务
166
+
167
+ ![](./doc/img/func.jpeg)
168
+
169
+ 群消息同步
170
+
171
+ ![](./doc/img/async.png)
172
+
173
+ 群合影
174
+
175
+ ![](./doc/img/group.jpeg)
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "wechaty-web-panel",
3
+ "version": "0.2.12",
4
+ "description": "",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "node test/index.js",
8
+ "release": "verpub publish",
9
+ "release:dry": "verpub --dry-run"
10
+ },
11
+ "keywords": [
12
+ "定时发送",
13
+ "微秘书",
14
+ "智能机器人",
15
+ "微信每日说",
16
+ "每日说",
17
+ "群消息同步",
18
+ "Wechaty",
19
+ "wechatEveryDay",
20
+ "wechaty",
21
+ "wechaty-plugin"
22
+ ],
23
+ "author": {
24
+ "name": "Leo_chen",
25
+ "url": "http://www.xkboke.com",
26
+ "email": "leo.gengchen@foxmail.com"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/gengchen528/wechaty-web-panel"
31
+ },
32
+ "license": "MIT",
33
+ "devDependencies": {
34
+ "babel-eslint": "^10.1.0",
35
+ "eslint": "^7.4.0",
36
+ "eslint-config-prettier": "^6.11.0",
37
+ "eslint-plugin-prettier": "^3.1.4",
38
+ "prettier": "^2.0.5"
39
+ },
40
+ "readme": "README.md",
41
+ "dependencies": {
42
+ "cheerio": "^1.0.0-rc.3",
43
+ "mcanvas": "^2.0.8",
44
+ "mqtt": "^4.2.6",
45
+ "nedb": "^1.8.0",
46
+ "node-schedule": "^1.3.2",
47
+ "qrcode-terminal": "^0.12.0",
48
+ "superagent": "^5.2.2",
49
+ "tencentcloud-sdk-nodejs": "^4.0.30",
50
+ "wechaty": "^0.63.3",
51
+ "wechaty-plugin-contrib": "^0.14.17",
52
+ "wechaty-puppet": "^0.41.4",
53
+ "wechaty-puppet-wechat": "^0.28.4"
54
+ },
55
+ "peerDependencies": {
56
+ "wechaty": "^0.63.3"
57
+ },
58
+ "publishConfig": {
59
+ "registry": " https://registry.npmjs.org/"
60
+ },
61
+ "engines": {
62
+ "node": ">=14.0",
63
+ "npm": ">=6.14"
64
+ },
65
+ "_id": "wechaty-web-panel@0.2.12",
66
+ "_commitid": "07b70c4"
67
+ }
@@ -0,0 +1,23 @@
1
+ const adb = require('../lib/nedb')()
2
+
3
+ async function addAibotConfig(info) {
4
+ try {
5
+ let doc = await adb.insert(info)
6
+ return doc
7
+ } catch (error) {
8
+ console.log('插入数据错误', error)
9
+ }
10
+ }
11
+
12
+ async function getAibotConfig() {
13
+ try {
14
+ let search = await adb.find({})
15
+ return search[0]
16
+ } catch (error) {
17
+ console.log('查询数据错误', error)
18
+ }
19
+ }
20
+ module.exports = {
21
+ addAibotConfig,
22
+ getAibotConfig,
23
+ }
@@ -0,0 +1,86 @@
1
+ const cdb = require('../lib/nedb.js')()
2
+
3
+ /**
4
+ * 添加配置文件
5
+ * @param {*} config
6
+ */
7
+ async function addConfig(info) {
8
+ try {
9
+ let doc = await cdb.insert(info)
10
+ return doc
11
+ } catch (error) {
12
+ console.log('插入数据错误', error)
13
+ }
14
+ }
15
+
16
+ /**
17
+ * 更新配置文件
18
+ * @param {*} config
19
+ */
20
+ async function updateConfig(config) {
21
+ try {
22
+ let res = await allConfig()
23
+ if (res) {
24
+ let up = await cdb.update({ id: config.id }, config)
25
+ return up
26
+ } else {
27
+ let add = await addConfig(config)
28
+ return add
29
+ }
30
+ } catch (error) {
31
+ console.log('配置文件更新失败', error)
32
+ }
33
+ }
34
+ /**
35
+ * 获取所有配置
36
+ */
37
+ async function allConfig() {
38
+ try {
39
+ let search = await cdb.find()
40
+ return search[0]
41
+ } catch (error) {
42
+ console.log('查询数据错误', error)
43
+ }
44
+ }
45
+ /**
46
+ * 每日任务
47
+ */
48
+ async function dayTaskSchedule() {
49
+ try {
50
+ let res = await cdb.find({})
51
+ return res[0].dayTaskSchedule
52
+ } catch (error) {
53
+ console.log('获取每日任务', error)
54
+ }
55
+ }
56
+ /**
57
+ * 群资讯
58
+ */
59
+ async function roomNewsSchedule() {
60
+ try {
61
+ let res = await cdb.find.find({})
62
+ return res[0].roomNewsSchedule
63
+ } catch (error) {
64
+ console.log('获取每日任务', error)
65
+ }
66
+ }
67
+ /**
68
+ * 群任务
69
+ */
70
+ async function roomTaskSchedule() {
71
+ try {
72
+ let res = await cdb.find.find({})
73
+ return res[0].roomTaskSchedule
74
+ } catch (error) {
75
+ console.log('获取每日任务', error)
76
+ }
77
+ }
78
+
79
+ module.exports = {
80
+ addConfig,
81
+ updateConfig,
82
+ allConfig,
83
+ dayTaskSchedule,
84
+ roomNewsSchedule,
85
+ roomTaskSchedule,
86
+ }