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/plugins/set.lua

28 lines
610 B
Lua
Raw Normal View History

2014-11-17 20:47:03 +01:00
function save_value( text )
2014-11-17 21:55:25 +01:00
var_name, var_value = string.match(text, "!set (%a+) (.+)")
2014-11-17 20:47:03 +01:00
if (var_name == nil or var_value == nil) then
return "Usage: !set var_name value"
end
2014-11-23 00:31:22 +01:00
_values[var_name] = var_value
local json_text = json:encode_pretty(_values)
file = io.open ("./res/values.json", "w+")
2014-11-17 20:47:03 +01:00
file:write(json_text)
file:close()
2014-11-23 00:31:22 +01:00
2014-11-17 20:47:03 +01:00
return "Saved "..var_name.." = "..var_value
end
function run(msg, matches)
local text = save_value(msg.text)
return text
end
return {
description = "Set value",
usage = "!set [value_name] [data]",
patterns = {"^!set (%a+) (.+)$"},
run = run
}