From 4b8aecf28a8d61b7945469b70bdb200032e77a3e Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Wed, 6 Oct 2021 22:59:08 +0530 Subject: [PATCH] Allow aliases in roleplay.json. Add runs, sob, sobs, handhold aliases --- commands/index.js | 33 ++++++++++++++++++++++++++------- static/roleplay.json | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/commands/index.js b/commands/index.js index 7cc479b..443cb84 100644 --- a/commands/index.js +++ b/commands/index.js @@ -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)); diff --git a/static/roleplay.json b/static/roleplay.json index 7764610..bb6115f 100644 --- a/static/roleplay.json +++ b/static/roleplay.json @@ -143,6 +143,9 @@ "both": "{} is glomping {} for {}" } }, + "handhold": { + "alias": "holdhands" + }, "happy": { "forms": { "none": "{} is happy", @@ -319,6 +322,9 @@ "both": "{} is running from {} for {}" } }, + "runs": { + "alias": "run" + }, "shoot": { "forms": { "none": "{} is shooting", @@ -359,6 +365,18 @@ "both": "{} is sleeping {} for {}" } }, + "sob": { + "alias": "sobs" + }, + "sobs": { + "alias": "cry", + "forms": { + "none": "{} is sobbing", + "others": "{} is sobbing due to {}", + "reason": "{} is sobbing because {}", + "both": "{} is sobbing due to {} because {}" + } + }, "snuggle": { "forms": { "none": "{} is snuggling",