for Bottledhate: Stabbot
 

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

for Bottledhate: Stabbot

Started by Jorgo, 28 February, 2005, 12:49:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jorgo

Hi :-)
This is fun of the funscripts without which my hub just wouldn't be the same  8)

Now, I saw in the header of the script that the original was actually written in lua5 and then converted back to lua4 by you.

Any chance we could get the original updated  :P  version?

Thanks in advance!

bastya_elvtars

BH has finished scripting. :(

Post the script and I will see what I can do.
Everything could have been anything else and it would have just as much meaning.

Jorgo

#2
Thanks, man!

sFileName = "data/StabBot/StabTable.dat" --//save file for data. path can be relative to script dir: "data/StabTable.dat"  or absolute: "c:\\path\\to\\file.bleh"
FloodTime = 5 --//(default)(seconds). limits users to 1 stab every x seconds. 0 = off
StatsInMain = 0 --// the bots default setting with no stats. 1 = on 0 = off (it looks the same either way.. but, only you see it if it is set to off..0)
PreFixs = {["!"] = 1, ["+"]=1, ["?"]=1,["*"]=1,["#"]=1,["^"]=1,["?"]=1,["?"]=1,["~"]=1} --//the allowed prefixes used before the Cmds..(i hate only being able to use 1)
Cmd1 = "stab" --/the cmd to invoke the stab.
Cmd2 = "deaths" --//the cmd to invoke the total count.
Cmd3 = "stabhappy" --//the cmd to invoke the total usage.(how many times each user has used the command)
Cmd4 = "mystabs" --//the cmd to invoke personal stats. (who you have stabbed and how many times)
Cmd5 = "tgglBot" --//(ops or better only)turn the the bot on or off.
Cmd6 = "tgglMain"  --//(ops or better only)turn the main chat stats on or off.
Cmd7 = "shelp" --// tells users what te commands are... + ops what Cmd5, Cmd6, Cmd8, & Cmd9 are...
Cmd8 = "clrstabs" --//ops may clear any. users only their own. (personal usage data only.. not death count or total usage)
Cmd9 = "setflood" --//(ops or better only)the time in seconds. limits users to 1 stab every x seconds.
-DON'T MESS AORUND BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!-/////////////////////////////////////////////////////////////////////////////////////////////--
-
local f,e = openfile( sFileName, "a+" ) --//Error handle.. makes sure save file and dir exist...
if f then
   write(f,"")
   closefile(f)
else --//and if it doesn't.. make the path, then the file.
   local _,_,path = strfind(sFileName, "(.+[/_\\]).+$") 
   if path ~= nil then
      execute("mkdir ".."\""..gsub(path, "/", "\\").."\"")
   end
   f,e = openfile( sFileName, "a+" )
   if f then
      write(f,"" ) 
      closefile(f) --// file and path did not exist.. now they do.
   else
   sFileName = "_stabtable.dat"--//this is only if the path provided is invalid to winblows. defaults to a file in the scripts dir.
   end
end
-
sTable={["Settings"]={["Status"]=1,["StatsInMain"]=StatsInMain, ["FldScnds"] = FloodTime},["gTotal"]=0,["tUse"]={},["uUse"]={}}
cmdS={[Cmd1]=1,[Cmd2]=1,[Cmd3]=1,[Cmd4]=1, [Cmd5]=1,[Cmd6]=1,[Cmd7]=1,[Cmd8]=1,[Cmd9]=1}
oUsers = {}
dofile(sFileName)
dofile("_StabAnswers.txt")
-
function NewUserConnected(user)--//used for the randmNames function, and flood control.
oUsers[user.sName] = 1
end
function UserDisconnected(user)
oUsers[user.sName] = nil
end
OpDisconnected = UserDisconnected
OpConnected = NewUserConnected
-
function DataArrival(user, data) 
   if strsub(data, 1, 1) == "<" then
      local _,_,cmd=strfind(data, "%b<>%s+(%S+).+")  
      if not PreFixs[strsub( cmd, 1, 1)] then return end --//(trying to speed things up.. dunno if it helps)
      cmd = strsub(cmd,2)
      if not cmdS[cmd] then return end --//(trying to speed things up.. dunno if it helps)
      local userN = user.sName
      local _,_,junk=strfind(data, "%b<>%s+%S+%s+(.+)|")
      local requestString = ""
      if cmd == Cmd1 then --// list for the cmd to invoke the stab.
         if sTable["Settings"]["Status"] == 0 then return end--//bot on?
         if not oUsers[userN] then oUsers[userN] = 1 end--//case we missed their log-in.
         if clock() - oUsers[userN] <= sTable["Settings"]["FldScnds"] then return 1 end--//flood protection.
         local answer,victim, rand = answer1[random(getn(answer1))], junk or randmName(), randmName()
         if strfind(victim, "%%") then victim = randmName() end--//the '%' sign fucks stuff up....
         answer = gsub( answer, "(%[stbr%])", userN )--swap the vars in the answer..
         answer = gsub( answer, "(%[stbd%])", victim ) 
         answer = gsub( answer, "(%[rnduser%])", rand )
         SendToAll( answer.."|" )
         sTable["gTotal"] = sTable["gTotal"] +1
         if sTable["tUse"][userN] then
            sTable["tUse"][userN] = sTable["tUse"][userN] + 1
         else
            sTable["tUse"][userN] = 1
         end
         if sTable["uUse"][userN] then
            if sTable["uUse"][userN][victim] then
               sTable["uUse"][userN][victim] = sTable["uUse"][userN][victim] + 1
            else
               sTable["uUse"][userN][victim] = 1
            end
         else
            sTable["uUse"][userN] = {}
            sTable["uUse"][userN][victim] = 1
         end         
         saveData() --//Save all data
         oUsers[userN] = clock()
-
      elseif cmd == Cmd2 then --//listen for the cmd to invoke the total count.
         if sTable["Settings"]["Status"] == 0 then return end--//bot on?
         if sTable["Settings"]["StatsInMain"] == 1 then
            SendToAll(" *** The death count is: "..sTable["gTotal"]..". ***|" )
         else
            user:SendData(" *** The death count is: "..sTable["gTotal"]..". ***|" )
            return 1
         end
-
      elseif cmd == Cmd3 then --//listen for the cmd to invoke the total usage.
         if sTable["Settings"]["Status"] == 0 then return end--//bot on?
         counting = 0            
         for key,value in sTable["tUse"] do
            counting = counting +1
            if counting < 5 then
               requestString = requestString..key.." = "..value.."            "
            else
               requestString = requestString..key.." = "..value.."\r\n"
               counting = 0
            end
         end
         if sTable["Settings"]["StatsInMain"] == 1 then
            SendToAll(" \r\n*** Stab Usage for the hub... (how many times each person used the command)***"..
               "\r\n_________________________________________________________________________\r\n"..requestString..
               "\r\n_________________________________________________________________________|" ) --//send pm to yhub bot via raw message dispay the stab count
         else
            user:SendData(" \r\n*** Stab Usage for the hub... (how many times each person used the command)***"..
               "\r\n_________________________________________________________________________\r\n"..requestString..
               "\r\n_________________________________________________________________________|" ) 
               return 1
         end
-
      elseif cmd == Cmd4  then --//listen for the cmd to invoke personal stats.
         if sTable["Settings"]["Status"] == 0 then return end--//bot on?
         local who = junk or userN
         if sTable["uUse"][who] then
            counting = 0            
            for key,value in sTable["uUse"][who] do
               counting = counting +1
               if counting < 5 then
                  requestString = requestString..key.." = "..value.."            "
               else
                  requestString = requestString..key.." = "..value.."\r\n"
                  counting = 0
               end
            end
            if sTable["Settings"]["StatsInMain"] == 1 then
               SendToAll(" \r\n***Personal Stab Usage for "..who.."... (how many times you stabbed that person)***"..
                  "\r\n_________________________________________________________________________\r\n"..requestString..
                  "\r\n_________________________________________________________________________|" ) 
            else
               user:SendData(" \r\n***Personal Stab Usage for "..who.."... (how many times you stabbed that person)***"..
                  "\r\n_________________________________________________________________________\r\n"..requestString..
                  "\r\n_________________________________________________________________________|" ) 
                  return 1
            end
         else
            if sTable["Settings"]["StatsInMain"] == 1 then
               SendToAll("No data for "..who..".|")
            else
               user:SendData("No data for "..who..".|")
               return 1
            end
         end
-
      elseif cmd == Cmd5 then--//Listen for Bot On/Off cmd
         if user.iProfile >=1 then return end--//ops only
         if sTable["Settings"]["Status"] == 1 then 
            sTable["Settings"]["Status"] = 0
            user:SendData("Bot Turned OFF|")
         else
            sTable["Settings"]["Status"] = 1
            user:SendData("Bot Turned ON|")
         end
         saveData() --//Save all data
         return 1
-         
      elseif cmd == Cmd6 then--//listen for the main chat stats on or off.
         if user.iProfile >=1 then return end--//ops only
         if sTable["Settings"]["StatsInMain"] == 1 then
            user:SendData("Stats In Main Turned OFF|")
            sTable["Settings"]["StatsInMain"] = 0
         else
            user:SendData("Stats In Main Turned ON|")
            sTable["Settings"]["StatsInMain"] = 1
         end
         saveData() --//Save all data
         return 1
-        
      elseif cmd == Cmd7 then--//listen for help cmd
         local prfxs =""
         for k,v in PreFixs do prfxs = prfxs..k.."  " end
         user:SendData("\r\nHelp for StabBot:\r\n\t"..
         "Availible prefixes for commands:  "..prfxs.."\r\n\t"..
         "User Commands:\r\n\t\t"..
         Cmd1.." [nick]\tStabs nick or random user if not provided.\r\n\t\t"..
         Cmd2.."\t\tShows the total count of how many times "..Cmd1.." has been used.\r\n\t\t"..
         Cmd3.."\tShows how many times each user has used "..Cmd1..".\r\n\t\t"..
         Cmd4.."\tShows who you have used "..Cmd1.." on, and how many times.\r\n\t\t"..
         Cmd8.."\t\tClears your personal usage data.\r\n|")
         if user.iProfile <= 1 then
            user:SendData("\r\nAdmin Help for StabBot:\r\n\t"..
            "Op Commands:\r\n\t\t"..
            Cmd5.."\t\tTurns StabBot ON or OFF\r\n\t\t"..
            Cmd6.."\tTurns Spaming of "..Cmd3.." and "..Cmd4.." in the main chat on or off.\r\n\t\t"..
            Cmd9.." <#>\tSets the flood time. # = seconds. Limits users to 1 stab every # seconds. 0 = off.\r\n\t\t"..
            Cmd8.." \tClears the personal usage data for user.\r\n|")
         end
-
      elseif cmd == Cmd8 then --//listen for clear stats cmd
         local who = junk or userN
         if user.iProfile >=2 then who = user.sName end
         if not sTable["uUse"][who] then
            user:SendData("There is no data for "..who..".|")
         else
            sTable["uUse"][who] = nil
            user:SendData("Personal data for "..who.." has been cleared.|") 
            saveData() --//Save all data
         end
         return 1
      elseif cmd == Cmd9 then --// listen for flood time cmd
         if user.iProfile >=1 then return end--//ops only
         _,_,junk=strfind(data, "%b<>%s+%S+%s+(%d+)|")
         if junk == nil then
            user:SendData("Error. Syntax: !"..Cmd8.." <#>    # = seconds. Limits users to 1 stab every # seconds. 0 = off|")
         else
            sTable["Settings"]["FldScnds"] = tonumber(junk)
            user:SendData("Flood time set to "..junk.." seconds.|")
            saveData() --//Save all data
         end
         return 1
      end
   end
end
-
function randmName()
   local n = 0
   for k,v in oUsers do n=n+1 end
   n = random( n ) 
   for k,v in oUsers do
      if n == 1 then 
         return k 
      end
      n = n - 1
   end
end
function saveData()
   local data = Serialize(sTable, "sTable", "")
   local f,e = openfile( sFileName, "w+" ) 
   if f then
     write(f, data )
     closefile(f)
   end
end
function Serialize(tTable, sTableName, sTab)
   sTab = sTab or "";
   sTmp = ""
   sTmp = sTmp..sTab..sTableName.."={"
   local tStart = 0
	for key, value in tTable do
      if tStart == 1 then
         sTmp = sTmp..",\r\n"
      else
         sTmp = sTmp.."\r\n"
         tStart = 1
      end
      local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
      if(type(value) == "table") then
         sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
      else
         local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
         sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
      end
   end
   sTmp = sTmp.."\r\n"..sTab.."}"
   return sTmp 
end

plop

the lua 5 version BH made was for BCDC++.

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 <----<<

Jorgo

Ok, this one is done - thanks Madman!

/virtually closes thread  :D

SMF spam blocked by CleanTalk