Compare commits

...

2 Commits

Author SHA1 Message Date
Hri7566 411f9c3ab1 Merge branch 'main' of git.hri7566.info:Hri7566/supercosmic 2023-12-01 15:49:13 -05:00
Hri7566 f92378a26d things 2023-12-01 15:48:14 -05:00
3 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,66 @@
import { Command } from "../../Command";
import crypto from "crypto";
// Possible answers
const answers = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes, definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
`Don't count on it`,
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"
];
export const magic8ball = new Command(
"magic8ball",
["magic8ball", "8ball", "8"],
"magic8ball bozo",
"magic8ball <question>",
(msg, agent) => {
/**
* Magic 8 ball command
*
* Returns a unique answer for every question asked.
*/
// Check arguments
// We're not checking for question marks since the user might think that's too much work
if (!msg.argv[1]) return `🎱 Ask me a question, dummy`;
// Hash the question (the user will get the same response for repeated questions)
// We use a predictable but unique salt (security by obscurity?)
const hash = crypto.createHash("sha-256");
hash.update("magic" + msg.argv[1] + "8ball");
// Use the question hash as the index
const hex = hash.digest("hex");
let index = parseInt(hex[0] + hex[1] + hex[2], 16);
// Make sure the index is within the bounds of the answers array
while (index >= answers.length) {
index -= answers.length;
}
while (index <= 0) {
index += answers.length;
}
// Answer the user's question
let answer = answers[index];
return `🎱 ${answer}, ${msg.p.name}`;
}
);

View File

@ -6,11 +6,13 @@ import { id } from "./commands/utility/id";
import { msg } from "./commands/utility/msg";
import { math } from "./commands/utility/math";
import { memory } from "./commands/utility/memory";
import { magic8ball } from "./commands/fun/magic8ball";
import { cursor } from "./commands/utility/cursor";
import { inventory } from "./commands/economy/inventory";
import { color } from "./commands/utility/color";
export function loadCommands() {
// cringe
const general = new CommandGroup("general", "⭐ General");
general.addCommands([help, about]);
CommandHandler.addCommandGroup(general);
@ -19,6 +21,10 @@ export function loadCommands() {
economy.addCommands([inventory]);
CommandHandler.addCommandGroup(economy);
const fun = new CommandGroup("fun", "✨ Fun");
fun.addCommands([magic8ball]);
CommandHandler.addCommandGroup(fun);
const utility = new CommandGroup("utility", "🔨 Utility");
utility.addCommands([math, memory, id, msg, cursor, color]);
CommandHandler.addCommandGroup(utility);

View File

@ -23,6 +23,8 @@ export class SwitchChatAgent extends ServiceAgent<Client> {
this.client.defaultName = this.desiredUser.name;
this.client.defaultFormattingMode = "markdown";
console.log("SwitchChat owner only mode:", config.ownerOnly);
}
public start() {