TalkAction [LUA and C++]Block IPs/links on Default/Trade/Help

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,026
Best answers
19
Reaction score
1,063
Location
PLand
Idea from http://otland.net/f81/advanced-anti-swearing-50400/
When player say:
otservlist.org/index.php&show=543456
it show:
13:06 Gessi [102]: (illegal IP)/index.php&show=543456
---------------------
C++ code (TFS 0.3.5 !) execute talkaction 'illegalWords' always when anything say something (not spell/talkaction). LUA script must check is it player, channel ...
In source in talkaction.cpp find:
PHP:
	if(!talkAction || (talkAction->getChannel() != -1 && talkAction->getChannel() != channelId))
		return false;
and replace with:
PHP:
	if(!talkAction)
	{
    	for(TalkActionsMap::iterator it = talksMap.begin(); it != talksMap.end(); ++it)
    	{
    		if(it->first == "illegalWords")
    		{
    			talkAction = it->second;
    			break;
    		}
    	}
    	if(talkAction && talkAction->isScripted() && talkAction->executeSay(creature, words, "", channelId))
    	    return true;
        return false;
    }
    else if(talkAction->getChannel() != -1 && talkAction->getChannel() != channelId)
		return false;
(compile :) )
in talkactions.xml add:
PHP:
<talkaction words="illegalWords" event="script" value="illegalwords.lua"/>
in illegalwords.lua paste:
Lua:
function getFixedText(cid, text)
    local wrongWords = {"otservlist.org", "ots-list.pl", "google.br", "83.17.165.189", "hopto.org", "no-ip.org", ".com"}
	local lowerText = string.lower(text)
	local noSpaceText = string.gsub(string.gsub(string.gsub(lowerText, "%s", ""), "%p", ""),"-", "")
	for w = 1, #wrongWords do
		wordLen = string.len(wrongWords[w])
		for p = 1, string.len(text) do
			if(string.sub(lowerText, p, p+wordLen-1) == wrongWords[w]) then
				text = string.sub(text, 1, p-1) .. string.rep("*", wordLen) .. string.sub(text, p+wordLen)
			end
		end
	end
	if(string.lower(text) == lowerText) then
		for c = 1, #wrongWords do
			if(string.find(noSpaceText, string.gsub(string.gsub(wrongWords[c], "%p", ""),"-", "")) ~= nil) then
				return "I think I'm better then link blocker, but I'm not :( (message from link blocker)."
			end
		end
	end
    return text
end

function onSay(cid, words, param, channel)
		local fixedWords = getFixedText(cid, words)
		if words ~= fixedWords and getPlayerAccess(cid) == 0 then
			if channel == 0 then -- default
				doCreatureSay(cid, fixedWords, TALKTYPE_SAY)
				return true
			elseif channel == 5 or channel == 7 then -- trade
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't send links to Trade channel.")
				return true
			elseif channel == 9 then -- help
				doPlayerSendChannelMessage(cid, getCreatureName(cid), fixedWords, TALKTYPE_CHANNEL_Y, channel)
				return true
			end
		end
	return false
