things
This commit is contained in:
parent
45693903dc
commit
f92378a26d
|
@ -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}`;
|
||||
}
|
||||
);
|
|
@ -6,12 +6,18 @@ 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";
|
||||
|
||||
export function loadCommands() {
|
||||
// cringe
|
||||
const general = new CommandGroup("general", "⭐ General");
|
||||
general.addCommands([help, about]);
|
||||
CommandHandler.addCommandGroup(general);
|
||||
|
||||
const fun = new CommandGroup("fun", "✨ Fun");
|
||||
fun.addCommands([magic8ball]);
|
||||
CommandHandler.addCommandGroup(fun);
|
||||
|
||||
const utility = new CommandGroup("utility", "🔨 Utility");
|
||||
utility.addCommands([math, memory, id, msg]);
|
||||
CommandHandler.addCommandGroup(utility);
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue