To add one function
 

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

To add one function

Started by Pit, 21 November, 2004, 19:17:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pit

Greetings scripters

I have this script from nerbos, and i wanted a litle add on please..

--## Linker Help
--## Pedido por mOrrI
--## Feito por nErBoS
--## Comands:
--##   !links                        - Mostra todas a categorias disponiveis
--##   !novacat   - Cria uma nova categoria com comando e uma descri??o para o comando
--##   !apagacat                 - Apaga uma categoria
--##   !novolink      - Adiciona um novo link ? categoria
--##   !apagalink      - Apaga um link ? categoria
--##   !helplinks            - Mostra todos os comandos

sBot = "LAV-Links?"

arrCat = {}
fCat = "cat.dat"

--## Configura??o ##--

uLaterPtokax = 1   -- Escreve 0 se tiveres a usar uma vers?o Ptokax 0.3.3.0 ou superior
                   -- Escreve 1 se tiveres a usar uma vers?o Ptokax infeiror a 0.3.3.0

--## FIM ##--

function Main()
   frmHub:RegBot(sBot)
   LoadFromFile(fCat)
end

function OnExit()
   SaveToFile(fCat , arrCat , "arrCat")
end

function DataArrival(user,data)
   if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data, "%b<>%s+(%S+)")
      if (cmd == "!links") then
         local sTmp,aux,cat = "As categorias com os links do HUB:\r\n\r\n"
         for aux, cat in arrCat do
            sTmp = sTmp.."\t"..cat.cmd.." - "..cat.des.."\r\n"
         end
         user:SendPM(sBot, sTmp)
         return 1
      elseif (cmd == "!helplinks") then
    local sTmp = "Comandos para os Links:\r\n\r\n"
    if (user.bOperator) then
       sTmp = sTmp.."!links\t\t\t\t\t- Mostra todas a categorias disponiveis\r\n"
      sTmp = sTmp.."!novacat \t- Cria uma nova categoria com comando e uma descri??o para o comando\r\n"
       sTmp = sTmp.."!apagacat \t\t\t\t- Apaga uma categoria\r\n"
       sTmp = sTmp.."!novolink \t\t- Adiciona um novo link ? categoria\r\n"
       sTmp = sTmp.."!apagalink \t\t- Apaga um link ? categoria\r\n"
      sTmp = sTmp.."!helplinks\t\t\t\t- Mostra todos os comandos\r\n"
    else
       sTmp = sTmp.."!links\t\t\t\t\t- Mostra todas a categorias disponiveis\r\n"
    end
    user:SendPM(sBot, sTmp)
    return 1
      elseif (cmd == "!novacat" and user.bOperator) then
         local s,e,name,com,desc = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.+)")
         if (name == nil or com == nil or desc == nil) then
            user:SendPM(sBot, "Syntax Erro, !novacat , tens de escrever um nome, o comando e a sua descri??o.")
         elseif (type(arrCat[strlower(name)]) == "table") then
            user:SendPM(sBot, "J? existe uma categoria com o nome "..name)
         else
            arrCat[strlower(name)] = {}
            arrCat[strlower(name)]["cmd"] = com
            arrCat[strlower(name)]["des"] = desc
            arrCat[strlower(name)]["link"] = {}
            user:SendPM(sBot, "A categoria foi criada com sucesso.")
            if (uLaterPtokax == 1) then
               OnExit()
            end
         end
         return 1
      elseif (cmd == "!apagacat" and user.bOperator) then
         local s,e,name = strfind(data, "%b<>%s+%S+%s+(%S+)")
         if (name == nil) then
            user:SendPM(sBot, "Syntax Erro, !apagacat , tens de escrever um nome.")
         elseif (arrCat[strlower(name)] == nil) then
            user:SendPM(sBot, "Na? existe nenhuma categoria com o nome "..name)
         else
            arrCat[strlower(name)] = nil
            user:SendPM(sBot, "A categoria foi apagada com sucesso.")
            if (uLaterPtokax == 1) then
               OnExit()
            end
         end              
         return 1
      elseif (cmd == "!novolink" and user.bOperator) then
         local s,e,cat,link = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
         if (cat == nil or link == nil) then
            user:SendPM(sBot, "Syntax Erro, !novolink , tens de escrever uma categoria e um link.")
         elseif (type(arrCat[strlower(cat)]) ~= "table") then
            user:SendPM(sBot, "N?o existe nenhuma categoria com o nome "..cat)
         elseif (arrCat[strlower(cat)]["link"][strlower(link)] ~= nil) then
            user:SendPM(sBot, "O link "..link.." j? existe.")
         else
            arrCat[strlower(cat)]["link"][strlower(link)] = user.sName
            user:SendPM(sBot, "O link foi adicionado com sucesso.")
            if (uLaterPtokax == 1) then
               OnExit()
            end
         end
         return 1
      elseif (cmd == "!apagalink" and user.bOperator) then
         local s,e,cat,link = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
         if (cat == nil or link == nil) then
            user:SendPM(sBot, "Syntax Erro, !apagalink , tens de escrever uma categoria e um link.")
         elseif (type(arrCat[strlower(cat)]) ~= "table") then
            user:SendPM(sBot, "N?o existe nenhuma categoria com o nome "..cat)
         elseif (arrCat[strlower(cat)]["link"][strlower(link)] == nil) then
            user:SendPM(sBot, "O link "..link.." n?o existe.")
         else
            arrCat[strlower(cat)]["link"][strlower(link)] = nil
            user:SendPM(sBot, "O link foi removido com sucesso.")
            if (uLaterPtokax == 1) then
               OnExit()
            end
         end
         return 1                  
      else
         local aux,cat
         for aux, cat in arrCat do
            if (cmd == cat.cmd) then
               local sTmp,num,link,poster = "Links da categoria "..aux..":\r\n\r\n",1
               for link, poster in cat.link do
                  sTmp = sTmp.."\t"..num.."- "..link.."\tColocado por: "..poster.."\r\n"
                  num = num + 1
               end
               user:SendPM(sBot, sTmp)
               return 1
            end
         end
      end
   end
