-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# FCC Panky | ||
|
||
FCC 成都社区的微信群管理机器人,源自[【微信机器人工作坊】][1] | ||
|
||
## 核心功能 | ||
|
||
1. 入群提醒 | ||
2. 自动回复 | ||
- 官网链接 | ||
|
||
## 本地运行 | ||
|
||
```shell | ||
git clone https://github.com/FreeCodeCamp-Chengdu/wechat-robot.git ~/Desktop/FCC-Panky | ||
cd ~/Desktop/FCC-Panky | ||
|
||
npm set puppeteer_download_host https://storage.googleapis.com.cnpmjs.org | ||
npm install | ||
npm start | ||
``` | ||
|
||
[1]: https://fcc-cd.tk/activity/workshop/wechat-robot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@fcc-cdc/wechat-robot", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "WeChat group administrator of FCC ChengDu community", | ||
"license": "AGPL-3.0", | ||
"author": "[email protected]", | ||
|
@@ -12,16 +12,19 @@ | |
"bugs": { | ||
"url": "https://github.com/FreeCodeCamp-Chengdu/wechat-robot/issues" | ||
}, | ||
"main": "index.js", | ||
"main": "source/index.js", | ||
"scripts": { | ||
"format": "prettier --write \"{,!(node_modules|.git)/**/}*.{html,md,css,less,js,json,yml,yaml}\"", | ||
"start": "node index" | ||
"start": "node source/" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run format && git add ." | ||
} | ||
}, | ||
"engines": { | ||
"node": "^7.6.0" | ||
}, | ||
"dependencies": { | ||
"puppeteer": "^1.17.0", | ||
"qrcode-terminal": "^0.12.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
exports.roomJoin = function(room, list, guy) { | ||
room.say(`欢迎喜爱编程的小伙伴入群: | ||
${list.map((guy, index) => ` ${++index}. ${guy.name()}`)} | ||
const roomList = require('./room.json'), | ||
replyMap = require('./reply.json'); | ||
|
||
exports.roomJoin = async (room, list, guy) => { | ||
const topic = await room.topic(), | ||
name = guy.name(); | ||
|
||
list = list.map(guy => guy.name()); | ||
|
||
console.log(`【加群】${topic} 的 ${name} 邀请了 ${list}`); | ||
|
||
return room.say(`欢迎喜爱编程的小伙伴入群: | ||
${list.map((name, index) => ` ${++index}. ${name}`)} | ||
请新人按照“昵称 - 技术栈”的格式修改自己的群名,并仔细阅读群公告中的【FCC 社区行为准则】: | ||
https://fcc-cd.tk/profile/code-of-conduct/ | ||
若以上新人有因违反【行为准则】而被踢,邀请人 ${guy.name()} 也将负连带责任,被一起踢出本群。`); | ||
若以上新人有因违反【行为准则】而被踢,邀请人 ${name} 也将负连带责任,被一起踢出本群。`); | ||
}; | ||
|
||
exports.message = async message => { | ||
const room = message.room(), | ||
text = message.text(); | ||
|
||
if (!room || !roomList.includes(await room.topic())) return; | ||
|
||
for (let pattern in replyMap) | ||
if (text.match(new RegExp(pattern, 'i'))) { | ||
console.log(`【回复】 | ||
${text} | ||
=> | ||
${replyMap[pattern]}`); | ||
|
||
return message.say(replyMap[pattern]); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"(FCC|freeCodeCamp)\\s*成都.*官?方?网站?": "https://fcc-cd.tk/", | ||
"(FCC|freeCodeCamp)\\s*中(文|国).*官?方?网站?": "https://freecodecamp.one/", | ||
"(FCC|freeCodeCamp)\\s*(国际|全球).*官?方?网站?": "https://freecodecamp.org/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
"FCC成都社区 - 1群", | ||
"FCC成都社区 - 2群", | ||
"FCC成都社区 - 3群", | ||
"FCC成都社区 - 4群", | ||
"微信机器人测试" | ||
] |