diff --git a/scripts/banChannel.ts b/scripts/banChannel.ts new file mode 100644 index 0000000..02fe22e --- /dev/null +++ b/scripts/banChannel.ts @@ -0,0 +1,16 @@ +import redis from '@/utils/redis' + +const [channelId] = Bun.argv.slice(2) + +if (!channelId) { + console.error('Usage: bun run scripts/banChannel.ts [channelId]') + process.exit(1) +} + +const key = 'slop:banned_channels' +const added = await redis.sadd(key, channelId) +const size = await redis.scard(key) + +console.log(`${added ? 'Banned' : 'Already banned'} channel ${channelId} (set size: ${size})`) + +await redis.quit() \ No newline at end of file diff --git a/src/utils/slop.ts b/src/utils/slop.ts index b89f9c9..1402176 100644 --- a/src/utils/slop.ts +++ b/src/utils/slop.ts @@ -1,23 +1,5 @@ import redis from '@/utils/redis'; -const channelBlacklist = [ - 'UCR7d_LMsADXorkUF5fkcEHQ', - 'UCgcX8KN9tjesfSg1KYW8JMA', - 'UCRbV62Z7jv5j9WHdjCQT4BQ', - 'UCErCs-HgXDfj_79jbWO8SqA', - 'UClt1wsBuiIJS8_RoAFlkSlQ', - 'UCviJ2KzLw4W7zRNzPv6FLbA', - 'UCUQmW2YLzhEmMTqO0RAPlOw', - 'UCtmnjVU-u1B7vX-XDhuvExA', - 'UCgcX8KN9tjesfSg1KYW8JMA', - 'UCh8VpxMSRm-JoogNpCFHbMw', - 'UCUQmW2YLzhEmMTqO0RAPlOw', - 'UC4Anp9y2TU-d5blFUf7wCqw', - 'UC-TaLb_bURExFdLFXkJ3Adg', - 'UC1XgosSxwK9xtrMLsRzCbHw', - 'UCInXezQxpWgrd7uPKeA6gPQ', -] - async function analyseSlop(id: string, title: string, description: string) { const llmResponse = await (await fetch('https://nano-gpt.com/api/v1/chat/completions', { method: 'POST', @@ -88,7 +70,8 @@ User Description: ${description.slice(0,500)}` } } async function parseSlop(id: string, title: string, description: string, channelId: string): Promise { - if (channelBlacklist.includes(channelId)) return true; + const isBanned = await redis.sismember('slop:banned_channels', channelId) + if (isBanned) return true; const cachedSlop = await redis.get(`slop:${id}`) if (cachedSlop) return cachedSlop == 'true' ? true : false @@ -100,4 +83,4 @@ async function parseSlop(id: string, title: string, description: string, channel return is_slop } -export { parseSlop } \ No newline at end of file +export { parseSlop }