Add /word, /words
This commit is contained in:
parent
1f6fc86faa
commit
4d2b2eb650
3
bot.js
3
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 =>
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
const random = require("./random");
|
const random = require("./random");
|
||||||
const insults_fun = require("./insult");
|
const insults_fun = require("./insult");
|
||||||
|
const words_fun = require("./words");
|
||||||
const is = require("./is");
|
const is = require("./is");
|
||||||
module.exports = (bot, [ questions, kys, insults, commands_list ]) => {
|
module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => {
|
||||||
|
|
||||||
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("words", (ctx) => ctx.reply(words_fun(random, words)(ctx)));
|
||||||
bot.telegram.getMe()
|
bot.telegram.getMe()
|
||||||
.then(bot_user => {
|
.then(bot_user => {
|
||||||
|
|
||||||
console.log(bot_user);
|
|
||||||
const default_text = (command, text) => `Do you want to ${text} `
|
const default_text = (command, text) => `Do you want to ${text} `
|
||||||
+ `yourself?\nIf no, reply to someone with /${command} to kill`
|
+ `yourself?\nIf no, reply to someone with /${command} to kill`
|
||||||
+ ` them or run /${command} username/name.\nYou can suggest `
|
+ ` them or run /${command} username/name.\nYou can suggest `
|
||||||
|
|
|
@ -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.";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue