Compare commits
9 Commits
6c8bb4000b
...
54f1e9a73b
Author | SHA1 | Date |
---|---|---|
Ceda EI | 54f1e9a73b | |
Ceda EI | 3b945e17f3 | |
Ceda EI | 56999fd89d | |
Ceda EI | 4d2b2eb650 | |
Ceda EI | 1f6fc86faa | |
Ceda EI | b6edbb8b3b | |
Ceda EI | 71809ed109 | |
Ceda EI | 2b6837adb5 | |
Ceda EI | 2d7dc0ca02 |
4
bot.js
4
bot.js
|
@ -9,7 +9,8 @@ const data = [
|
||||||
"questions",
|
"questions",
|
||||||
"kys",
|
"kys",
|
||||||
"insults",
|
"insults",
|
||||||
"commands_list"
|
"commands_list",
|
||||||
|
"words"
|
||||||
].map(file =>
|
].map(file =>
|
||||||
fs.readFile(file + ".txt", "utf-8")
|
fs.readFile(file + ".txt", "utf-8")
|
||||||
.then(list =>
|
.then(list =>
|
||||||
|
@ -19,3 +20,4 @@ Promise.all(data)
|
||||||
.then(data =>
|
.then(data =>
|
||||||
commands(bot, data));
|
commands(bot, data));
|
||||||
|
|
||||||
|
bot.launch();
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
function absurdify(text) {
|
||||||
|
|
||||||
|
const text_array = text.split("");
|
||||||
|
return text_array.map((character) =>
|
||||||
|
Math.random() > 0.5 ? character.toLowerCase(): character.toUpperCase())
|
||||||
|
.join("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = () => (ctx) => {
|
||||||
|
|
||||||
|
const message = ctx.message.text.replace(/^[^ ]+/, "");
|
||||||
|
if (message) {
|
||||||
|
|
||||||
|
return absurdify(message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (ctx.message.reply_to_message)
|
||||||
|
return absurdify(ctx.message.reply_to_message.text);
|
||||||
|
else
|
||||||
|
return "Need text to absurdify. Send /absurdify text or reply to a"
|
||||||
|
+ "message with /absurdify";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,51 @@
|
||||||
|
const random = require("./random");
|
||||||
|
const insults_fun = require("./insult");
|
||||||
|
const words_fun = require("./words");
|
||||||
|
const is = require("./is");
|
||||||
|
const weebify = require("./weebify");
|
||||||
|
const absurdify = require("./absurdify");
|
||||||
|
module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => {
|
||||||
|
|
||||||
|
bot.command("question", (ctx) => ctx.reply(random(questions)()));
|
||||||
|
bot.command("word", (ctx) => ctx.reply(random(words)()));
|
||||||
|
bot.command("words", (ctx) => ctx.reply(words_fun(random, words)(ctx)));
|
||||||
|
bot.telegram.getMe()
|
||||||
|
.then(bot_user => {
|
||||||
|
|
||||||
|
const default_text = (command, text) => `Do you want to ${text} `
|
||||||
|
+ `yourself?\nIf no, reply to someone with /${command} to kill`
|
||||||
|
+ ` them or run /${command} username/name.\nYou can suggest `
|
||||||
|
+ `more /${command} replies using /feedback`;
|
||||||
|
|
||||||
|
bot.command("insult", (ctx) => ctx.reply(insults_fun(random,
|
||||||
|
insults, default_text("insult", "insult"), "Watch who you talk"
|
||||||
|
+ " to.", ["@" + bot_user.username, bot_user.firstName])(ctx)));
|
||||||
|
|
||||||
|
bot.command("kys", (ctx) => ctx.reply(insults_fun(random, kys,
|
||||||
|
default_text("kys", "kill"), "I can't be killed.",
|
||||||
|
["@" + bot_user.username, bot_user.firstName])(ctx)));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.command("commands", (ctx) => ctx.reply(commands_list.join("\n")));
|
||||||
|
bot.command("is", (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("will", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("shall", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("was", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("do", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("does", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("did", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("should", (ctx) => ctx.reply(is(random)(ctx)));
|
||||||
|
bot.command("coin", (ctx) => ctx.reply(random(["Heads", "Tails"])()));
|
||||||
|
bot.command("help", (ctx) => ctx.reply("You can either check /commands "
|
||||||
|
+ "for a short overview or check the [Help Page]"
|
||||||
|
+ "(https://t.me/quadnite/9).", {parse_mode: "Markdown"}));
|
||||||
|
bot.command("rate", (ctx) => ctx.reply("[Vote for me on Telegram "
|
||||||
|
+ "Directory!](https://t.me/tgdrbot?start=quadnite_bot)", {parse_mode:
|
||||||
|
"Markdown"}));
|
||||||
|
bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx)));
|
||||||
|
bot.command("absurdify", (ctx) => ctx.reply(absurdify()(ctx)));
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
module.exports = (random, kys, default_text, bot_text, excluded_names) => (ctx) => {
|
||||||
|
|
||||||
|
if (ctx.message.reply_to_message) {
|
||||||
|
|
||||||
|
const { from } = ctx.message.reply_to_message;
|
||||||
|
const name = from.username ? "@" + from.username : from.firstName;
|
||||||
|
if (name == excluded_names[0])
|
||||||
|
return bot_text;
|
||||||
|
return random(kys)().replace(/##name##/g, name);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const text_array = ctx.message.text.split(" ");
|
||||||
|
if (text_array.length > 1) {
|
||||||
|
|
||||||
|
const name = text_array[1];
|
||||||
|
if (excluded_names.includes(name)
|
||||||
|
|| excluded_names.includes("@" + name))
|
||||||
|
return bot_text;
|
||||||
|
|
||||||
|
return random(kys)().replace(/##name##/g, name);
|
||||||
|
|
||||||
|
} else
|
||||||
|
return default_text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,12 @@
|
||||||
|
module.exports = (random) => (ctx) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
const text_array = ctx.message.text.split(" ");
|
||||||
|
if (text_array.length == 1)
|
||||||
|
return "You know, you also have to ask the question.";
|
||||||
|
|
||||||
|
return random([["Yes", "Yep", "Yeah", "Yus", "Ja", "Ya", "Aye", "Ay", "Oui"],
|
||||||
|
["No", "Nopes", "Nu", "Nah", "Nein", "Naw", "Nay", "Yesn't"]][Math.round(
|
||||||
|
Math.random())])();
|
||||||
|
|
||||||
|
};
|
|
@ -1,2 +1,5 @@
|
||||||
module.exports = (list = []) => (n = 1) =>
|
module.exports = (list = []) => (n = 1) =>
|
||||||
Array(n).fill(0).map(list[Math.floor(Math.random() * list.length)]);
|
Array(n)
|
||||||
|
.fill(0)
|
||||||
|
.map(() => list[Math.floor(Math.random() * list.length)])
|
||||||
|
.join("\n");
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
function weebify(text) {
|
||||||
|
|
||||||
|
const dict = {
|
||||||
|
a : "卂",
|
||||||
|
b : "乃",
|
||||||
|
c : "匚",
|
||||||
|
d : "刀",
|
||||||
|
e : "乇",
|
||||||
|
f : "下",
|
||||||
|
g : "厶",
|
||||||
|
h : "卄",
|
||||||
|
i : "工",
|
||||||
|
j : "丁",
|
||||||
|
k : "长",
|
||||||
|
l : "乚",
|
||||||
|
m : "从",
|
||||||
|
n : "𠘨",
|
||||||
|
o : "口",
|
||||||
|
p : "尸",
|
||||||
|
q : "㔿",
|
||||||
|
r : "尺",
|
||||||
|
s : "丂",
|
||||||
|
t : "丅",
|
||||||
|
u : "凵",
|
||||||
|
v : "リ",
|
||||||
|
w : "山",
|
||||||
|
x : "乂",
|
||||||
|
y : "丫",
|
||||||
|
z : "乙"
|
||||||
|
};
|
||||||
|
const text_array = text.toLowerCase().split("");
|
||||||
|
return text_array.map((character) =>
|
||||||
|
dict[character] ? dict[character] : character)
|
||||||
|
.join("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = () => (ctx) => {
|
||||||
|
|
||||||
|
const message = ctx.message.text.replace(/^[^ ]+/, "");
|
||||||
|
if (message) {
|
||||||
|
|
||||||
|
return weebify(message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (ctx.message.reply_to_message)
|
||||||
|
return weebify(ctx.message.reply_to_message.text);
|
||||||
|
else
|
||||||
|
return "Need text to weebify. Send /weebify text or reply to a "
|
||||||
|
+ "message with /weebify";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,21 @@
|
||||||
|
module.exports = (random, words) => (ctx) => {
|
||||||
|
|
||||||
|
const text_array = ctx.message.text.split(" ");
|
||||||
|
if (text_array.length == 1) {
|
||||||
|
|
||||||
|
return random(words)(10);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const input = parseInt(text_array[1]);
|
||||||
|
if (input && input > 0)
|
||||||
|
if (input < 50)
|
||||||
|
return random(words)(input);
|
||||||
|
else
|
||||||
|
return "Too many words.";
|
||||||
|
else
|
||||||
|
return "Not a valid number.";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "quadnite-bot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A Telegram bot that makes chats in group more fun.",
|
||||||
|
"main": "bot.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+ssh://git@gitlab.com/ceda_ei/Quadnite-Bot.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"bot",
|
||||||
|
"telegram",
|
||||||
|
"telegram-bot"
|
||||||
|
],
|
||||||
|
"author": "Ceda EI",
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://gitlab.com/ceda_ei/Quadnite-Bot/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://gitlab.com/ceda_ei/Quadnite-Bot#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"telegraf": "^3.27.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
dependencies:
|
||||||
|
telegraf: 3.27.1
|
||||||
|
packages:
|
||||||
|
/@types/node/10.12.24:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-GWWbvt+z9G5otRBW8rssOFgRY87J9N/qbhqfjMZ+gUuL6zoL+Hm6gP/8qQBG4jjimqdaNLCehcVapZ/Fs2WjCQ==
|
||||||
|
/debug/4.1.1:
|
||||||
|
dependencies:
|
||||||
|
ms: 2.1.1
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==
|
||||||
|
/ms/2.1.1:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
|
||||||
|
/node-fetch/2.3.0:
|
||||||
|
dev: false
|
||||||
|
engines:
|
||||||
|
node: 4.x || >=6.0.0
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==
|
||||||
|
/sandwich-stream/2.0.2:
|
||||||
|
dev: false
|
||||||
|
engines:
|
||||||
|
node: '>= 0.10'
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==
|
||||||
|
/telegraf/3.27.1:
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 10.12.24
|
||||||
|
debug: 4.1.1
|
||||||
|
node-fetch: 2.3.0
|
||||||
|
sandwich-stream: 2.0.2
|
||||||
|
telegram-typings: 3.6.1
|
||||||
|
dev: false
|
||||||
|
engines:
|
||||||
|
node: '>=6.2.0'
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-RQUnuNAEEWcLhRap81qwGUUqAy1KcvqANnA0G3pzZqFkhMe6LrTk5lVi9tdOaF0Ud/yOx5fdx0rNPYfiB27Z+w==
|
||||||
|
/telegram-typings/3.6.1:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw==
|
||||||
|
registry: 'https://registry.npmjs.org/'
|
||||||
|
shrinkwrapMinorVersion: 9
|
||||||
|
shrinkwrapVersion: 3
|
||||||
|
specifiers:
|
||||||
|
telegraf: ^3.27.1
|
Loading…
Reference in New Issue