-
Notifications
You must be signed in to change notification settings - Fork 50
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
0c29f9f
commit 2648f3a
Showing
5 changed files
with
109 additions
and
8 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
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,12 @@ | ||
module.exports = { | ||
account: { | ||
|
||
}, | ||
group: { | ||
prefix: "/", | ||
blockTime: 0 | ||
}, | ||
member: { | ||
|
||
} | ||
}; |
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,47 @@ | ||
const { constrain } = kb2abot.utils; | ||
|
||
module.exports = { | ||
authorDetails: { | ||
name: "khoakomlem", | ||
contact: "fb.com/khoakomlem" | ||
}, | ||
|
||
friendlyName: "Kiểm tra spam", | ||
|
||
keywords: ["spamdetect"], | ||
|
||
description: "Block những group đang spam tin nhắn tới bot", | ||
|
||
extendedDescription: "", | ||
|
||
hideFromHelp: true, | ||
|
||
disable: false, | ||
|
||
onLoad: async function() { | ||
}, | ||
|
||
onMessage: async function(api, message) { | ||
if (message.body.indexOf(this.group.storage.prefix) != 0) | ||
return; | ||
if (!this.groupStorage.spamScore) | ||
this.groupStorage.spamScore = 0; | ||
if (!this.groupStorage.lastMessage) | ||
this.groupStorage.lastMessage = 0; | ||
const diff = Date.now() - this.groupStorage.lastMessage; | ||
if (diff <= 1500) | ||
this.groupStorage.spamScore += (2000 - diff)/1000; | ||
else | ||
this.groupStorage.spamScore -= (diff - 800)/1000; | ||
this.groupStorage.spamScore = constrain(this.groupStorage.spamScore, 0, 10); | ||
if (this.groupStorage.spamScore >= 10) { | ||
api.sendMessage("Too frequent! Blocking group for 5 mins...", message.threadID); | ||
this.group.storage.blockTime = Date.now() + 1000 * 60 * 5; | ||
this.groupStorage.spamScore = 0; | ||
} | ||
this.groupStorage.lastMessage = Date.now(); | ||
}, | ||
|
||
onCall: async function(api, message) { | ||
} | ||
}; |
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