pm counter
 

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

pm counter

Started by Sporos, 14 February, 2009, 16:51:31

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sporos

------ Code by Daywalker? ------


--// PM Counter by Daywalker?

--// Hub Settings
local Bot = "AndAnotherOne" --// botname
local Description = "ICountPmsForAliving" --// .
local Email = "wtfamidoinghere@hotmail.com" --// .
local Menu = "PM?" --// Menu name for RC

local Owner = "Sporos" --// replace with your own name

LPC = "LogPmCount.txt"
local Path = string.gsub(Core.GetPtokaXPath().."scripts/","/","\\")
LPC = Path..LPC

PMC = {}
local cPM = 0

OnStartup = function()
	Core.RegBot(Bot, Description, Email, true)
	if loadfile(LPC) then dofile(LPC) else Save_File(LPC, PMC, "PMC") end
	Pfx = SetMan.GetString(29):sub(1,1)
	collectgarbage("collect")
end

UserConnected = function(user)				-- Is called when user finish login sequence.
	EnterCmd(user)
end

OpConnected = UserConnected
RegConnected = UserConnected

ChatArrival = function(user, data)
	local s,e,cmd = string.find( data, "%b<> %p(%w+)")
	if cmd and tCom[cmd] then
		local _,_,_,lev = tCom[cmd]()
		if lev[user.iProfile] and lev[user.iProfile] == 1 then
			local message = tCom[cmd](user,data,pre,cmd)
			Core.SendToNick(user.sNick,"<"..Bot.."> "..message.."|")
			collectgarbage("collect")
			return true
		end
	end
end

ToArrival = function(user,data)
	local s,e,to = string.find(data,"^$To: (%S+) From:")
	local s,e,cmd = string.find( data, "%b<> %p(%w+)")
	if cmd and tCom[cmd] then
		local _,_,_,lev = tCom[cmd]()
		if lev[user.iProfile] and lev[user.iProfile] == 1 then
			if to and to == Bot then
				Core.SendPmToNick(user.sNick,Bot,tCom[cmd](user,data,pre,cmd).."|")
			end
			collectgarbage("collect")
			return true
		end
	end
	if to then
		cPM = cPM + 1
		table.insert(PMC,{user.sNick,cPM})
		Save_File(LPC, PMC, "PMC")
	end
end

tCom = {
	shpm = function(user,data)
		if user then
			local x
			local reply = "\r\n\r\n\tTotal PM Calls\r\n\r\n\tList\tNick\t\tTotal\r\n"..
			"\t"..string.rep("?",40).."\r\n"
			for i,v in pairs(PMC) do
				x = 1
				reply = reply.."\t["..i.."]\t"..string.format("%-15s",v[1]).."\t"..v[2].."\r\n"
			end
			if x then
				return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
			else
				return "Sorry "..user.sNick.." this command is disabled for your profile."
			end
		else
			return "PM Count ", "Show All","", -- adjust this to your needs
			-- Adjust To Your Profiles
			{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
		end
	end,
}

EnterCmd = function(user)
	local x
	for i,v in pairs(tCom) do
		local menu,desc,arg,lev = tCom[i]()
		if lev[user.iProfile] and lev[user.iProfile] == 1 then
			x = 1
			Core.SendToNick(user.sNick,"$UserCommand 1 3 "..Menu.."\\"..menu.."\\"..
			desc.."$<%[mynick]> "..Pfx..i..arg.."&#124;|")
		end
	end
	if x then
		local Prof
		if user.iProfile ~= -1 then
			Prof = ProfMan.GetProfile(user.iProfile).sProfileName
		else
			Prof = "Unregistered User"
		end
	end
	collectgarbage("collect")
end

OnError = function(sErrorMsg)				-- Is called when error was found in script or whatever.
	Core.SendToNick(Owner,"<"..Bot.."> "..sErrorMsg)
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n" )
	for key, value in pairs(tTable) do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
		if(type(value) == "table") then
			Save_Serialize(value, sKey, hFile, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			hFile:write( sTab.."\t"..sKey.." = "..sValue)
		end
		hFile:write( ",\n")
	end
	hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
	local hFile = io.open (file , "wb")
	Save_Serialize(table, tablename, hFile)
	hFile:close()
end


------ End of Code ------




wonder if someone could help me with this script..... its working but i get this:



   Total PM Calls

   List   Nick      Total
   ????????????????????????????????????????
   [1]   Lost_in_Space     1
   [2]   Lost_in_Space     2
   [3]   Lost_in_Space     3
   [4]   Sporos            4
   [5]   Sporos            5
   [6]   Sporos            6
   [7]   Sporos            7
   [8]   Sporos            8

   ????????????????????????????????????????

But i want a summary of users pm and no a huge list with same nick like this one ...

? Top 100 private message talkers
---------------------------------------------------------------------------------------------------------
? Sporos         40 PM(s)      (after 15:105:41)


if anyone can help would be nice Thanks in advance :D


SMF spam blocked by CleanTalk