PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: FrAcTi0n on 04 February, 2005, 17:57:32

Title: release bot - need someone to add one function for me.)
Post by: FrAcTi0n on 04 February, 2005, 17:57:32
hello, i use thiz script and i ask if someone is able to add one fuction to it... if u add release, to first check if it isnot already added... thx fra

--------------------------------------------------------------------------------------------------------------------------------
--Made by nErBoS

--Version 0.3



Bot = "---=juanita_juarez=---"


reltxt = "releases.txt" -- Will be created in the Script folder

prefix = "+" -- Commands Prefix



function Main()

   frmHub:RegBot(Bot)

end



function DataArrival(user, data)

   if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then

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

   s,e,cmd = strfind(data,"%b<>%s+(%S+)")

      if (cmd==prefix.."add") then --## Adds a Release to the list

         if (strlen(user.sName) > 20) then

            user:SendPM(Bot, "Your nick is too long, you can't post the release.")

         else

            AddRelease(user, data)

         end

         return 1

      elseif (cmd==prefix.."all") then --## Show all releases

         ShowRelease(user, data, "all")

         return 1

      elseif (cmd==prefix.."new") then  --## Show the last 30 releases

         ShowRelease(user, data, "last")

         return 1

      elseif (cmd==prefix.."del") then --## Erase a release

         if (user.bOperator) then

            DelRelease(user, data)

         else

            user:SendPM(Bot, "You don?t have permission to use this command.")

         end

         return 1

      elseif (cmd==prefix.."find") then --## Search for a Release

         local s,e,findrel = strfind(data,"%b<>%s+%S+%s+(%S+)")

    if (findrel == nil or findrel == "") then

            user:SendPM(Bot, "Syntax Error, "..prefix.."find , you must write a name.")

    else        

            ShowRelease(user, data, "find", findrel)

    end

    return 1

      end

   end

end



function AddRelease(user, data)

local s,e,type,rel,desc = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")

local tmp = ""
   if (rel == nil or rel == "" or desc == nil or desc == "") then

      user:SendPM(Bot, "Syntax Error, "..prefix.."add .")

      user:SendPM(Bot, "Types Avaibale:\r\n\r\n\r\n\t- DnB - DnB, Jungle, RaggaJungle\r\n\t- Break - Breakbeatss\r\n\t- Users - Junglist users production and mixes .) \r\n\t- fav - f###in good shit \r\n\t- 0 - other \r\n\r\n")

   elseif (strlen(rel) > 90) then

      user:SendPM(Bot, "The Release Name can't have more then 90 characters.")

   elseif (strlen(desc) > 20) then

      user:SendPM(Bot, "The Description can't have more then 20 characters.")  

   else

      if (readfrom(reltxt) == nil) then

         writeto(reltxt)

         write("\r\n"..rel.."$"..desc.."$"..user.sName.."$"..GetTime().."$"..strlower(type).."|")

         writeto()

      else

         readfrom(reltxt)

         while 1 do

         local line = read()

            if (line == "") then

               tmp = tmp.."\r\n"..rel.."$"..desc.."$"..user.sName.."$"..GetTime().."$"..strlower(type).."|"
            elseif(line == nil) then

               break

            else

               tmp = tmp.."\r\n"..line

            end

         end

         readfrom()

         writeto(reltxt)

         write(tmp)

         writeto()

      end

      SendToAll(Bot, "New Release has been added by "..user.sName.."... Write "..prefix.."all or use right click on hub tab to see all Releases.")

      user:SendData(Bot, "Your Release has been added, thank you.")

   end

end



function ShowRelease(user, data, type, string)

local tline = 0

local tmp = ""
local dnb = ""

local breaks = ""

local fav = ""

local users = ""

