This repository was archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
74 lines (47 loc) · 2.07 KB
/
main.lua
File metadata and controls
74 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
------------------------------------------------------------------------------------------------------------------------
-- PLEASE SET THE DIRECTORY OF THIS SCRIPT
local script_dir = ""
local mod_channels = {
"##minetest-ctf",
}
local log_channel = "##smartguard"
------------------------------------------------------------------------------------------------------------------------
hexchat.register("SmartGuard", "2.0 Beta", "Aids moderation by narrowing messages down to suspicious ones")
-- Require
package.path = package.path .. ";" .. script_dir .. "/?.lua"
require("smartguard")
require("blacklist")
require("whitelist")
------------------------------------------------------------------------------------------------------------------------
local function log_message(pname, pmessage)
local log = 'Player ' .. pname .. ' said "' .. pmessage .. '"'
hexchat.command("msg " .. log_channel .. " " .. log)
-- HexChat doesn't support notifications so DM is sent to yourself
local my_nick = hexchat.get_info("nick")
-- Please comment out the following line if you would like it to stop
hexchat.command("msg " .. my_nick .. " " .. log)
end
function is_in(str, tbl)
for _, value in pairs(tbl) do
if value == str then
return true
end
end
return false
end
------------------------------------------------------------------------------------------------------------------------
hexchat.hook_print("Channel Message", function(word, _)
if is_in(hexchat.get_info("channel"), mod_channels) then
local message_org = word[2]
local message_auth, message_cont = message_org:match("([^%s]+)%s*(.*)")
if smartguard.moderate(message_cont, message_auth,
blacklist.blacklist1,
blacklist.blacklist2,
whitelist.whitelist1)
then
log_message(message_auth, message_cont)
end
end
return hexchat.EAT_NONE
end)
------------------------------------------------------------------------------------------------------------------------