This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/plugins/hex.lua

30 lines
437 B
Lua
Raw Normal View History

2015-07-03 00:15:52 +02:00
local PLUGIN = {}
PLUGIN.doc = [[
2015-07-08 09:38:04 +02:00
/hex <number>
2015-07-03 00:15:52 +02:00
This function converts a number to or from hexadecimal.
]]
PLUGIN.triggers = {
2015-07-08 09:38:04 +02:00
'^/hex '
2015-07-03 00:15:52 +02:00
}
function PLUGIN.action(msg)
local input = get_input(msg.text)
if string.sub(input, 1, 2) == '0x' then
send_msg(msg, tonumber(input))
elseif tonumber(input) then
send_msg(msg, string.format('%x', input))
else
send_msg(msg, config.locale.errors.argument)
2015-07-03 00:15:52 +02:00
end
end
return PLUGIN