local other = ""

   if (type == "last") then

      tmp = tmp.."\r\n\r\nThe Last 30 Releases: \r\n\r\n"

      tmp = tmp.." Date\t\tPosted by\t\t\tDescription\t\tRelease Name\r\n"

   elseif (type == "all") then

      tmp = tmp.."\r\n\r\nAll Releases: \r\n\r\n"

      tmp = tmp.." Date\t\tPosted by\t\t\tDescription\t\tRelease Name\r\n"

   elseif (type == "find") then

      local s,e,findrel = strfind(data,"%b<>%s+%S+%s+(%S+)")

      tmp = tmp.."\r\n\r\nSearch Result: \r\n\r\n"

      tmp = tmp.." Date\t\tPosted by\t\t\tDescription\t\tRelease Name\r\n"

   end

      readfrom(reltxt)

      while 1 do

      local line = read()

         if (type == "last") then

            if (tline == 30) then

               break

            end

         end

         if (line == nil) then

            break

         else

         local s,e,rel,desc,who,time,tp = strfind(line, "(.*)%$(.*)%$(.*)%$(.*)%$(.*)%|")

     if (type == "last" or type == "all") then

            if (rel ~= nil) then

      if (tp == "dnb") then

         dnb = dnb.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      elseif (tp == "breaks") then

         breaks = breaks.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      elseif (tp == "fav") then

         fav = fav.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      elseif (tp == "users") then

         users = users.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      else

         other = other.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      end

      tline = tline + 1

            end

     elseif (type == "find") then

            if (rel ~= nil and rel == string) then

      if (tp == "dnb") then

         dnb = dnb.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      elseif (tp == "breaks") then
      
         breaks = breaks.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      elseif (tp == "fav") then

         fav = fav.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      elseif (tp == "users") then

         users = users.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      else

         other = other.." "..time.."\t"..who..Coluns(who)..desc..Coluns(desc)..rel.."\r\n"
      end

            end

          end

    end

      end

      readfrom()

if (dnb ~= "") then

   tmp = tmp.."\r\n ==- DnB releasez\r\n -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n"

   tmp = tmp..dnb

end

if (breaks ~= "") then

   tmp = tmp.."\r\n -Breaks\r\n -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n"

   tmp = tmp..breaks

end

if (fav ~= "") then

   tmp = tmp.."\r\r\n -F###ing good shit \r\n-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n"

   tmp = tmp..fav

end

if (users ~= "") then

   tmp = tmp.."\r\r\n - Junglist Users Production and mixes\r\n  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n"

   tmp = tmp..users

end

if (other ~= "") then

   tmp = tmp.."\r\r\n Other Styles:\r\n -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n"


   tmp = tmp..other


   tmp = tmp.."\r\n ----------------------------------------------------------------------------------------------------------junglist.no-ip.com----------------------------------------------------------------------------------------------------------------------------\r\n"
end

   user:SendPM(Bot, tmp)

end



function DelRelease(user, data)

local s,e,release = strfind(data,"%b<>%s+%S+%s+(%S+)")

local time = 0

local tmp = ""
   if (release == nil or release == "") then

      user:SendPM(Bot, "Syntax Error, "..prefix.."del , you must write a name.")

   else

      readfrom(reltxt)

      while 1 do

      local line = read()

         if (line == nil) then

            break

         else

         local s,e,rel = strfind(line, "(.*)%$.*%$.*%$.*%$.*%|")

            user:SendPM(Bot, rel)

            if (rel == nil or rel == "") then

               tmp = tmp..line.."\r\n"    
            elseif (strlower(rel) == strlower(release)) then

               time = 1

            else

               tmp = tmp..line.."\r\n"                
            end

         end

      end

      readfrom()    

      writeto(reltxt)

      write(tmp)

      writeto()

   end

   if (time == 1) then

      user:SendPM(Bot, "The Release has been erased.")

   else

      user:SendPM(Bot, "The Release was not found.")

   end

end



function GetTime()

   d = date("%d")

   mm = date("%m")

   y = date("%y")

   Date = d.."/"..mm.."/"..y

   return Date

end



function Coluns(string)

local tmp = ""
      if (strlen(string) < 8) then

         tmp = "\t\t\t"
      elseif (strlen(string) < 16) then

         tmp = "\t\t"
      else

         tmp = "\t"
      end

return tmp

end
------------------------------------------------------------------------------------------------------------