alcoholic top 10
 

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

alcoholic top 10

Started by plop, 10 May, 2004, 22:13:46

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plop

simple useless script i made.
it counts how much ppl say the word bier and can show a top 10.
it's in dutch, so translate it yourself if needed.
Alcohol = {}
Bot = "alcoholic"
timer = date("%H")

function CountBier(user, data)
   data = strlower(data)
   _, bier = gsub(data, "bier", "bier")
   if bier then
      if Alcohol[user.sName] then
         Alcohol[user.sName] = Alcohol[user.sName] + bier
      else
         Alcohol[user.sName] = bier
      end
   end
end

function ShowBier()
   local Tmp = {}
   local line
   local c,d = 0,0
   for a,b in Alcohol do
      if Tmp[b] then
         Tmp[b]=(Tmp[b].."/"..a)
      else
         Tmp[b]=a
      end
      if b > c then
         c = b
      end
   end
   if c ~= 0 then
      for i=c,1, -1 do
         if line == nil then
            line = "\r\n\r\n---------------------------------------------------------------\r\n"
            line = line.."   De alcoholist top 10\r\n"
            line = line.."---------------------------------------------------------------\r\n"
         end
         if Tmp[i] then
            line = line.."   "..i.." biertjes\t"..Tmp[i]..".\r\n"
            d = d + 1
            if d == 10 then
               break
            end
         end
      end
      line = line.."---------------------------------------------------------------\r\n"
   else
      line = "no stats yet"
   end
   Tmp = nil
   return line
end

function Save()
   writeto("alcoholist.lst")
   for a,b in Alcohol do
      write(a.."$"..b.."\r\n")
   end
   writeto()
end

function Load()
   if readfrom("alcoholist.lst") then
      readfrom("alcoholist.lst")
      while 1 do
         local kicks = read()
         if kicks ==  nil then
            break
         end
         s,e,name,amount = strfind(kicks, "(.+)$(.+)")
         Alcohol[name]=tonumber(amount)
      end
      readfrom()
   end
end

function DataArrival(user, data)
   if timer ~= date("%H") then
      Save()
   end  
   if(strsub(data, 1, 4) == "$To:") then
      data=strsub(data,1,strlen(data)-1) 
      CountBier(user, data)
   elseif( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
      if cmd == "!bier" then
         user:SendData(Bot, ShowBier().."|")
         return 1
      else
         CountBier(user, data)
      end
   end
end

function Main() 
   Load()
end
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

bastya_elvtars

Not that bad one... psychologists would surely love it, because this can be part of a DC survey  :D
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk