Skip to content

Commit

Permalink
Merge pull request fuergaosi233#622 from chenzn1/feature/ingore-old-m…
Browse files Browse the repository at this point in the history
…essage

feat: ingore old messages
  • Loading branch information
fuergaosi233 authored Feb 18, 2023
2 parents 6b251ba + f00730c commit 3a1db2b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const bot = WechatyBuilder.build({
// get a Wechaty instance

async function main() {
const initializedAt = Date.now()
await chatGPTBot.startGPTBot();
bot
.on("scan", async (qrcode, status) => {
Expand All @@ -27,7 +28,10 @@ async function main() {
chatGPTBot.setBotName(user.name());
})
.on("message", async (message) => {
if (!chatGPTBot.ready) {
if (
!chatGPTBot.ready ||
message.date().getTime() < initializedAt
) {
return;
}
if (message.text().startsWith("/ping")) {
Expand Down

0 comments on commit 3a1db2b

Please sign in to comment.