PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: miku82 on 04 May, 2005, 08:06:10

Title: isit posible to make mainchat recordbot
Post by: miku82 on 04 May, 2005, 08:06:10
witsh counts  ho talkin  moust on main chat 8)
Title:
Post by: Dessamator on 04 May, 2005, 09:45:46
it already exists, search for chatstats !!
Title:
Post by: miku82 on 05 May, 2005, 18:27:14
QuoteOriginally posted by Dessamator
it already exists, search for chatstats !!

wath comadn it use  i cant get  it to work
 ?(
Title:
Post by: Dessamator on 05 May, 2005, 20:00:30
these are the commands :
Quote!mychatstat
!topchatters
!delchatter
!clearchatstats
Title:
Post by: miku82 on 06 May, 2005, 06:37:34
QuoteOriginally posted by Dessamator
these are the commands :
Quote!mychatstat
!topchatters
!delchatter
!clearchatstats


dam  :rolleyes: it woun?t work
Title:
Post by: Dessamator on 06 May, 2005, 11:08:11
ok then just, show me what chatstats u are using, and we'll see !!
Title:
Post by: miku82 on 06 May, 2005, 11:57:53
QuoteOriginally posted by Dessamator
ok then just, show me what chatstats u are using, and we'll see !!


botname = "ChatStat"


ChatStat={}

ChatStatCounter=0


function Main()

frmHub:RegBot(botname)

end


function reset()

ChatStat={}

ChatStatCounter=0

end


function save_stats(user)

    remove("chatstat.dat")

    local handle=openfile("chatstat.dat","a")

    write(handle,ChatStatCounter.."\n")

    for a,b in ChatStat do

        write(handle,a.."?"..b.."\n")

    end

    closefile(handle)

    user:SendPM(botname,"Chatstat has been successfully saved ...")


end


function load_stats(user)

   local handle=openfile("chatstat.dat","r")

    ChatStatCounter=read(handle)

    Poll={}

    while 1 do

      local line = read(handle)

       if line == nil then break

      else

         x,y,a=strfind(line,"([^?]*)")

         x,y,b=strfind(line,"([^?]*)$")

         SendToAll("DEBUG",a..""..b)

         ChatStat[a]=tonumber(b)   

      end

   end

    closefile(handle)


    user:SendPM(botname,"Chatstat has been successfully loaded ...")


end




function show_top5(userobj)

local index1, key1

local index2, key2

local index3, key3

local index4, key4

local index5, key5

key1=0

key2=0

key3=0

key4=0

key5=0


for a,b in ChatStat do

if (ChatStat[a]>key1) then

index5=index4

key5=key4

index4=index3

key4=key3

index3=index2

key3=key2

index2=index1

key2=key1

index1=a

key1=ChatStat[a]

else

if (ChatStat[a]>key2) then

index5=index4

key5=key4

index4=index3

key4=key3

index3=index2

key3=key2

index2=a

key2=ChatStat[a]

else

if (ChatStat[a]>key3) then

index5=index4

key5=key4

index4=index3

key4=key3

index3=a

key3=ChatStat[a]

else

if (ChatStat[a]>key4) then

index5=index4

key5=key4

index4=a

key4=ChatStat[a]

else

if (ChatStat[a]>key5) then

index5=a

key5=ChatStat[a]

end

end

end

end

end

end


userobj:SendPM(botname,"Top 5 poster in this hub : \r\n")

userobj:SendPM(botname,"* Nr.   Posts : Name..........")

if (index1~=nil) then

userobj:SendPM(botname,"* 1.     "..ChatStat[index1].."  :   "..index1)

end

if (index2~=nil) then

userobj:SendPM(botname,"* 2.     "..ChatStat[index2].."  :   "..index2)

end


if (index3~=nil) then

userobj:SendPM(botname,"* 3.     "..ChatStat[index3].."  :   "..index3)

end


if (index4~=nil) then

userobj:SendPM(botname,"* 4.     "..ChatStat[index4].."  :   "..index4)

end


if (index5~=nil) then

userobj:SendPM(botname,"* 5.     "..ChatStat[index5].." :   "..index5)

end

end


function GetCommand(data)

   s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

   return cmd

end


function DataArrival(user, data)

if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then


if (ChatStat[user.sName] == nil) then

ChatStat[user.sName]=1

else

ChatStat[user.sName]=ChatStat[user.sName]+1

end

ChatStatCounter=ChatStatCounter+1

end

if(strsub(data, 1, 4) == "$To:") then

s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

cmd=strsub(cmd,1,strlen(cmd)-1)


if (whoTo == botname) then

if (cmd=="+showstat")then

show_top5(user)

end

if (user.bOperator) then

if (cmd=="+savestat")then

save_stats(user)

end

if (cmd=="+loadstat")then

load_stats(user)

end

end



end

end


end


i tryid  thous  you gave to mi  and thous   cmd text from the script
Title:
Post by: Dessamator on 06 May, 2005, 12:10:10
the commands are +showstat +loadstat and +savestat
Title:
Post by: miku82 on 06 May, 2005, 12:14:36
QuoteOriginally posted by Dessamator
the commands are +showstat +loadstat and +savestat


i hav tryid  thous  bud thei dosen?t  work
Title:
Post by: Dessamator on 06 May, 2005, 12:27:29
what ptokax version are u using?, and if ur using the new ptokax , search for the script in the lua5 section, and the commands are the first ones i posted !
Title:
Post by: miku82 on 06 May, 2005, 12:29:03
QuoteOriginally posted by Dessamator
what ptokax version are u using?, and if ur using the new ptokax , search for the script in the lua5 section, and the commands are the first ones i posted !

thanx buddy