2019-02-11 22:39:42 +01:00
|
|
|
module.exports = (random, kys, default_text, bot_text, excluded_names) => (ctx) => {
|
2019-02-11 21:23:32 +01:00
|
|
|
|
|
|
|
if (ctx.message.reply_to_message) {
|
|
|
|
|
|
|
|
const { from } = ctx.message.reply_to_message;
|
2020-04-19 14:47:12 +02:00
|
|
|
const name = from.username ? "@" + from.username : from.first_name;
|
2019-02-11 22:39:42 +01:00
|
|
|
if (name == excluded_names[0])
|
|
|
|
return bot_text;
|
2019-02-11 21:23:32 +01:00
|
|
|
return random(kys)().replace(/##name##/g, name);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2020-11-20 17:26:16 +01:00
|
|
|
const text_array = ctx.message.text.split(" ");
|
2019-02-11 21:23:32 +01:00
|
|
|
if (text_array.length > 1) {
|
|
|
|
|
2020-11-20 17:26:16 +01:00
|
|
|
const name = text_array.slice(1).reduce((i, j) => i + " " + j).trim();
|
2019-02-11 22:39:42 +01:00
|
|
|
if (excluded_names.includes(name)
|
|
|
|
|| excluded_names.includes("@" + name))
|
|
|
|
return bot_text;
|
|
|
|
|
2019-02-11 21:23:32 +01:00
|
|
|
return random(kys)().replace(/##name##/g, name);
|
|
|
|
|
|
|
|
} else
|
|
|
|
return default_text;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|