anti-shout (rather fun)
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

anti-shout (rather fun)

Started by bastya_elvtars, 06 September, 2004, 23:52:31

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bastya_elvtars

-- anti-shout script
-- not perfect, only detects 2+ words to minimize bugs
-- replaces uppercase with lowercase only if whole text is uppercase
-- added non-english char table, it counts only when things are needed 2 replace
-- if both words consist of non-standard chars only, it ignores (in Hungarian, its quite impossible)
-- consumes resources, use with caution
-- NB: made for hungarian and english language, but supports german IMHO (i dont speak german) - feel free to modify the table
-- bastya_elvtars (the rock n' roll doctor)

Bot="-Silence-"

locale="hun" -- change 2 your location,if you add a bad code, the script fails to start (to avoid bad locale settings causing bad work)

nonstandard={	["Ű"]="ű",
				["?"]="?",
				["?"]="?",
				["Ő"]="ő",
				["?"]="?",
				["?"]="?",
				["?"]="?",
				["?"]="?"
}
-- sets locale
function Main()
	assert(setlocale(locale),"Bad locale!") -- does not seem 2 have influence :-/
end
-- checks data
function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		local _,_,text=strfind(data,"%b<>%s+(%S+%s+%S+.*)")
		if text then
			local engletters=gsub(text, "%A","")
			if strfind(engletters,"(%a+)") then 
				if strupper(engletters)==engletters then
					SendToAll(Bot,"Hmm hmm... "..user.sName.." better not shout...;)")
					attenuate(user,text)  return 1
				end
			end
		end
	end
end
-- find out what this does ^^
function attenuate(user,text)
	text=strlower(text)
	for a,b in nonstandard do
		text=gsub(text,a,b)
	end
	SendToAll("<"..user.sName.."> "..text)
end
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk