-
Notifications
You must be signed in to change notification settings - Fork 19
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
1 parent
5706b29
commit d542742
Showing
16 changed files
with
224 additions
and
78 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,3 @@ | ||
{ | ||
"a": 4 | ||
} |
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
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,32 @@ | ||
import { Wechaty } from 'wechaty' | ||
import { PuppetPadplus } from 'wechaty-puppet-padplus' | ||
import Qrterminal from 'qrcode-terminal' | ||
|
||
import * as message from './event/message' | ||
import * as friendShip from './event/friend-ship' | ||
import * as roomJoin from './event/room-join' | ||
|
||
import { schedule } from './schedule' | ||
|
||
const bot = new Wechaty({ | ||
puppet: new PuppetPadplus(), | ||
name: 'daxiange' | ||
}) | ||
|
||
function handleScan (qrcode: string) { | ||
Qrterminal.generate(qrcode, { small: true }) | ||
} | ||
|
||
bot | ||
.on('scan', handleScan) | ||
.on('room-join', roomJoin.handleRoomJoin) | ||
.on('friendship', friendShip.handleFriendShip) | ||
.on('message', message.handleMessage) | ||
.start() | ||
|
||
// 需要保证 bot start 之后调用 | ||
// 然而 bot.start().then() 无法触达,只好使用这种笨办法 | ||
setTimeout(() => { | ||
schedule(bot) | ||
}, 3000) | ||
|
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 @@ | ||
import { Wechaty } from 'wechaty' | ||
|
||
import inteviewBot from './interview' | ||
|
||
export async function schedule (bot: Wechaty) { | ||
await inteviewBot(bot) | ||
} |
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,15 @@ | ||
import { Wechaty } from 'wechaty' | ||
import { CronJob } from 'cron' | ||
import { randomQuestion } from '../message/interview' | ||
|
||
// 找到前端面试,及前端进阶开头的群名,每天 9:45 定时推送 | ||
export default async (bot: Wechaty) => { | ||
return new CronJob('45 9 * * *', async () => { | ||
const rooms = await bot.Room.findAll({ topic: /前端面试|前端进阶/ }) | ||
const q = await randomQuestion() | ||
for (const room of rooms) { | ||
// const alias = await room. | ||
await room.say(q) | ||
} | ||
}, null, true, 'Asia/Shanghai') | ||
} |
Oops, something went wrong.