mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
added invulnerable chatters, completely reworked the way vulnerable chatters and admins is stored
This commit is contained in:
@@ -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
14
src/commands/addinvuln.ts
Normal 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);
|
||||
13
src/commands/getinvulns.ts
Normal file
13
src/commands/getinvulns.ts
Normal 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);
|
||||
16
src/commands/removeinvuln.ts
Normal file
16
src/commands/removeinvuln.ts
Normal 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);
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user