Dont count nick in stats
 

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

Dont count nick in stats

Started by Madman, 20 May, 2004, 05:02:06

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

Hi, i use this script

-- chatstats v2
-- by tezlo
-- modified by tezlo and Optimus
-- modified by Madman for his "needs" :p


--everybody can.. 
--?mystats 
--?userstats  
--?stats [category] (there are 4 categories.. posts chars --words smilies) 

--OPs also can.. 
--!savestats and !loadstats (obsolete.. stats get saved --automatically) 
--!clearstats

eyes = ":;8B="
nose = "-o'"
mouth = "%[%)%(%]DpP?sS"
-- modify the above to fit your needs!

stats = {}
names = { posts = 1, chars = 2, words = 3, smilies = 4 }
-- can you think of something else to count? post up


function Main()
	loadStats()
end

function OnExit()
	saveStats()
end

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, str = strfind(data, "^%b<> (.*)%|$")
		local s, e, cmd, args = strfind(str, "^([%!%?]%a+)%s*(.*)$")
		if s then
			cmd = strlower(cmd)
			if cmd == "?mystats" then cmdStats(user, user.sName)
			elseif cmd == "?userstats" then cmdStats(user, args)
			elseif cmd == "?stats" then cmdTopStats(user, args)
			elseif cmd == "!savestats" and (user.iProfile == 0) then saveStats(user)
			elseif cmd == "!loadstats" and (user.iProfile == 0)  then loadStats(user)
			elseif cmd == "!clearstats" and (user.iProfile == 0)  then clearStats(user)
			else return end return 1
		else	updStats(user.sName, str)
		end
	end
end

function cmdStats(user, target)
	local tmp = stats[target]
	if tmp then user:SendData(">>> chatstats for "..target..": "..tmp[1].." posts "..tmp[2].." characters "..tmp[3].." words "..tmp[4].." smilies")
	else user:SendData(">>> no record for "..target) end
end

function cmdTopStats(user, args) 
local id = names[args] or 1 
local index = sortStats(id) 
local chat = "" 
chat = chat.."\r\n\r\n\t============== -=Current Top 20 Chatstats=- ==============\r\n" 
chat = chat.."\tNr:\tPosts:\tChartrs:\tWords:\tSmilies:\tNick:\r\n" 
local n = getn(index) 
if n > 20 then n = 20 end 
for i = 1, n do 
local nick = index[i] 
local tmp = stats[nick] 
chat = chat.."\t"..i..".\t "..tmp[id].."\t "..tmp[2].."\t "..tmp[3].."\t "..tmp[4].."\t"..nick.."\r\n" 
end 
SendToAll(chat) 
end 


function loadStats(user)
	stats = dofile("chatstats.dat") or {}
	if user then user:SendData(">>> Stas Loaded") end
end

function saveStats(user)
	local f = openfile("chatstats.dat", "w+")
	assert(f, "chatstats.dat")
	write(f, "return {\n")
	for nick, table in stats do
		write(f, "\t"..format("[%q]", nick).." = { "..table[1], ", "..table[2]..", "..table[3]..", "..table[4].." },\n")
	end write(f, "}") closefile(f)
	if user then user:SendData(">>> Stats Saved") end
end

function clearStats(user)
	stats = {}
	if user then user:SendData(">>> Stats cleared") end
end

function sortStats(id)
	local index = {n=0}
	foreach(stats, function(nick, tmp) tinsert(%index, nick) end)
	local f = function(x, y) return stats[x][%id] > stats[y][%id] end
	sort(index, f) return index
end

function updStats(nick, str)
	local tmp = stats[nick] or {0,0,0,0}
	tmp[1], tmp[2], tmp[3], tmp[4] = tmp[1]+1, tmp[2]+strlen(str), tmp[3]+cntargs(str, "(%a+)"), tmp[4]+cntsmilies(str)
	stats[nick] = tmp
end

function cntargs(str, rule) 
	local s, n = gsub(str, rule, "") 
	return n
end

function cntsmilies(str) 
	return cntargs(str, "(["..eyes.."]["..nose.."]?["..mouth.."])") + cntargs(str, "(["..mouth.."]["..nose.."]?["..eyes.."])")
end

And i also got a program for multichat...
That program, requiers that it is reged as op...
So the script think it is a Op user and not a "bot"
So, is it possibole to add to the script that it should not count that nick?
The name of the multichat is multi

 
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

Hi,

