looking for a script (logger 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

looking for a script (logger stats)

Started by xjr13sp, 25 January, 2004, 00:35:15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xjr13sp

I am looking for a script which shall give me the Chat Statistics, but the Chat Statistics of the users who speaks least! A Chat Stats inverted!  :D

Is it possible for a great Developer Man (I'm thinking about Chilla  :] ) to write this kind of script for me?

[NL]Pur

i think in almost most hubs the stats are going too look the same.  10 ppl with 0 chars

c h i l l a

#2
funny request but since I wanted to do something , like that anyways once, I decided to do it know :)

it also changeable , cause I'd prefer it the other way around ;).

--Chat stats by chill for xjr13sp.
--Serialisation by RabidWombat


cmd1 = "+showstats"	-- Main Command

Max1 = 10		-- How Many top chatters are shown of each genre.

howToSort = 1	-- Stands for the sorting either 1= least first, 2 = highest first.

StatsFile = "ChatStats.txt"
StatsFolder = "txt"
ChatStats = {}
dofile(StatsFolder.."/"..StatsFile)

chatEmotions = {
	[":)"] = 1,
	[":-)"] = 1,
	[":("] = 1,
	[":-("] = 1,
	[";)"] = 1,
	[";-)"] = 1,
	[":-p"] = 1,
	[":p"] = 1,
	[":D"] = 1,
	[":-D"] = 1,
}


function Main()
	SetTimer(1000*60*5)
	StartTimer()
end

function OnTimer()
	WriteTable(ChatStats,"ChatStats",StatsFile)
end

function DataArrival(curUser,data)
	if strsub(data,1,1) == "<" then
		if not ChatStats[curUser.sName] then
			ChatStats[curUser.sName] = {}
			ChatStats[curUser.sName].words = 0
			ChatStats[curUser.sName].chars = 0
			ChatStats[curUser.sName].emotions = 0
		end
		data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)
		curName = curUser.sName
		gsub(data,"(%S+)",function(w)
			ChatStats[curName].chars = ChatStats[curName].chars + strlen(w)
			if chatEmotions[w] then
				ChatStats[curName].emotions = ChatStats[curName].emotions + 1
			else
				ChatStats[curName].words = ChatStats[curName].words + 1
			end
		end)
		curName = nil

		local _,_,word1 = strfind(data,"^(%S+)")

		if word1 and STATSFUNC[word1] then
			SendToAll(STATSFUNC[word1]())
		end

	end
end

---------------------------------------------------------------------------------------

--	TABLE FUNCTIONS

---------------------------------------------------------------------------------------
STATSFUNC = {
	[cmd1] = function()
		TCopy = {}

		for i,v in ChatStats do

			tinsert(TCopy,{i,v})

		end

		local msg = "-----  Current Chat Stats ------\r\n\r\n\tTop "..Max1.." Char Stats\r\n\r\n"
		if howToSort == 1 then
			sort(TCopy,function(a,b) return(a[2].chars < b[2].chars) end)
		else
			sort(TCopy,function(a,b) return(a[2].chars > b[2].chars) end)
		end
		for i = 1,Max1 do
			if TCopy[i] then
				msg = msg.."\t# "..i.."  -  "..TCopy[i][1]..", with "..TCopy[i][2].chars.." chars.\r\n"
			end
		end

		if howToSort == 1 then
			sort(TCopy,function(a,b) return(a[2].words < b[2].words) end)
		else
			sort(TCopy,function(a,b) return(a[2].words > b[2].words) end)
		end
		msg = msg.."\r\n\tTop "..Max1.." Word Stats\r\n\r\n"
		for i = 1,Max1 do
			if TCopy[i] then
				msg = msg.."\t# "..i.."  -  "..TCopy[i][1]..", with "..TCopy[i][2].words.." words.\r\n"
			end
		end

		if howToSort == 1 then
			sort(TCopy,function(a,b) return(a[2].emotions < b[2].emotions) end)
		else
			sort(TCopy,function(a,b) return(a[2].emotions > b[2].emotions) end)
		end
		msg = msg.."\r\n\tTop "..Max1.." Emotion Stats\r\n\r\n"
		for i = 1,Max1 do
			if TCopy[i] then
				msg = msg.."\t# "..i.."  -  "..TCopy[i][1]..", with "..TCopy[i][2].emotions.." emotions.\r\n"
			end
		end

		return(msg)
	end,
}

---------------------------------------------------------------------------------------

--	Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
	local handle = openfile(StatsFolder.."/"..file,"w")
	Serialize(table,tablename,handle)
  	closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	write(hFile,sTab..sTableName.." = {\n");
	for key,value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
		if(type(value) == "table") then
			Serialize(value,sKey,hFile,sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile,sTab.."\t"..sKey.." = "..sValue);
		end
		write(hFile,",\n");
	end
	write(hFile,sTab.."}");
end

xjr13sp

You are so marvellous Chilla  :D
I'll test your script this evening and keep you informed about results....

Many thanks !

SMF spam blocked by CleanTalk