feat: expand faketpa + add usage
This commit is contained in:
parent
c51f71c1f2
commit
9cacc2ca46
4
chat.lua
4
chat.lua
|
|
@ -100,11 +100,11 @@ local function sayserver(msg)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function faketpa(tgtplr, sender, fakeplr, fakemsg)
|
local function faketpa(tgtplr, sender, fakeplr, fakemsg, url)
|
||||||
dispatch(function(bx)
|
dispatch(function(bx)
|
||||||
local clickEvent = {
|
local clickEvent = {
|
||||||
action = "open_url",
|
action = "open_url",
|
||||||
value = "https://picture.wtf/p/27wzu9.png",
|
value = url,
|
||||||
}
|
}
|
||||||
|
|
||||||
local msg = {
|
local msg = {
|
||||||
|
|
|
||||||
45
cmds.lua
45
cmds.lua
|
|
@ -211,15 +211,54 @@ cmds.faketpa = {
|
||||||
{ match = "block", desc = "from who fake" },
|
{ match = "block", desc = "from who fake" },
|
||||||
{ match = "block", desc = "from who carrier" },
|
{ match = "block", desc = "from who carrier" },
|
||||||
{ match = "block", desc = "carrier says what" },
|
{ match = "block", desc = "carrier says what" },
|
||||||
|
{ match = "block", desc = "what url to open", optional = true },
|
||||||
},
|
},
|
||||||
allowLimitedUser = true,
|
allowLimitedUser = true,
|
||||||
proc = function(unm, tgt, fromwho, carrierwho, carrierwhat)
|
proc = function(unm, tgt, fromwho, carrierwho, carrierwhat, openurl)
|
||||||
ch.faketpa(tgt, fromwho, carrierwho, carrierwhat)
|
openurl = openurl or "https://picture.wtf/p/27wzu9.png"
|
||||||
|
ch.faketpa(tgt, fromwho, carrierwho, carrierwhat, openurl)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmds.usage = {
|
||||||
|
alias = { "u", "cmd", "c" },
|
||||||
|
desc = "how to use a command?",
|
||||||
|
args = {
|
||||||
|
{ match = "block", desc = "what command" },
|
||||||
|
},
|
||||||
|
allowLimitedUser = true,
|
||||||
|
proc = function(unm, cmd)
|
||||||
|
local xcmd
|
||||||
|
for k, v in next, cmds do
|
||||||
|
if k == cmd then
|
||||||
|
xcmd = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
for _, a in next, v.alias do
|
||||||
|
if a == cmd then
|
||||||
|
xcmd = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not xcmd then
|
||||||
|
ch.send(unm, "could not find command \"" .. cmd .. "\"", "cmd")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local msg = "the usage is- $" .. cmd
|
||||||
|
for _, arg in next, xcmd.args do
|
||||||
|
local br1, br2 = "<", ">"
|
||||||
|
if arg.optional then
|
||||||
|
br1, br2 = "[", "]"
|
||||||
|
end
|
||||||
|
msg = msg .. " " .. br1 .. arg.desc .. br2
|
||||||
|
end
|
||||||
|
ch.send(unm, msg, "help")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds.help = {
|
cmds.help = {
|
||||||
alias = {},
|
alias = { "cmds", "?" },
|
||||||
desc = "help with how to use",
|
desc = "help with how to use",
|
||||||
args = {
|
args = {
|
||||||
{ match = "number", desc = "page", optional = true }
|
{ match = "number", desc = "page", optional = true }
|
||||||
|
|
|
||||||
15
index.lua
15
index.lua
|
|
@ -83,20 +83,21 @@ local function processMessage(unm, msg, hidden)
|
||||||
|
|
||||||
if x.match == "block" then
|
if x.match == "block" then
|
||||||
msg, arg = nextWord(msg)
|
msg, arg = nextWord(msg)
|
||||||
if not arg then
|
if not arg and not x.optional then
|
||||||
ch.send(unm, "missing arg: " .. x.desc, "cmd")
|
ch.send(unm, "missing arg: " .. x.desc, "cmd")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif x.match == "player" then
|
elseif x.match == "player" then
|
||||||
msg, arg = nextWord(msg)
|
msg, arg = nextWord(msg)
|
||||||
if not arg then
|
if not arg and not x.optional then
|
||||||
ch.send(unm, "missing player arg: " .. x.desc, "cmd")
|
ch.send(unm, "missing player arg: " .. x.desc, "cmd")
|
||||||
return
|
return
|
||||||
end
|
else
|
||||||
arg = tk:resTg(arg)
|
arg = tk:resTg(arg)
|
||||||
if not arg then
|
if not arg then
|
||||||
ch.send(unm, "target not found for: " .. x.desc, "cmd")
|
ch.send(unm, "target not found for: " .. x.desc, "cmd")
|
||||||
return
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif x.match == "rest" then
|
elseif x.match == "rest" then
|
||||||
arg = msg
|
arg = msg
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue