From 842ad55d61cf3541c182ddd60e6bec6405c0278e Mon Sep 17 00:00:00 2001 From: Lea Date: Wed, 8 Nov 2023 20:32:05 +0100 Subject: [PATCH] add trolling --- src/index.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/index.ts b/src/index.ts index 2c80a6e..b8fec00 100644 --- a/src/index.ts +++ b/src/index.ts @@ -273,6 +273,8 @@ client.on('message', async (message) => { } catch(e) { await message.reply('nuh uh'); } + } else { + await wordFilters(message); } return; } @@ -539,6 +541,26 @@ client.on('message', async (message) => { } }); +async function wordFilters(message: Message) { + try { + const RE_POKETUBE_VIDEO = /https?:\/\/(poketube.fun|poketube.sudovanilla.com)\/watch\?([^\s\/]+&)?v=(?[^\s\/?&]{1,16})(&\S*)?/gi; + const results: string[] = []; + + if (!message.content) return; + + for (const result of message.content.matchAll(RE_POKETUBE_VIDEO)) { + var id = result.groups?.videoid; + if (id) results.push(`https://youtu.be/${id}`); + } + + if (results.length) { + await message.reply(results.join('\n')); + } + } catch(e) { + console.error(e); + } +} + client.on('member/join', async (member) => { const GAMER_WORDS = /nigg{er,a}|hitt?ler|trann(y|ie)|troon|faggot/i; const CHILD_WORDS = /roblox|fran(รง|c)ais/i;