Can someone help whit my chatstats script
 

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

Can someone help whit my chatstats script

Started by Habatsu, 08 March, 2005, 13:42:38

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Habatsu

i?v got one broblemo,to use this script whit the new ptokax and robo 10,,can someone help me to config this script so it can use whit new ptokax? here is the script

------------------------------------------------------------------------
Bot = "?Agents??"

TimeSpanInMinutes = 10

-------------------
-- Main function --
-------------------

function Main()

ChatOpStat={}
ChatUserStat={}

frmHub:RegBot(Bot)

tabConfig = parseINI("Stats/Bigstats.ini")
tabOpStats = parseINI("Stats/OpStats.ini")
tabUserStats = parseINI("Stats/UserStats.ini")
cfgStats = getsection(tabConfig,"stats")
InitTable ("Stats/OpStats.ini",tabOpStats,ChatOpStat)
InitTable ("Stats/UserStats.ini",tabUserStats,ChatUserStat)
smEyes = getkey(cfgStats, "eyes")
smNose = getkey(cfgStats, "nose")
smMouth = getkey(cfgStats, "mouth")
SetTimer(TimeSpanInMinutes*60000)
StartTimer()

end

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

   if (strsub(data,1,1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind( data,"%b<>%s+(%S+)" )
         if (cmd=="?stats")then
            pm = 0
            ShowTop15(user)

         elseif (cmd=="!helps")then
            if user.bOperator then
               ShowHelpStats(user)
               returndata = 1
            end
         end
   end

   if(strsub(data,1,4) == "$To:") then
      data=strsub(data,1,strlen(data)-1)
      s,e,whoTo = strfind(data,"$To:%s+(%S+)")
      if (whoTo == Bot) then
         s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
         if (user.bOperator) then
            if (cmd=="!helps")then
               ShowHelpStats(user)

            elseif (cmd=="!savestats") then
               SaveStats(user)

            elseif (cmd=="!loadstats") then
               LoadStats(user)

            elseif (cmd=="!clearstats") then
               Reset(user)

            elseif (cmd=="?mystats") then
               ShowYourStats(user,cmd,args)

            elseif (cmd=="?stats")then
               pm = 1
               ShowTop15(user)

            elseif (cmd=="?userstats") then
               s,e,cmd,userName= strfind(data,"%b<>%s+(%S+)%s+(.+)")
               if not userName then
                  user:SendPM(Bot,"***Wrong synthax: ?userstats ")
               else
                  ShowUserStats(user,cmd,userName)
               end
            end
         end
      end
   end
end

--------- Update Chat Stats ---------

function DoUpdUserStats(user, str)
   local table = getitem(tabUserStats, user.sName)
   if not table then table = mkUserStats(user) end
   local stats = getvalue(table.tItems, "stats")
   local s, e, chars, words, smilies = strfind(stats, "(%d+)|(%d+)|(%d+)")

   chars = tonumber(chars)+strlen(str)
   words = tonumber(words)+cntargs(str, "(%a+)", 2)
   smilies = tonumber(smilies)+cntsmilies(str)

   ChatUserStat[user.sName]=chars

   putvalue(table.tItems, "stats", chars.."|"..words.."|"..smilies)
end

function DoUpdOpStats(user, str)
   local table = getitem(tabOpStats, user.sName)
   if not table then table = mkOpStats(user) end
   local stats = getvalue(table.tItems, "stats")
   local s, e, chars, words, smilies = strfind(stats, "(%d+)|(%d+)|(%d+)")

   chars = tonumber(chars)+strlen(str)
   words = tonumber(words)+cntargs(str, "(%a+)", 2)
   smilies = tonumber(smilies)+cntsmilies(str)

   ChatOpStat[user.sName]=chars

   putvalue(table.tItems, "stats", chars.."|"..words.."|"..smilies)
end

--------- Show Chat Stats Commands ---------

function ShowHelpStats(user)
   user:SendPM(Bot,"\r\n\===============================================\r\nUsers Commands in main chat:\r\n????????????????????????\r\n?stats\t\t- Show the Top 15 Chaters, and the stats user's\r\n\r\nOps Commands in pm for the stats:\r\n????????????????????????????\r\n?stats\t\t- Show the Top 15 Chaters and the stats user's\r\n?userstats \t- Show stats user's\r\n?mystats\t\t- Show ur current stats\r\n!loadstats\t- Load stats\r\n!savestats\t- Saves stats\r\n!clearstats\t- All stats initialized\r\n!helps\t\t- This help again\r\n===============================================")
end

--------- Load Chat Stats ---------

function LoadStats(user)
   tabConfig = parseINI("Stats/Bigstats.ini")
   tabOpStats = parseINI("Stats/OpStats.ini")
   tabUserStats = parseINI("Stats/UserStats.ini")
   cfgStats = getsection(tabConfig,"stats")
   InitTable ("Stats/OpStats.ini",tabOpStats,ChatOpStat)
   InitTable ("Stats/UserStats.ini",tabUserStats,ChatUserStat)
   smEyes = getkey(cfgStats, "eyes")
   smNose = getkey(cfgStats, "nose")
   smMouth = getkey(cfgStats, "mouth")
   user:SendPM(Bot,"Chatstat has been successfully loaded ...")
end

--------- Reset Chat Stats ---------

function Reset(user)
   ChatOpStat={}
   ChatUserStat={}
   remove("Stats/OpStats.ini")
   local handle=openfile("Stats/OpStats.ini","a")
   write(handle,"\n")
   closefile(handle)
   remove("Stats/UserStats.ini")
   local handle=openfile("Stats/UserStats.ini","a")
   write(handle,"\n")
   closefile(handle)
   tabConfig = parseINI("Stats/Bigstats.ini")
   tabOpStats = parseINI("Stats/OpStats.ini")
   tabUserStats = parseINI("Stats/UserStats.ini")
   user:SendPM(Bot,"Chat-Stats initialized!")
end

--------- Save Chat Stats ---------

function SaveStats(user)
   writeINI("Stats/OpStats.ini",tabOpStats)
   writeINI("Stats/UserStats.ini",tabUserStats)
   user:SendPM(Bot,"Chatstat has been successfully saved ...")
end

--------- Your Chat Stats ---------

function ShowYourStats(user, cmd, args)
   local table = getitem(tabOpStats, user.sName)
   if not table then table = mkOpStats(user, "") end
   local stats = getkey(table, "stats")
   local s, e, chars, words, smilies = strfind(stats, "(%d+)|(%d+)|(%d+)", 1)
   user:SendPM(Bot,user.sName.." "..chars.." characters "..words.." words ".. smilies.." smilies")
end

--------- User Chat Stats ---------

function ShowUserStats(user, cmd, userName)
   local table = getitem(tabUserStats, userName)
   UserError=0
   OpError=0
   if not table then
      UserError=1
   else
      local stats = getkey(table, "stats")
      local s, e, chars, words, smilies = strfind(stats, "(%d+)|(%d+)|(%d+)", 1)
      user:SendPM(Bot,userName.." "..chars.." characters "..words.." words ".. smilies.." smilies")
   end
   local table = getitem(tabOpStats, userName)
   if not table then
      OpError=1
   else
      local stats = getkey(table, "stats")
      local s, e, chars, words, smilies = strfind(stats, "(%d+)|(%d+)|(%d+)", 1)
      user:SendPM(Bot,userName.." "..chars.." characters "..words.." words ".. smilies.." smilies")
   end
   if UserError==1 and OpError==1 then
      user:SendPM(Bot,userName.." is not in my stats file...")
   end
end

--------- Show Top 15 Chatters ---------

function ShowTop15(user)

   local user1, userkey1
   local user2, userkey2
   local user3, userkey3
   local user4, userkey4
   local user5, userkey5
   local user6, userkey6
   local user7, userkey7
   local user8, userkey8
   local user9, userkey9
   local user10, userkey10

   local op1, opkey1
   local op2, opkey2
   local op3, opkey3
   local op4, opkey4
   local op5, opkey5

   userkey1=0
   userkey2=0
   userkey3=0
   userkey4=0
   userkey5=0
   userkey6=0
   userkey7=0
   userkey8=0
   userkey9=0
   userkey10=0

   opkey1=0
   opkey2=0
   opkey3=0
   opkey4=0
   opkey5=0

   for a,b in ChatOpStat do
      if (ChatOpStat[a]>opkey1) then
         op5=op4
         opkey5=opkey4
         op4=op3
         opkey4=opkey3
         op3=op2
         opkey3=opkey2
         op2=op1
         opkey2=opkey1
         op1=a
         opkey1=ChatOpStat[a]
      else
         if (ChatOpStat[a]>opkey2) then
            op5=op4
            opkey5=opkey4
            op4=op3
            opkey4=opkey3
            op3=op2
            opkey3=opkey2
            op2=a
            opkey2=ChatOpStat[a]
         else
            if (ChatOpStat[a]>opkey3) then
               op5=op4
               opkey5=opkey4
               op4=op3
               opkey4=opkey3
               op3=a
               opkey3=ChatOpStat[a]
            else
               if (ChatOpStat[a]>opkey4) then
                  op5=op4
                  opkey5=opkey4
                  op4=a
                  opkey4=ChatOpStat[a]
               else
                  if (ChatOpStat[a]>opkey5) then
                     op5=a
                     opkey5=ChatOpStat[a]
                  end
               end
            end
         end
      end
   end

   opstats1 = ""
   opstats2 = ""
   opstats3 = ""
   opstats4 = ""
   opstats5 = ""

   if (op1~=nil) then
      opstats1 = ("* 1.\t"..ChatOpStat[op1]..":\t"..op1)
   end

   if (op2~=nil) then
      opstats2 = ("\r\n* 2.\t"..ChatOpStat[op2]..":\t"..op2)
   end

   if (op3~=nil) then
      opstats3 = ("\r\n* 3.\t"..ChatOpStat[op3]..":\t"..op3)
   end

   if (op4~=nil) then
      opstats4 = ("\r\n* 4.\t"..ChatOpStat[op4]..":\t"..op4)
   end

   if (op5~=nil) then
      opstats5 = ("\r\n* 5.\t"..ChatOpStat[op5]..":\t"..op5)
   end

   opstats = opstats1..opstats2..opstats3..opstats4..opstats5
 first part of script
:]  haba :]

SMF spam blocked by CleanTalk