File: kickfilter.lua

package info (click to toggle)
eiskaltdcpp 2.2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 20,372 kB
  • ctags: 12,362
  • sloc: cpp: 94,068; ansic: 8,832; perl: 1,523; xml: 1,378; sh: 685; php: 661; makefile: 101
file content (38 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (10)
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
--// kickfilter.lua
--// Filters kick messages from the chat if Filtering is turned on in the Settings

kickfilter = {}
kickfilter._noise = {}
-- If you want, you can add more kick-messages here:
table.insert(kickfilter._noise, "^[^ ]+ is kicking [^ ]+ because")
table.insert(kickfilter._noise, "^is kicking [^ ]+ because")

function kickfilter.isNoise(text)
	if (DC():GetSetting("FilterMessages") == 0) then
		return false
	end
	local ret = false
	for k in pairs(kickfilter._noise) do
		if string.find(text, kickfilter._noise[k]) then
			ret = true
		end
	end
	return ret
end

dcpp:setListener( "chat", "kickfilter",
	function( hub, user, text )
		if kickfilter.isNoise(text) then
			if hub:getProtocol() == "nmdc" then
				DC():PrintDebug("[" .. hub:getUrl() .. "] <" .. DC():ToUtf8(user:getNick()) .. "> " .. DC():ToUtf8(text) )
			else
				DC():PrintDebug("[" .. hub:getUrl() .. "] <" .. user:getNick() .. "> " .. text )
			end
				
				return true
		end
		return false
	end
)

DC():PrintDebug( "  ** Loaded kickfilter.lua **" )