This commit is contained in:
2021-06-22 19:06:52 +05:30
5 changed files with 1251 additions and 18 deletions

View File

@@ -8,8 +8,9 @@ const feedback = require("./feedback");
const media_wiki = require("./media_wiki");
const info = require("./info");
const expand = require("./expand");
const roleplay = require("./roleplay");
module.exports = (bot, [ questions, kys, insults, commands_list, words ], feedback_id, axios) => {
module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay_data ], feedback_id, axios) => {
bot.command("question", (ctx) => ctx.reply(random(questions)()));
bot.command("word", (ctx) => ctx.reply(random(words)()));
@@ -32,7 +33,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ], feedba
});
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("are", (ctx) => ctx.reply(is(random)(ctx)));
bot.command("can", (ctx) => ctx.reply(is(random)(ctx)));
@@ -63,4 +64,8 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ], feedba
bot.command("expand", (ctx) => ctx.reply(expand(words)(ctx)));
bot.command("start", (ctx) => ctx.reply("Hi! I'm Octanite. Sibling of @quadnite_bot. My creator @ceda_ei created me as 'another option' to users who want the bot in their groups to have privacy mode enabled. \n\nPrivacy mode? Wut is that?\n- Well basically disabling privacy mode enables a bot to read all the messages. @quadnite_bot has that disabled. Enabling privacy mode causes the bot to not recieve messages at some times. To circumvet that, you need to append @octanite_bot to your commands or simply use @quadnite_bot. \n\n[P.S. - My creator doesn't store any messages or personal data. It's safe to use any of the two bots.]\nTo 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)));
};

40
commands/roleplay.js Normal file
View 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});
};