• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

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

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,955
Solutions
98
Reaction score
3,351
Location
Poland
GitHub
gesior
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:
Nice nice ;)I have small bug:

Player say: google.br = (illegal IP) :)
and
Player say: Google.br = Google.br :(
 
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 )
 
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..
 
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:
it makes mods(talkaction) stop working.
or I did something wrong.(but I dont think so.)
 
Nice idea! But if you add all of domains how to allow yours adress? Maybe some exception into script? Btw rep++
 
Back
Top