fix(spam): count duplicate mentions; only clean offending messages
This commit is contained in:
parent
e8c021eea6
commit
847ee11195
2 changed files with 64 additions and 16 deletions
src
30
src/utils.ts
30
src/utils.ts
|
@ -238,3 +238,33 @@ export function trimLines(str: string) {
|
|||
|
||||
export const emptyEmbedValue = "\u200b";
|
||||
export const embedPadding = "\n" + emptyEmbedValue;
|
||||
|
||||
export const userMentionRegex = /<@!?([0-9]+)>/g;
|
||||
export const roleMentionRegex = /<&([0-9]+)>/g;
|
||||
|
||||
export function getUserMentions(str: string) {
|
||||
const regex = new RegExp(userMentionRegex.source, "g");
|
||||
const userIds = [];
|
||||
let match;
|
||||
|
||||
// tslint:disable-next-line
|
||||
while ((match = regex.exec(str)) !== null) {
|
||||
console.log("m", match);
|
||||
userIds.push(match[1]);
|
||||
}
|
||||
|
||||
return userIds;
|
||||
}
|
||||
|
||||
export function getRoleMentions(str: string) {
|
||||
const regex = new RegExp(roleMentionRegex.source, "g");
|
||||
const roleIds = [];
|
||||
let match;
|
||||
|
||||
// tslint:disable-next-line
|
||||
while ((match = regex.exec(str)) !== null) {
|
||||
roleIds.push(match[1]);
|
||||
}
|
||||
|
||||
return roleIds;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue