mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-28 07:44:56 +00:00
38 lines
914 B
Lua
38 lines
914 B
Lua
--- @class FlagResult Result of flagging a post
|
|
--- @field flagged boolean Whether the post was flagged
|
|
--- @field reasons string[] List of reasons for flagging
|
|
|
|
--- Flag a post for moderation
|
|
--- Checks content length and banned terms
|
|
---@param post { content?: string } Post to check
|
|
---@return FlagResult Flagging result
|
|
local function flag_post(post)
|
|
local banned_terms = {
|
|
"spam",
|
|
"scam",
|
|
"phish",
|
|
"abuse"
|
|
}
|
|
|
|
local content = post.content or ""
|
|
local reasons = {}
|
|
|
|
if #content > 5000 then
|
|
table.insert(reasons, "Post exceeds 5000 characters")
|
|
end
|
|
|
|
local lowered = string.lower(content)
|
|
for _, term in ipairs(banned_terms) do
|
|
if string.find(lowered, term, 1, true) then
|
|
table.insert(reasons, "Contains banned term: " .. term)
|
|
end
|
|
end
|
|
|
|
return {
|
|
flagged = #reasons > 0,
|
|
reasons = reasons
|
|
}
|
|
end
|
|
|
|
return flag_post
|