Commit d9d77f97 by Todd Coram

refactor

parent 660c443f
......@@ -201,7 +201,7 @@ local function mutter_request(fromcs,msg)
session = msg.session,
channel_id = msg.channel_id,
tree_id = msg.tree_id,
message = doreq(config,req,a1) }
message = doreq.func(mutterbotreq,config,req,a1) }
local respmsg_p = wire.make_packet(proto.TEXTMESSAGE,respmsg:save())
local cs = manager.session[manager.user[fromcs].state.session]
cs:send(respmsg_p)
......
......@@ -2,18 +2,30 @@ local crypto = require'crypto'
local rand = require'randbytes'
local mutter_req = {
["genpass"] = function (cfg,req)
local pass = crypto.hex(rand(4))
cfg.userpassword = pass
return("User Password is "..pass)
end,
["welcome"] = function (cfg,req,p1)
cfg.welcome_text = p1
return("Welcome text is set to:"..p1)
end,
["unknown-request"] = function (cfg,req)
return("Huh? "..req)
end
["genpass"] = {help="Generate a unique password for all users.",
func = function (self,cfg,req)
local pass = crypto.hex(rand(4))
cfg.userpassword = pass
return("User Password is "..pass)
end
},
["welcome"] = {help="Set a new welcome message.",
func = function (self,cfg,req,p1)
cfg.welcome_text = p1
return("Welcome text is set to:"..p1)
end
},
["unknown-request"] = {
func = function (self,cfg)
local msg = "Huh?<br/>"
for n,h in pairs(self) do
if h.help then
msg = msg .. "<bold>"..n .. "</bold> - " .. h.help .. "<br/>"
end
end
return(msg)
end
}
}
return mutter_req
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment