From 9cacc2ca46704cabf9ea0c136e08c8707ea454d0 Mon Sep 17 00:00:00 2001 From: min Date: Fri, 20 Feb 2026 05:56:57 -0500 Subject: [PATCH] feat: expand faketpa + add usage --- chat.lua | 4 ++-- cmds.lua | 45 ++++++++++++++++++++++++++++++++++++++++++--- index.lua | 15 ++++++++------- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/chat.lua b/chat.lua index 942e794..7b9afc1 100644 --- a/chat.lua +++ b/chat.lua @@ -100,11 +100,11 @@ local function sayserver(msg) end) end -local function faketpa(tgtplr, sender, fakeplr, fakemsg) +local function faketpa(tgtplr, sender, fakeplr, fakemsg, url) dispatch(function(bx) local clickEvent = { action = "open_url", - value = "https://picture.wtf/p/27wzu9.png", + value = url, } local msg = { diff --git a/cmds.lua b/cmds.lua index f140374..858fd78 100644 --- a/cmds.lua +++ b/cmds.lua @@ -211,15 +211,54 @@ cmds.faketpa = { { match = "block", desc = "from who fake" }, { match = "block", desc = "from who carrier" }, { match = "block", desc = "carrier says what" }, + { match = "block", desc = "what url to open", optional = true }, }, allowLimitedUser = true, - proc = function(unm, tgt, fromwho, carrierwho, carrierwhat) - ch.faketpa(tgt, fromwho, carrierwho, carrierwhat) + proc = function(unm, tgt, fromwho, carrierwho, carrierwhat, openurl) + 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, } cmds.help = { - alias = {}, + alias = { "cmds", "?" }, desc = "help with how to use", args = { { match = "number", desc = "page", optional = true } diff --git a/index.lua b/index.lua index a9bd31e..6e47b9f 100644 --- a/index.lua +++ b/index.lua @@ -83,20 +83,21 @@ local function processMessage(unm, msg, hidden) if x.match == "block" then msg, arg = nextWord(msg) - if not arg then + if not arg and not x.optional then ch.send(unm, "missing arg: " .. x.desc, "cmd") return end elseif x.match == "player" then 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") return - end - arg = tk:resTg(arg) - if not arg then - ch.send(unm, "target not found for: " .. x.desc, "cmd") - return + else + arg = tk:resTg(arg) + if not arg then + ch.send(unm, "target not found for: " .. x.desc, "cmd") + return + end end elseif x.match == "rest" then arg = msg