summaryrefslogtreecommitdiff
path: root/luamods/say.lua
blob: 8fa48be41fb5eca40fe6617fe86dcb555bbd3e7f (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
local lines = {
	english = {
		["no_message"] = "{sender.alias_name}: Message must be provided.",
	},
	russian = {
		["no_message"] = "{sender.alias_name}: Сообщение должно быть указано.",
	},
}

return {
	name = "say",
	description = "Make the bot say something. Available only to superusers.",
	delay_sec = 5,
	options = {},
	subcommands = {},
	aliases = {},
	minimal_rights = "superuser",
	handle = function(request)
		if request.message == nil then
			return l10n_custom_formatted_line_request(request, lines, "no_message", {})
		end

		local msg = request.message

		local parts = str_split(msg, " ")
		if #parts == 0 then
			return l10n_custom_formatted_line_request(request, lines, "no_message", {})
		end

		local channel_name = request.channel.alias_name
		if string.sub(parts[1], 1, 1) == "#" then
			channel_name = string.sub(parts[1], 2, #parts[1])
			table.remove(parts, 1)
			msg = table.concat(parts, " ")
		end

		irc_send_message(channel_name, msg)

		return nil
	end,
}