end
(it block links on trade/rook-trade, because player doesn't get 2 min exhaust when post links with this script)
If talkaction return false (illegalWords false = good msg) player say normal message/send to channel.
EDIT:
ADDED NEW LINK/IP DETECTION FUNCTION
Its version to block links, better dont try to add here insults like 'fuck' because it can work wrong and block other words (ignore [one or more] 'space', ',', '.', '-', ' , " in text)
you can block user otses like:
xxxx.hopto.org
or short link/dns services like:
no-ip.net
hopto.org
tinyurl.net
or 90% links:
.org
.net
.com
.pl
.br
for normal user that try to post link it show:
if someone try to post link to his ots:
NEW BEST RPG OTS! ACC. MAKER http://mybestots.hopto.org/index.php
23:49 Erg: NEW BEST RPG OTS! ACC. MAKER http://mybestots.*********/index.php
players will have problem to get info what is address of server
if spammer 'is pro' and try something like (space and - ):
NEW BEST RPG OTS! ACC. MAKER http://mybestots - hopto - org/index.php
23:50 Erg: I think I'm better then link blocker, but I'm not :( (message from link blocker).
JUST EDIT CONFIG (add spammed link/ip) IN LUA FILE AND ON GOD IN GAME SAY '/reload talkactions'
 
Last edited:

GSMaster

Why? for money
Joined
Oct 26, 2008
Messages
160
Best answers
0
Reaction score
8
Location
HKS <3
Nice nice ;)I have small bug:

Player say: google.br = (illegal IP) :)
and
Player say: Google.br = Google.br :(
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
Nice one, rep +8 is coming :p
 
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,026
Best answers
19
Reaction score
1,063
Location
PLand
Nice nice ;)I have small bug:

Player say: google.br = (illegal IP) :)
and
Player say: Google.br = Google.br :(
Edited first post. Moved text check (and fix) to new function. Now everyone can edit it easy to block what he want. You can add some functions for players like:
replace:
#level - player (cid) level
#sword - sword skill
#sword% - sword percent
...
(but better if someone add it for priv. msgs too :p )
 

Zerak456

Gorlex.net NEW!
Joined
Aug 13, 2008
Messages
1,060
Best answers
0
Reaction score
6
Location
Germany
make

.com
.se
.pl
.br
.co.uk
etc..

and
,com
,co,uk
,co.uk
.co,uk
,se
,pl
,hopto,org
,hopto.org
.hopto,org
etc..
 

Gregor

New Member
Joined
Feb 29, 2008
Messages
770
Best answers
0
Reaction score
3
Location
UK/POLAND
Nice script gesior :)

ps. do you have any own ots right now?
 
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,026
Best answers
19
Reaction score
1,063
Location
PLand
Nice nice ;)I have small bug:

Player say: google.br = (illegal IP) :)
and
Player say: Google.br = Google.br :(
muuuch better version (tested on my war server with many addresses):
in place of function from (old) first post (updated) use it:
PHP:
function getFixedText(cid, text)
    local wrongWords = {"otservlist.org", "ots-list.pl", "google.br", "83.17.165.189", "hopto.org", "no-ip.org", ".com"}
	local lowerText = string.lower(text)
	local noSpaceText = string.gsub(string.gsub(string.gsub(lowerText, "%s", ""), "%p", ""),"-", "")
	for w = 1, #wrongWords do
		wordLen = string.len(wrongWords[w])
		for p = 1, string.len(text) do
			if(string.sub(lowerText, p, p+wordLen-1) == wrongWords[w]) then
				text = string.sub(text, 1, p-1) .. string.rep("*", wordLen) .. string.sub(text, p+wordLen)
			end
		end
	end
	if(string.lower(text) == lowerText) then
		for c = 1, #wrongWords do
			if(string.find(noSpaceText, string.gsub(string.gsub(wrongWords[c], "%p", ""),"-", "")) ~= nil) then
				return "I think I'm better then link blocker, but I'm not :( (message from link blocker)."
			end
		end
	end
    return text
end
Its version to block links, better dont try to add here insults like 'fuck' because it can work wrong and block other words (ignore [one or more] 'space', ',', '.', '-', ' , " in text)
you can block user otses like:
xxxx.hopto.org
or short link/dns services like:
no-ip.net
hopto.org
tinyurl.net
or 90% links:
.org
.net
.com
.pl
.br
for normal user that try to post link it show:
if someone try to post link to his ots:
NEW BEST RPG OTS! ACC. MAKER http://mybestots.hopto.org/index.php
23:49 Erg: NEW BEST RPG OTS! ACC. MAKER http://mybestots.*********/index.php
players will have problem to get info what is address of server
if spammer 'is pro' and try something like (space and - ):
NEW BEST RPG OTS! ACC. MAKER http://mybestots - hopto - org/index.php
23:50 Erg: I think I'm better then link blocker, but I'm not :( (message from link blocker).
 
Last edited:
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,026
Best answers
19
Reaction score
1,063
Location
PLand
very nice.
works in 0.3.4?
Check is it crash ots when someone write illegal link on help [player, not gm] (I have this problem on version ~0.3.4pl2). If not, all should work.
 

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
392
Best answers
0
Reaction score
0
Location
Brazil
it makes mods(talkaction) stop working.
or I did something wrong.(but I dont think so.)
 
Top