Allow aliases in roleplay.json. Add runs, sob, sobs, handhold aliases

This commit is contained in:
2021-10-06 22:59:08 +05:30
parent f1740ce4c0
commit 4b8aecf28a
2 changed files with 44 additions and 7 deletions

View File

@@ -67,16 +67,35 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay
+ "chatting with me in private, you are most likely doing it wrong. "
+ "Add me to a group for fun. To give feedback, use /feedback"));
const getGetGif = (command) => () => axios.get(
`category/${command}/gif`,
{
baseURL: ugokiRoot
}
);
function getGetGif(command) {
const alias = roleplay_data[command].alias;
if (alias)
return getGetGif(alias);
return () => axios.get(
`category/${command}/gif`,
{
baseURL: ugokiRoot
}
);
}
function getForms(name) {
if (roleplay_data[name].forms)
return roleplay_data[name].forms;
return getForms(roleplay_data[name].alias);
}
// Add all roleplay commands
Object.keys(roleplay_data).map(command =>
bot.command(command, ctx => roleplay(roleplay_data[command].forms, getGetGif(command))(ctx)));
bot.command(command,
(ctx) => roleplay(getForms(command), getGetGif(command))(ctx)
)
);
bot.command("suggest", (ctx) => suggest(axios, apiToken, ugokiRoot)(ctx));