add bot detection

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-14 00:41:47 +01:00
parent 1d3d688901
commit 176ddc410b
4 changed files with 4935 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
import bots from './bots';
export function isBot(ua: string) {
const res = bots.find((bot) => {
if (new RegExp(bot.regex).test(ua)) {
return true;
}
return false;
});
if (!res) {
return null;
}
return {
name: res.name,
type: res.category,
};
}