allow mentioning users instead of using userids

This commit is contained in:
2025-04-10 14:52:22 -04:00
parent 38147c46a2
commit c16e55d56c
4 changed files with 44 additions and 8 deletions

27
utils/userUtils.js Normal file
View File

@@ -0,0 +1,27 @@
function extractUserId(input) {
if (/^\d{17,19}$/.test(input)) {
return input;
}
const mentionRegex = /<@!?(\d{17,19})>/;
const match = input.match(mentionRegex);
if (match && match[1]) {
return match[1];
}
return null;
}
function processUserInput(input) {
return input
.split(',')
.map(part => part.trim())
.map(part => extractUserId(part))
.filter(id => id !== null);
}
module.exports = {
extractUserId,
processUserInput
};