AscIIArtFiles
 

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

AscIIArtFiles

Started by SilvaO, 22 July, 2005, 01:21:31

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SilvaO

Hi!
can you conver to LUA 5

Quote-- ![AscIIArtBot]!? V:1.1 by [ES]latinmusic
-- Some improvements inside the code
-- Old AscII files have been retouched for better display
-- New cool art files have been added
-- To download the new ASCII files use the same link as before
-- Enjoy
botName = "![AscIIArtBot]!?"
DirArray = {}
TimerStatus = 0
CommandStatus = 1
file = "ArtList.txt"
ErrorMsg = "You do not have enough privileges to execute this command."
function Main()
   execute("dir AscIIArtFiles > ArtList.txt /B")
   MakeArray(curUser)
   local version = botName.." V:1.1 by [ES]latinmusic"
   SendToAll(botName, "Script restarted.\r\n  "..version..date(" launched at day: %d/%m/%Y. Local Hub Time: %X."))
   SendToAll(botName, "The 'AscII Art List File' have been generated.")
end
function DataArrival(curUser, data)
   if strsub(data, 1, 1) ~= "<" then return end
   local s, e, cmd, args = strfind(data, "^%b<> %-(%a+)%s*(.*)%|$")
   if not s then return end
   cmd = strlower(cmd)
   if cmd == "showart" then
      if CommandStatus == 1 then
         variable = DirArray[random(1,getn(DirArray))]
         local result = Show(TheFile)
         curUser:SendData(botName,result)
      else
         curUser:SendData(botName,"The command '-showart' is temporarily deactivated.")
      end
      return 1
   elseif cmd == "reloadart" then
      if (curUser.iProfile ~= 0) then curUser:SendData(botName,ErrorMsg) return 1 end
      execute("dir AscIIArtFiles > ArtList.txt /B")
      MakeArray(curUser)
      SendToAll(botName,"The 'AscII Art List File' have been updated.\r\n")
      return 1
   elseif cmd == "showhelp" then
      curUser:SendData(botName,"List of the commands available for "..botName.."\r\n\r\nCommands --> Description\r\n-reloadart --> Reload the AscII art files\r\n-startimer --> Start the timer\r\n-stoptimer --> Stop the timer\r\n-showart --> Display AscII art files ramdomly on user request\r\n-showhelp --> Display this help\r\n")
   elseif cmd == "startimer" then
      if not curUser.bOperator then curUser:SendData(botName,ErrorMsg) return 1 end
      if TimerStatus == 0 then
         local s,e,_,minutes = strfind( data, "%b<>%s+(%S+)%s+(%S+)%|$")
         if not s then curUser:SendData(botName,"Syntax: -startimer ") return 1 end
         TimerStatus = 1
         CommandStatus = 0
         SetTimer(minutes*60000)
         StartTimer()
         curUser:SendData(botName,"The 'Timer' function have been activated. First 'AscII Art' will be displayed in "..minutes.." minute(s) from now.")
         SendToAll(botName,"The command '-showart' have been temporarily deactivated.")
      else
         curUser:SendData(botName,"The 'Timer' function is already active.")
      end
      return 1
   elseif cmd == "stoptimer" then
      if not curUser.bOperator then curUser:SendData(botName,ErrorMsg) return 1 end
      if TimerStatus == 1 then
         TimerStatus = 0
         CommandStatus = 1
         StopTimer()
         curUser:SendData(botName,"The 'Timer' function have been deactivated.")
         SendToAll(botName,"The command '-showart' have been activated.")
      else
         curUser:SendData(botName,"The 'Timer' function is already deactivated.")
      end
      return 1
   else return end
end
function MakeArray(curUser)
   readfrom(file,"r")
   while 1 do
      local line = read()
      if line == nil or line == "" then break
      else
         tinsert(DirArray, line)
      end
   end
   readfrom()
   return DirArray
end
function Show(TheFile)
   readfrom("AscIIArtFiles/"..variable,"r")
   local art = ""
   while 1 do
      local line = read()
      if line == nil then break
      else
         art = art..line.."\r\n"
      end
   end
   readfrom()
   return art
end
function OnTimer()
   variable = DirArray[random(1,getn(DirArray))]
   local result = Show(TheFile)
   SendToAll(botName,result)
end

SMF spam blocked by CleanTalk