Try this...

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, str = strfind(data, "^%b<> (.*)%|$")
		local s, e, cmd, args = strfind(str, "^([%!%?]%a+)%s*(.*)$")
		if s then
			cmd = strlower(cmd)
			if cmd == "?mystats" then cmdStats(user, user.sName)
			elseif cmd == "?userstats" then cmdStats(user, args)
			elseif cmd == "?stats" then cmdTopStats(user, args)
			elseif cmd == "!savestats" and (user.iProfile == 0) then saveStats(user)
			elseif cmd == "!loadstats" and (user.iProfile == 0)  then loadStats(user)
			elseif cmd == "!clearstats" and (user.iProfile == 0)  then clearStats(user)
			else return end return 1
		elseif (strsub(data, 1, 6) ~= "

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

Thanks, works great
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

QuoteOriginally posted by nErBoS
Hi,

Try this...

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, str = strfind(data, "^%b<> (.*)%|$")
		local s, e, cmd, args = strfind(str, "^([%!%?]%a+)%s*(.*)$")
		if s then
			cmd = strlower(cmd)
			if cmd == "?mystats" then cmdStats(user, user.sName)
			elseif cmd == "?userstats" then cmdStats(user, args)
			elseif cmd == "?stats" then cmdTopStats(user, args)
			elseif cmd == "!savestats" and (user.iProfile == 0) then saveStats(user)
			elseif cmd == "!loadstats" and (user.iProfile == 0)  then loadStats(user)
			elseif cmd == "!clearstats" and (user.iProfile == 0)  then clearStats(user)
			else return end return 1
		elseif (strsub(data, 1, 6) ~= "

Best regards, nErBoS

Back at this again.. =)

Have some probs with adding a second nick

      elseif (strsub(data, 1, 6) ~= "      elseif (strsub(data, 1, 7) ~= "
If i write like that nobody get counted....
Seems pointless to have a chat stats script of it dont count any thing ;p
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

#4
Hi,

Try this...

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, str = strfind(data, "^%b<> (.*)%|$")
		local s, e, cmd, args = strfind(str, "^([%!%?]%a+)%s*(.*)$")
		if s then
			cmd = strlower(cmd)
			if cmd == "?mystats" then cmdStats(user, user.sName)
			elseif cmd == "?userstats" then cmdStats(user, args)
			elseif cmd == "?stats" then cmdTopStats(user, args)
			elseif cmd == "!savestats" and (user.iProfile == 0) then saveStats(user)
			elseif cmd == "!loadstats" and (user.iProfile == 0)  then loadStats(user)
			elseif cmd == "!clearstats" and (user.iProfile == 0)  then clearStats(user)
			else return end return 1
		elseif (strsub(data, 1, 6) ~= "

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

Thanks
As always it worked =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

Hmm.. back to this again... i am helping a freind of mine... he has an other stats script...

His updatestats function look like this..
function DataArrival(user,data)
local tmp = strsub(data,1,1)
	if tmp == "<" then
		local s, e, str = strfind(data,"%b<> (.*)|")
		if not iscommand(str) then
			if (user.bOperator) then
				DoUpdOpStats(user,str)
			else
				DoUpdUserStats(user,str)
			end
		end
	end
instead of....
function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, str = strfind(data, "^%b<> (.*)%|$")
		local s, e, cmd, args = strfind(str, "^([%!%?]%a+)%s*(.*)$")
		if s then
			cmd = strlower(cmd)
			if cmd == "?mystats" then cmdStats(user, user.sName)
			elseif cmd == "?userstats" then cmdStats(user, args)
			elseif cmd == "?stats" then cmdTopStats(user, args)
			elseif cmd == "!savestats" and (user.iProfile == 0) then saveStats(user)
			elseif cmd == "!savestats" and (user.iProfile == 1)  then No(user) --//See function No
			elseif cmd == "!loadstats" and (user.iProfile == 0)  then loadStats(user)
			elseif cmd == "!loadstats" and (user.iProfile == 1)  then No(user)
			elseif cmd == "!clearstats" and (user.iProfile == 0)  then clearStats(user)
			elseif cmd == "!clearstats" and (user.iProfile == 1)  then No(user)
			else return end return 1
		elseif (strsub(data, 1, 7) ~= "<-=Fake" and strsub(data, 1, 7) ~= "

I tried with
if (user.bOperator) then
			if (strsub(data, 1, 7) ~= "<-=Fake") then --//Nick That dont counts
				DoUpdOpStats(user,str)
			else
				DoUpdUserStats(user,str)
But that made it ignore all users... i have tried other things to.. but it always something wrong... so can anybody make it work?

it should ignore all nicks that starts with -=Fake
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

#7
Hi,

The condition seems wrong, try this...

if (user.bOperator) then
	if (strsub(data, 1, 7) ~= "<-=Fake") then --//Nick That dont counts
		DoUpdOpStats(user,str)
	end
else
	DoUpdUserStats(user,str)
end

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

Thank you.. That worked... never thought about that =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk