summaryrefslogtreecommitdiff
path: root/luamods/help.lua
blob: 6fd8968192d4fd71269219147972e8bbed1fdf0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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,
}