diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-15 15:51:02 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-15 15:51:02 +0500 |
| commit | e410ed000d119d0d3e4d5707abad11512b9e4a34 (patch) | |
| tree | 9c794a3fbc0ca615363948c4c92c183c462c6548 /luamods/help.lua | |
| parent | 2bd139d4323efa983df47bd131c90df501aee371 (diff) | |
feat: !help in lua
Diffstat (limited to 'luamods/help.lua')
| -rw-r--r-- | luamods/help.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/luamods/help.lua b/luamods/help.lua new file mode 100644 index 0000000..6fd8968 --- /dev/null +++ b/luamods/help.lua @@ -0,0 +1,50 @@ +local lines = { + english = { + ["command_unavailable"] = "{sender.alias_name}: This command is not available.", + ["help_default"] = "{sender.alias_name}: More info can be found here: %s", + ["help_command"] = "{sender.alias_name}: More info about {channel.prefix}%s: %s", + }, + russian = { + ["command_unavailable"] = "{sender.alias_name}: Эта команда недоступна.", + ["help_default"] = "{sender.alias_name}: Больше информации можно найти здесь: %s", + ["help_command"] = "{sender.alias_name}: Больше информации о {channel.prefix}%s: %s", + }, +} + +return { + name = "help", + description = [[ +Get an information about commands. +]], + delay_sec = 1, + options = {}, + subcommands = {}, + aliases = {}, + minimal_rights = "user", + handle = function(request) + local cfg = bot_config() + if cfg == nil then + return l10n_custom_formatted_line_request(request, lines, "command_unavailable", {}) + end + + if cfg.url.help == nil then + return l10n_custom_formatted_line_request(request, lines, "command_unavailable", {}) + end + + local line_id = "help_default" + local args = { cfg.url.help } + if request.message ~= nil then + local parts = str_split(request.message, ' ') + local command = parts[1] + + if array_contains(bot_get_loaded_command_names(), command) then + line_id = "help_command" + args = {} + table.insert(args, command) + table.insert(args, cfg.url.help .. '/!' .. command) + end + end + + return l10n_custom_formatted_line_request(request, lines, line_id, args) + end, +} |