end

function Serialize(tTable, sTableName, sTab)
   assert(tTable, "tTable equals nil");
   assert(sTableName, "sTableName equals nil");

   assert(type(tTable) == "table", "tTable must be a table!");
   assert(type(sTableName) == "string", "sTableName must be a string!");

   sTab = sTab or "";
   sTmp = ""

   sTmp = sTmp..sTab..sTableName.." = {\n"

   for key, value in tTable do
      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

      sTmp = sTmp..",\n"
   end

   sTmp = sTmp..sTab.."}"
   return sTmp
end

function SaveToFile(file , table , tablename)
   writeto(file)
   write(Serialize(table, tablename))
   writeto()
end

function LoadFromFile(file)
   if (readfrom(file) ~= nil) then
      readfrom(file)
      dostring(read("*all"))
      readfrom()
   end
end


---------------------------------------------------------

My request is could you add on a subcat to the cat's himself...i mean
If i want to insert a new cat, the script has its comand, but if i want to add a subcat within a existing cat, i can't do it...

See this:

!listalinks               - Revela esta lista de Links dispon?vel.
!novacat    - Insere nova categoria e seu comando
!apagacat             - Elimina uma categoria
!novolink          - Adiciona um Link ? categoria
!apagalink          - Elimina um Link ? categoria
!links               - Mostra todos os comandos


Can you you do this with the right comands?!?!?

Here:

!listalinks               - Revela esta lista de Links dispon?vel.
!novacat    - Insere nova categoria e seu comando

!novasubcat                                                             -Insere nova Subcategoria e seu comando
!apagasubcat                        -Elimina uma Subcategoria

!apagacat             - Elimina uma categoria
!novolink          - Adiciona um Link ? categoria
!apagalink          - Elimina um Link ? categoria
!links               - Mostra todos os comandos


PS: In my request, cat means 'Categoria' and Subcat means 'Subcategoria'

Thanks...


Pit

nErBoS

#1
Hi,

The script is in portuguese, so ask it HERE and explain in portuguese what you want to change. Use the topic created for that request please.

Best regards, nErBoS
--## nErBoS Spot ##--

SMF spam blocked by CleanTalk