PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: NRJ on 07 October, 2005, 20:00:25

Title: CAPS to mormal letters
Post by: NRJ on 07 October, 2005, 20:00:25
Hello!
I need a script that will convert all text written in main chat from CAPS to normal letters expect first letter.

P.s.-Searching not to help (((


Title:
Post by: bastya_elvtars on 07 October, 2005, 22:19:55
QuoteOriginally posted by NRJ
Hello!
I need a script that will convert all text written in main chat from CAPS to normal letters expect first letter.

P.s.-Searching not to help (((


There is some anti-shout bot.
Title:
Post by: NRJ on 17 October, 2005, 13:27:46
QuoteOriginally posted by bastya_elvtars

There is some anti-shout bot.

Script does not work (((
Title:
Post by: Markitos on 17 October, 2005, 13:42:44
QuoteOriginally posted by NRJ
QuoteOriginally posted by bastya_elvtars

There is some anti-shout bot.

Script does not work (((
Wich script ur using???
Title:
Post by: NRJ on 18 October, 2005, 23:16:53
QuoteOriginally posted by Markitos
Wich script ur using???

anti-shout bot.
Title:
Post by: bastya_elvtars on 19 October, 2005, 00:22:23
Post the code please.
Title:
Post by: NightLitch on 19 October, 2005, 00:42:02
maybe this is the only thing needed:

function ChatArrival(user,data)
local _,_,msg = string.find(data, "%b<>%s(.*)%|")
    msg = string.gsub(msg, "(%S+)", function(word)
        local s = string.sub(word,1,1)
        return string.upper(s)..string.lower(string.sub(word,2))
end)
    SendToAll(user.sName, msg)
    return 1
end

I don't know, just made it, was bored...
Title: Re: CAPS to mormal letters
Post by: NRJ on 05 September, 2006, 15:55:50
I have casually found my topic and I decided to publish the decision of a old problem)

-- REPLACE SCPIRT by NRJ
-- based on NO YELL SCPIRT by NoNick

Messize=5; -- Min length of message in letters for replace text
Persent=0.8; -- Per cent of upper letters in message

Bot=frmHub:GetHubBotName() 

Letters={["A"]="a",["B"]="b",["C"]="c",["D"]="e",["E"]="e",["F"]="f",["G"]="g",["H"]="h",["I"]="i",["J"]="j",["K"]="k",["L"]="l",["M"]="m",["N"]="n",["O"]="o",["P"]="p",["Q"]="q",["R"]="r",["S"]="s",["T"]="t",["U"]="u",["V"]="v",["W"]="w",["X"]="x",["Y"]="y",["Z"]="z"}

function ChatArrival(sUser, sData)
local sData = string.sub(sData,(string.len(sUser.sName)+4),string.len(sData)-1)
if string.len(sData) > Messize then
local NoSpaces = string.gsub(sData , "[%s%p%с]", "")
local NoSpacesLen = string.len(NoSpaces)
local NoCAPSLen = string.len(string.gsub(NoSpaces , "[%abcdefghijklmnopqrstuvwxyz]", ""))

local val = (NoSpacesLen - NoCAPSLen)/NoSpacesLen
if  val > Persent then
sData =string.lower(sData)
for b,s in Letters do
sData=string.gsub(sData , b, Letters[b])
end
SendToNick(sUser.sName,"<"..Bot..">"..sUser.sName..", dont use CAPS LOCK!")
SendToAll("<"..sUser.sName.. "> " .. sData );
return 1
end
end
end
Title: Re: CAPS to mormal letters
Post by: bastya_elvtars on 05 September, 2006, 16:11:16
Quote from: NRJ on 05 September, 2006, 15:55:50
I have casually found my topic and I decided to publish the decision of a old problem)

-- REPLACE SCPIRT by NRJ
-- based on NO YELL SCPIRT by NoNick

Messize=5; -- Min length of message in letters for replace text
Persent=0.8; -- Per cent of upper letters in message

Bot=frmHub:GetHubBotName() 

Letters={["A"]="a",["B"]="b",["C"]="c",["D"]="e",["E"]="e",["F"]="f",["G"]="g",["H"]="h",["I"]="i",["J"]="j",["K"]="k",["L"]="l",["M"]="m",["N"]="n",["O"]="o",["P"]="p",["Q"]="q",["R"]="r",["S"]="s",["T"]="t",["U"]="u",["V"]="v",["W"]="w",["X"]="x",["Y"]="y",["Z"]="z"}

function ChatArrival(sUser, sData)
local sData = string.sub(sData,(string.len(sUser.sName)+4),string.len(sData)-1)
if string.len(sData) > Messize then
local NoSpaces = string.gsub(sData , "[%s%p%с]", "")
local NoSpacesLen = string.len(NoSpaces)
local NoCAPSLen = string.len(string.gsub(NoSpaces , "[%abcdefghijklmnopqrstuvwxyz]", ""))

local val = (NoSpacesLen - NoCAPSLen)/NoSpacesLen
if  val > Persent then
sData =string.lower(sData)
for b,s in Letters do
sData=string.gsub(sData , b, Letters[b])
end
SendToNick(sUser.sName,"<"..Bot..">"..sUser.sName..", dont use CAPS LOCK!")
SendToAll("<"..sUser.sName.. "> " .. sData );
return 1
end
end
end


for w in string.gmatch(text,"(%u+)") do
  text=string.gsub(text,w,string.lower(w))
end
Title: Re: CAPS to mormal letters
Post by: Thor on 05 September, 2006, 16:22:26
http://scriptdb.ptokax.ath.cx/download.php?view.90 ::)
Title: Re: CAPS to mormal letters
Post by: bastya_elvtars on 05 September, 2006, 19:57:40
This is a bit scientific approach, bit of challenge for me. :)

text="AADAFNAUOFhtrhfhgfhgfREtKaAAAAAAA"
txt=text
local num=0
for w in string.gmatch(text,"(%u)") do
  txt=string.gsub(text,w,string.lower(w))
  num=num+1
end

print((num/string.len(text)*100).."% of the chars had to be \"lowered\"")
print(txt)


Replace print to SendToAll for PtokaX.
Title: Re: CAPS to mormal letters
Post by: jiten on 05 September, 2006, 22:18:25
Something similar:

text = "AADAFNAUOFhtrhfhgfhgfREtKaAAAAAAA"
msg, x = string.gsub(text, "(%u)", function(s) return string.lower(s) end)
SendToAll(frmHub:GetHubBotName(), "\r\n\r\n\t*** "..x.." chars [ "..
string.format("%0.3f", x/string.len(text)*100).."% ] were lowered!\r\n\t"..
"*** Output: "..msg)
Title: Re: CAPS to mormal letters
Post by: bastya_elvtars on 05 September, 2006, 23:30:13
Quote from: jiten on 05 September, 2006, 22:18:25
Something similar:

text = "AADAFNAUOFhtrhfhgfhgfREtKaAAAAAAA"
msg, x = string.gsub(text, "(%u)", function(s) return string.lower(s) end)
SendToAll(frmHub:GetHubBotName(), "\r\n\r\n\t*** "..x.." chars [ "..
string.format("%0.3f", x/string.len(text)*100).."% ] were lowered!\r\n\t"..
"*** Output: "..msg)


Yeah, better than mine, haven't played with strings since April or so.
Title: Re: CAPS to mormal letters
Post by: JueLz on 13 October, 2006, 03:18:46
And mutor could you make it so if the user is operate
he can use caps?
Title: Re: CAPS to mormal letters
Post by: JueLz on 13 October, 2006, 11:12:20
Thank you :)