mirror of
https://gitlab.com/ceda_ei/Quadnite-Bot
synced 2025-11-01 01:30:05 +01:00
Compare commits
17 Commits
node_port
...
fde5830309
| Author | SHA1 | Date | |
|---|---|---|---|
| fde5830309 | |||
| 71e6f6927d | |||
| 6da0e12171 | |||
| b0eff87e72 | |||
| 9024ec65f9 | |||
| 53dda834f9 | |||
| af56ffbbb3 | |||
| 382579ba3f | |||
| 8f16112b2e | |||
| 72e69b7ac1 | |||
| 3ed015b584 | |||
| 2914321b3c | |||
| 375f032b97 | |||
| dcf77e56a3 | |||
| e4311467b3 | |||
| bd2f38679c | |||
| 59e8db799a |
4
bot.js
4
bot.js
@@ -3,8 +3,10 @@ const { BOT_API_KEY, FEEDBACK_ID } = process.env;
|
|||||||
const fs = require("fs").promises;
|
const fs = require("fs").promises;
|
||||||
const commands = require("./commands");
|
const commands = require("./commands");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
const roleplay = require("./roleplay.json");
|
||||||
|
|
||||||
const bot = new Telegraf(BOT_API_KEY);
|
const bot = new Telegraf(BOT_API_KEY);
|
||||||
|
bot.catch((err) => console.log(err));
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
"questions",
|
"questions",
|
||||||
@@ -19,6 +21,6 @@ const data = [
|
|||||||
|
|
||||||
Promise.all(data)
|
Promise.all(data)
|
||||||
.then(data =>
|
.then(data =>
|
||||||
commands(bot, data, FEEDBACK_ID, axios));
|
commands(bot, [...data, roleplay], FEEDBACK_ID, axios));
|
||||||
|
|
||||||
bot.launch();
|
bot.launch();
|
||||||
|
|||||||
48
commands/expand.js
Normal file
48
commands/expand.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
function expand(words, text) {
|
||||||
|
|
||||||
|
const letters = text.trim().toLowerCase().split("");
|
||||||
|
// Build a dictionary with lowercase letters as keys
|
||||||
|
const dict = {};
|
||||||
|
words.forEach(word => {
|
||||||
|
|
||||||
|
if (word == "")
|
||||||
|
return;
|
||||||
|
const initial = word.split("")[0].toLowerCase();
|
||||||
|
if (initial in dict)
|
||||||
|
dict[initial].push(word);
|
||||||
|
else
|
||||||
|
dict[initial] = [word];
|
||||||
|
|
||||||
|
});
|
||||||
|
return letters.map((letter) => {
|
||||||
|
|
||||||
|
if (!(letter.toLowerCase() in dict))
|
||||||
|
return letter;
|
||||||
|
const wordsWithLetter = dict[letter.toLowerCase()];
|
||||||
|
const word = wordsWithLetter[Math.floor(Math.random() * wordsWithLetter.length)];
|
||||||
|
return word;
|
||||||
|
|
||||||
|
}).reduce((acc, cur) => acc + " " + cur).replace(/\s{2,}/g, " ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = (words = []) => (ctx) => {
|
||||||
|
|
||||||
|
words = words.filter(i => ! i.match(/'s$/));
|
||||||
|
const message = ctx.message.text.replace(/^[^ ]+/, "");
|
||||||
|
if (message) {
|
||||||
|
|
||||||
|
return expand(words, message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (ctx.message.reply_to_message)
|
||||||
|
return expand(words, ctx.message.reply_to_message.text);
|
||||||
|
else
|
||||||
|
return "Need text to expand. Send /expand text or reply to a "
|
||||||
|
+ "message with /expand";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@@ -7,9 +7,10 @@ const absurdify = require("./absurdify");
|
|||||||
const feedback = require("./feedback");
|
const feedback = require("./feedback");
|
||||||
const media_wiki = require("./media_wiki");
|
const media_wiki = require("./media_wiki");
|
||||||
const info = require("./info");
|
const info = require("./info");
|
||||||
|
const expand = require("./expand");
|
||||||
|
const roleplay = require("./roleplay");
|
||||||
|
|
||||||
module.exports = (bot, [ questions, kys, insults, commands_list, words ],
|
module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay_data ], feedback_id, axios) => {
|
||||||
feedback_id, axios) => {
|
|
||||||
|
|
||||||
bot.command("question", (ctx) => ctx.reply(random(questions)()));
|
bot.command("question", (ctx) => ctx.reply(random(questions)()));
|
||||||
bot.command("word", (ctx) => ctx.reply(random(words)()));
|
bot.command("word", (ctx) => ctx.reply(random(words)()));
|
||||||
@@ -32,7 +33,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ],
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.command("commands", (ctx) => ctx.reply(commands_list.join("\n")));
|
bot.command("commands", (ctx) => ctx.reply(commands_list.join("\n"), {parse_mode: "html"}));
|
||||||
bot.command("is", (ctx) => ctx.reply(is(random)(ctx)));
|
bot.command("is", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
bot.command("are", (ctx) => ctx.reply(is(random)(ctx)));
|
bot.command("are", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
bot.command("can", (ctx) => ctx.reply(is(random)(ctx)));
|
bot.command("can", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
@@ -60,5 +61,13 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ],
|
|||||||
"https://wiki.archlinux.org/api.php")(ctx).then(x => ctx.reply(x,
|
"https://wiki.archlinux.org/api.php")(ctx).then(x => ctx.reply(x,
|
||||||
{parse_mode: "HTML"})));
|
{parse_mode: "HTML"})));
|
||||||
bot.command("info", (ctx) => ctx.reply(info()(ctx), {parse_mode: "Markdown"}));
|
bot.command("info", (ctx) => ctx.reply(info()(ctx), {parse_mode: "Markdown"}));
|
||||||
|
bot.command("expand", (ctx) => ctx.reply(expand(words)(ctx)));
|
||||||
|
bot.command("start", (ctx) => ctx.reply("Hi, I am Quadnite. If you are "
|
||||||
|
+ "chatting with me in private, you are most likely doing it wrong. "
|
||||||
|
+ "Add me to a group for fun. To give feedback, use /feedback"));
|
||||||
|
|
||||||
|
// Add all roleplay commands
|
||||||
|
Object.keys(roleplay_data).map(command =>
|
||||||
|
bot.command(command, ctx => roleplay(roleplay_data[command].forms, roleplay_data[command].gifs)(ctx)));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module.exports = () => (ctx) => {
|
|||||||
text += "Channel ID: ";
|
text += "Channel ID: ";
|
||||||
text += `\`${forward.id}\`\n`;
|
text += `\`${forward.id}\`\n`;
|
||||||
text += "Message Date: `";
|
text += "Message Date: `";
|
||||||
const date = new Date(reply.forward_date);
|
const date = new Date(reply.forward_date*1000);
|
||||||
text += date.toUTCString();
|
text += date.toUTCString();
|
||||||
text += "`";
|
text += "`";
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module.exports = (random, kys, default_text, bot_text, excluded_names) => (ctx)
|
|||||||
if (ctx.message.reply_to_message) {
|
if (ctx.message.reply_to_message) {
|
||||||
|
|
||||||
const { from } = ctx.message.reply_to_message;
|
const { from } = ctx.message.reply_to_message;
|
||||||
const name = from.username ? "@" + from.username : from.firstName;
|
const name = from.username ? "@" + from.username : from.first_name;
|
||||||
if (name == excluded_names[0])
|
if (name == excluded_names[0])
|
||||||
return bot_text;
|
return bot_text;
|
||||||
return random(kys)().replace(/##name##/g, name);
|
return random(kys)().replace(/##name##/g, name);
|
||||||
@@ -13,7 +13,7 @@ module.exports = (random, kys, default_text, bot_text, excluded_names) => (ctx)
|
|||||||
const text_array = ctx.message.text.split(" ");
|
const text_array = ctx.message.text.split(" ");
|
||||||
if (text_array.length > 1) {
|
if (text_array.length > 1) {
|
||||||
|
|
||||||
const name = text_array[1];
|
const name = text_array.slice(1).reduce((i, j) => i + " " + j).trim();
|
||||||
if (excluded_names.includes(name)
|
if (excluded_names.includes(name)
|
||||||
|| excluded_names.includes("@" + name))
|
|| excluded_names.includes("@" + name))
|
||||||
return bot_text;
|
return bot_text;
|
||||||
|
|||||||
40
commands/roleplay.js
Normal file
40
commands/roleplay.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
function joinUsers(users) {
|
||||||
|
|
||||||
|
if (users.length == 1)
|
||||||
|
return users[0];
|
||||||
|
return users.slice(0, users.length - 1).join(", ")
|
||||||
|
+ ` and ${users[users.length - 1]}`;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = (forms, gifs) => (ctx) => {
|
||||||
|
|
||||||
|
const gif = gifs[Math.floor(Math.random() * gifs.length)];
|
||||||
|
const message = ctx.message.text.replace(/^[^ ]+\s*/, "")
|
||||||
|
.match(/^((@\w+(\s+|$))*)(.*)/);
|
||||||
|
const users = message[1].trim().split(" ").filter(i => i.length);
|
||||||
|
const reason = message[4];
|
||||||
|
let reply = "";
|
||||||
|
const from = ctx.message.from;
|
||||||
|
const user = from.username ? "@" + from.username : from.first_name;
|
||||||
|
if (users.length > 0 && reason.length > 0)
|
||||||
|
reply = forms.both
|
||||||
|
.replace("{}", user)
|
||||||
|
.replace("{}", joinUsers(users))
|
||||||
|
.replace("{}", reason);
|
||||||
|
else if (users.length > 0)
|
||||||
|
reply = forms.others
|
||||||
|
.replace("{}", user)
|
||||||
|
.replace("{}", joinUsers(users));
|
||||||
|
else if (reason.length > 0)
|
||||||
|
reply = forms.reason
|
||||||
|
.replace("{}", user)
|
||||||
|
.replace("{}", reason);
|
||||||
|
else
|
||||||
|
reply = forms.none
|
||||||
|
.replace("{}", user);
|
||||||
|
|
||||||
|
ctx.replyWithAnimation(gif, {caption: reply});
|
||||||
|
|
||||||
|
};
|
||||||
@@ -1,23 +1,61 @@
|
|||||||
question - Get a random question
|
<b>Random</b>
|
||||||
word - Get a random word
|
|
||||||
words - Get n random words
|
|
||||||
kys - Kill yourself
|
|
||||||
coin - Tosses a coin
|
coin - Tosses a coin
|
||||||
wiki - Search Wikipedia
|
wiki - Search Wikipedia
|
||||||
arch_wiki - Search the Arch wiki
|
arch_wiki - Search the Arch wiki
|
||||||
|
kys - Kill yourself
|
||||||
insult - As expected, insults
|
insult - As expected, insults
|
||||||
|
|
||||||
|
<b>Wordplay</b>
|
||||||
|
|
||||||
|
question - Get a random question
|
||||||
|
word - Get a random word
|
||||||
|
words - Get n random words
|
||||||
weebify - Weebifies the given text
|
weebify - Weebifies the given text
|
||||||
absurdify - mAke tExT aBSUrd
|
absurdify - mAke tExT aBSUrd
|
||||||
is - Is <your question>
|
expand - Expands a given abbreviation
|
||||||
are - Are <your question>
|
|
||||||
can - Can <your question>
|
<b>Ask a question</b>
|
||||||
will - will <your question>
|
<code>
|
||||||
shall - shall <your question>
|
is are can
|
||||||
was - Was <your question>
|
will did shall
|
||||||
do - Do <your question>
|
was do does
|
||||||
does - Does <your question>
|
should
|
||||||
did - Did <your question>
|
</code>
|
||||||
should - Should <your question>
|
<b>Roleplay</b>
|
||||||
|
<code>
|
||||||
|
angry bite
|
||||||
|
blush bored
|
||||||
|
bonk boop
|
||||||
|
chase cheer
|
||||||
|
cringe cry
|
||||||
|
cuddle dab
|
||||||
|
dance die
|
||||||
|
eat facepalm
|
||||||
|
feed glomp
|
||||||
|
happy hate
|
||||||
|
holdhands hide
|
||||||
|
highfive hug
|
||||||
|
kill kiss
|
||||||
|
laugh lick
|
||||||
|
love lurk
|
||||||
|
nervous no
|
||||||
|
nom nuzzle
|
||||||
|
panic pat
|
||||||
|
peck poke
|
||||||
|
pout run
|
||||||
|
shoot shrug
|
||||||
|
sip slap
|
||||||
|
sleep snuggle
|
||||||
|
stab tease
|
||||||
|
think thumbsup
|
||||||
|
tickle triggered
|
||||||
|
twerk wag
|
||||||
|
wave wink
|
||||||
|
yes
|
||||||
|
</code>
|
||||||
|
<b>Miscallenous</b>
|
||||||
|
|
||||||
help - Need help? Go here
|
help - Need help? Go here
|
||||||
feedback - Send feedback, suggestion for kys, insult text
|
feedback - Send feedback, suggestion for kys, insult text
|
||||||
rate - Rate me on TGDR
|
rate - Rate me on TGDR
|
||||||
|
|||||||
17
insults.txt
17
insults.txt
@@ -67,3 +67,20 @@ Everyone has the right to be stupid but ##name## is abusing the privilege.
|
|||||||
##name## I’d tell you how I really feel, but I wasn’t born with enough middle fingers to express myself in this case.
|
##name## I’d tell you how I really feel, but I wasn’t born with enough middle fingers to express myself in this case.
|
||||||
##name## Stupidity’s not a crime, so feel free to go.
|
##name## Stupidity’s not a crime, so feel free to go.
|
||||||
##name## I’d tell you to go fuck yourself, but that would be cruel and unusual punishment.
|
##name## I’d tell you to go fuck yourself, but that would be cruel and unusual punishment.
|
||||||
|
I've finally found how ##name## is related to their pants, they're both full of shit.
|
||||||
|
There has been a rumor going around about ##name## acting like a dumbass. They're not acting.
|
||||||
|
##name## calling you an idiot would be an insult to stupid people.
|
||||||
|
##name## you know how laughter is supposed to be the best medicine? I'm surprised you haven't received an award for your face.
|
||||||
|
##name## you're the reason why shampoo bottles need directions.
|
||||||
|
They say trash takes 10-1000 years to go away, I sure hope you're going for a speedrun ##name##.
|
||||||
|
##name## makes me wish I had less eyes and ears.
|
||||||
|
##name## if you ran as much as your mouth maybe people would actually like you.
|
||||||
|
##name## mother nature takes pity on you.
|
||||||
|
If I had a face like ##name##'s I would file a lawsuit against my parents.
|
||||||
|
##name## I'm glad to see you finally graduated kindergarten.....oh no, I'm sorry I thought-
|
||||||
|
It makes me really sad to see how much time it takes ##name## to get ready in the morning, not that it makes much of a difference.
|
||||||
|
##name## I would try to insult you but it would take you the rest of the day to figure it out.
|
||||||
|
##name## I'm surprised your portraits don't hang themselves.
|
||||||
|
Many people think ##name## is a vampire because their reflection quit on the first day.
|
||||||
|
##name## you make satan consider going to church.
|
||||||
|
When god said 'Let there be light' he should have reconsidered after meeting ##name##.
|
||||||
|
|||||||
2
kys.txt
2
kys.txt
@@ -26,7 +26,7 @@
|
|||||||
##name## You should try playing snake and ladders, with real snakes and no ladders.
|
##name## You should try playing snake and ladders, with real snakes and no ladders.
|
||||||
##name## Dance naked on a couple of HT wires.
|
##name## Dance naked on a couple of HT wires.
|
||||||
##name## An active volcano is the best swimming pool for you.
|
##name## An active volcano is the best swimming pool for you.
|
||||||
##name## You shoulf try hot bath in a volcano.
|
##name## You should try hot bath in a volcano.
|
||||||
##name## Try to spend one day in a coffin and it will be yours forever.
|
##name## Try to spend one day in a coffin and it will be yours forever.
|
||||||
##name## Hit Uranium with a slow moving neutron in your presence. It will be a worthwhile experience.
|
##name## Hit Uranium with a slow moving neutron in your presence. It will be a worthwhile experience.
|
||||||
##name## You can be the first person to step on the sun. Have a try.
|
##name## You can be the first person to step on the sun. Have a try.
|
||||||
|
|||||||
81
package-lock.json
generated
Normal file
81
package-lock.json
generated
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"name": "quadnite-bot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": {
|
||||||
|
"version": "10.12.26",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.26.tgz",
|
||||||
|
"integrity": "sha512-nMRqS+mL1TOnIJrL6LKJcNZPB8V3eTfRo9FQA2b5gDvrHurC8XbSA86KNe0dShlEL7ReWJv/OU9NL7Z0dnqWTg=="
|
||||||
|
},
|
||||||
|
"axios": {
|
||||||
|
"version": "0.18.0",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "^1.3.0",
|
||||||
|
"is-buffer": "^1.1.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "3.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||||
|
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"follow-redirects": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==",
|
||||||
|
"requires": {
|
||||||
|
"debug": "^3.2.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-buffer": {
|
||||||
|
"version": "1.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||||
|
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
|
||||||
|
},
|
||||||
|
"node-fetch": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA=="
|
||||||
|
},
|
||||||
|
"sandwich-stream": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ=="
|
||||||
|
},
|
||||||
|
"telegraf": {
|
||||||
|
"version": "3.27.1",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "^10.1.2",
|
||||||
|
"debug": "^4.0.1",
|
||||||
|
"node-fetch": "^2.2.0",
|
||||||
|
"sandwich-stream": "^2.0.1",
|
||||||
|
"telegram-typings": "^3.6.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"debug": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||||
|
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"telegram-typings": {
|
||||||
|
"version": "3.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/telegram-typings/-/telegram-typings-3.6.1.tgz",
|
||||||
|
"integrity": "sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
name?
|
|
||||||
How old are you?
|
How old are you?
|
||||||
Whats your Birthday?
|
Whats your Birthday?
|
||||||
What starsign does that make it?
|
What starsign does that make it?
|
||||||
@@ -1755,4 +1754,3 @@ How do you memorize your numbers?
|
|||||||
Have you ever been stuck in a bad situation but had no phone?
|
Have you ever been stuck in a bad situation but had no phone?
|
||||||
How many signal bars do you usually get in your room?
|
How many signal bars do you usually get in your room?
|
||||||
What service provider do you think is the best and why so?
|
What service provider do you think is the best and why so?
|
||||||
|
|
||||||
|
|||||||
1150
roleplay.json
Normal file
1150
roleplay.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user