Skip to content

Commit

Permalink
IP message content Filter by AADI0009
Browse files Browse the repository at this point in the history
This function will allow users to enable a filter of ip adresses. Like that every message which has a IP in their content will be removed!
  • Loading branch information
Scraayp authored Jul 27, 2023
2 parents 69eda14 + 2f87d10 commit 090f896
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const antiSpam = new AntiSpam({
unMuteTime: 60, // Time in minutes before the user will be able to send messages again.
verbose: true, // Whether or not to log every action in the console.
removeMessages: true, // Whether or not to remove all messages sent by the user.
ipwarnEnabled: false, //whether to delete ip addresses in channels or not.
ignoredPermissions: [PermissionFlagsBits.Administrator], // If the user has the following permissions, ignore him.
// For more options, see the documentation:
});
Expand Down
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const { EventEmitter } = require("events");
* @property {boolean} [kickEnabled=true] Whether kick sanction is enabled.
* @property {boolean} [muteEnabled=true] Whether mute sanction is enabled.
* @property {boolean} [banEnabled=true] Whether ban sanction is enabled.
* @property {boolean} [ipwarnEnabled=false] Whether warn sanction is enabled.
*
* @property {number} [deleteMessagesAfterBanForPastDays=1] When a user is banned, their messages sent in the last x days will be deleted.
* @property {boolean} [verbose=true] Extended logs from module (recommended).
Expand Down Expand Up @@ -245,6 +246,8 @@ class AntiSpamClient extends EventEmitter {

warnEnabled:
options.warnEnabled != undefined ? options.warnEnabled : true,
ipwarnEnabled:
options.ipwarnEnabled != undefined ? options.ipwarnEnabled : false,
kickEnabled:
options.kickEnabled != undefined ? options.kickEnabled : true,
muteEnabled:
Expand Down Expand Up @@ -785,6 +788,16 @@ class AntiSpamClient extends EventEmitter {
m.sentTimestamp >
currentMessage.sentTimestamp - options.maxDuplicatesInterval
);
if (this.options.ipwarnEnabled == true) {
let regex = /([0-9]{1,3}\.){3}[0-9]{1,3}/;
if (message.content.match(regex)) {
message.delete();
message.channel.send(`${message.author} Don't post IP's in chat!`);
};
} else {
return;
};


/**
* Duplicate messages sent before the threshold is triggered
Expand Down

0 comments on commit 090f896

Please sign in to comment.