added invulnerable chatters, completely reworked the way vulnerable chatters and admins is stored

This commit is contained in:
2025-07-17 22:05:56 +02:00
parent 0ebc3d7cf6
commit dcd2eda439
16 changed files with 142 additions and 23 deletions

View File

@@ -9,6 +9,6 @@ export default new Command('addadmin', ['addadmin'], 'streamer', async msg => {
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const data = await addAdmin(target.id);
if (data === 1) await sendMessage(`${target.displayName} is now an admin`, msg.messageId);
if (data === "OK") await sendMessage(`${target.displayName} is now an admin`, msg.messageId);
else await sendMessage(`${target.displayName} is already an admin`, msg.messageId);
}, false);

14
src/commands/addinvuln.ts Normal file
View File

@@ -0,0 +1,14 @@
import { Command, sendMessage } from ".";
import { addInvuln } from "../lib/invuln";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('addinvuln', ['addinvuln'], 'streamer', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const data = await addInvuln(target.id);
if (data === "OK") await sendMessage(`${target.displayName} is now an invuln`, msg.messageId);
else await sendMessage(`${target.displayName} is already an invuln`, msg.messageId);
}, false);

View File

@@ -0,0 +1,13 @@
import { Command, sendMessage } from ".";
import { getInvulns } from "../lib/invuln";
import { User } from "../user";
export default new Command('getinvulns', ['getinvulns'], 'chatter', async msg => {
const invulns = await getInvulns()
const invulnnames: string[] = [];
for (const id of invulns) {
const invuln = await User.initUserId(id);
invulnnames.push(invuln?.displayName!);
};
await sendMessage(`Current invulnerable chatters: ${invulnnames.join(', ')}`, msg.messageId);
}, false);

View File

@@ -0,0 +1,16 @@
import { Command, sendMessage } from ".";
import { streamerUsers } from "..";
import { removeInvuln } from "../lib/invuln";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('removeinvuln', ['removeinvuln'], 'streamer', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
if (streamerUsers.includes(target.id)) { await sendMessage(`Can't remove invulnerability from ${target.displayName} as they are managed by the bot program`, msg.messageId); return; };
const data = await removeInvuln(target.id);
if (data === 1) await sendMessage(`${target.displayName} is no longer invulnerable`, msg.messageId);
else await sendMessage(`${target.displayName} isn't invulnerable`, msg.messageId);
}, false);

View File

@@ -2,7 +2,7 @@ import { redis } from "bun";
import { Command, sendMessage } from ".";
export default new Command('vulnchatters', ['vulnchatters', 'vulnc'], 'chatter', async msg => {
const data = await redis.keys('vulnchatters:*');
const data = await redis.keys('user:*:vulnerable');
const one = data.length === 1;
await sendMessage(`There ${one ? 'is' : 'are'} ${data.length} vulnerable chatter${one ? '' : 's'}`, msg.messageId);
});