Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local name = "ebookspam.lua"
- local desc = "mitigate chat spam in #ebooks on IRCHighWay"
- local version = "0.5"
- hexchat.register(name, version, desc)
- -- grey color and also the token used to identify filtered text
- local c0 = "\00323"
- -- search patterns
- local pat_searchook = "^@[Ss]earchook"
- local pat_find = "^@[Ff]ind"
- local pat_search = "^@[Ss]earch"
- local function cm_print(args)
- hexchat.emit_print("Channel Message", args[1], args[2], args[3], args[4])
- end
- local function cm_print_grey(args)
- args[2] = c0 .. args[2]
- cm_print(args)
- end
- local function cm_print_stripped(args)
- args[2] = c0 .. hexchat.strip(args[2])
- cm_print(args)
- end
- -- highlight search terms, change c1 to modify highlight color
- local function cm_print_search(args)
- local c1 = "\00324"
- args[2] = hexchat.strip(args[2])
- if args[2]:find(pat_searchook) then
- args[2] = args[2]:gsub(pat_searchook, "@searchook" .. c1)
- elseif args[2]:find(pat_find) then
- args[2] = args[2]:gsub(pat_find, "@find" .. c1)
- else
- args[2] = args[2]:gsub(pat_search, "@search" .. c1)
- end
- args[2] = c0 .. args[2]
- cm_print(args)
- end
- local function cm_cbk(args)
- if args[2]:find("^" .. c0) then
- return hexchat.EAT_NONE
- elseif args[2]:find(pat_search) or args[2]:find(pat_find) then -- search syntax
- cm_print_search(args)
- return hexchat.EAT_ALL
- elseif args[2]:find("^@") or args[2]:find("^!") then -- misc spam and download requests
- cm_print_grey(args)
- return hexchat.EAT_ALL
- elseif args[2]:find("[Tt]ype.*@") or args[2]:find("dlFilter") then -- bot spam
- cm_print_stripped(args)
- return hexchat.EAT_ALL
- end
- return hexchat.EAT_NONE
- end
- local function ctcp_print(args)
- args[1] = hexchat.strip(args[1])
- args[1] = c0 .. args[1]
- hexchat.emit_print("CTCP Generic to Channel", args[1], args[2], args[3])
- end
- local function ctcp_cbk(args)
- if args[1]:find("^" .. c0) then
- return hexchat.EAT_NONE
- elseif args[1]:find("OmenServe") or args[1]:find("FWServer") then
- ctcp_print(args)
- return hexchat.EAT_ALL
- end
- return hexchat.EAT_NONE
- end
- local help = ""
- hexchat.hook_print("Channel Message", cm_cbk)
- hexchat.hook_print("CTCP Generic to Channel", ctcp_cbk)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement