You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

2 days ago
-- Chat module for ARZ Web Helper
local M = {}
function M.init(fw)
-- Register static files
local static_dir = fw.modules_dir .. "/chat/static"
fw.register_module("chat", static_dir)
fw.log("INFO", "CHAT", "Module registered, static: " .. static_dir)
-- Register API handler
fw.on_api("chat", "send", function(body)
local ok, data = pcall(fw.json_decode, body)
if not ok or not data or not data.text then
return '{"ok":false,"error":"invalid body"}'
end
local text = data.text
if #text == 0 or #text > 144 then
return '{"ok":false,"error":"invalid length"}'
end
local win_text = fw.to_win1251(text)
sampProcessChatInput(win_text)
fw.log("INFO", "CHAT", "Sent: " .. text)
return '{"ok":true}'
end)
-- Intercept: block outgoing messages containing "spam"
fw.on_event("onSendChat", function(message)
if message:lower():find("spam") then
fw.log("WARN", "CHAT", "Blocked outgoing: " .. message)
return false
end
end, 10)
end
return M