please need heklp with this trig to lua 5.1.1
 

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

please need heklp with this trig to lua 5.1.1

Started by tortilla, 31 July, 2006, 00:44:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tortilla

--
SV = "PiKoleTo Live 1.00 Lua5"
--
-- by Mutor      ..Reworked an old script a bit 10/07/05
--
-- Alerts operators if trigger file is missing.
-- Now reads trigger table from external file.
-- Includes settable string (command) to list available triggers.
--
--Trigger table to be stored in external file
--Add / Remove triggers as you wish, follow the format.
--
---Editable Section---------------------
TrigBot = frmHub:GetHubBotName()-- Name for Bot: frmHub:GetHubBotName() or "Custom_Name"
Prefix = "?"               -- Command Prefix
RunComm = "ton"               -- Command to start TrigChat
StopComm = "toff"            -- Command to stop TrigChat
ListComm = "trig"            -- Command to list triggers (dont use prefix, script doesnt trigger on control chars)
RunStatus = "on"            -- Start TrigChat on or off -> "on"/"off"
TrigFile = "Trigspik.dat"         -- File to store triggers table
ShowVer= "yes"               -- Display script info on start? "yes"/"no"
---End Editable section--------------
--

Main = function()
   if TrigBot ~= frmHub:GetHubBotName() then
      frmHub:RegBot(TrigBot, 1, SV, "")
   end
   if ShowVer == "yes" and RunStatus == "on" then
      SendToAll(TrigBot, SV.." Iniciado en: "..os.date("%B %d %Y @ %X").."\tUsando Nick: "..TrigBot)
   end
   if loadfile(TrigFile) ~= nil then
      dofile(TrigFile)
   else
      local ErrMsg0="\r\n\r\n\tFile Error: "..TrigFile.." does not exist.\r\n"
      if not (frmHub:GetOpChatName()) then
         SendPmToOps(Bot,ErrMsg0)
      else
         SendPmToOps(frmHub:GetOpChatName(),TrigBot..ErrMsg0)
      end
   end
end

ChatArrival = function(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "^%b<>%s+(%p%w+)")
--local s,e,msg = string.find(data,"^%b<>%s+(.+)$") --match first capture anywhere in the text
local _,_,msg = string.find(data,"%s+(%S+)$")      --match first or last word
local s,e,trg = string.find(data,"^%b<>%s+(%w+)")
   if (cmd==Prefix..StopComm) and user.bOperator then
      if RunStatus == "off" then
         user:SendData(TrigBot,GetProfileName(user.iProfile).." "..user.sName..", TrigChat isn't running now...? ?>8-P")
      else
         RunStatus = "off"
         SendToAll(TrigBot,"TrigChat has been stopped by "..GetProfileName(user.iProfile).." "..user.sName..",...? ?>8-I")
      end
      return 1
   elseif (cmd==Prefix..RunComm) and user.bOperator then
      if RunStatus == "on" then
         user:SendData(TrigBot,GetProfileName(user.iProfile).." "..user.sName..", TrigChat is already running...? ?>8-P")
      else
         RunStatus = "on"
         SendToAll(TrigBot,"TrigChat has been started by? "..GetProfileName(user.iProfile).." "..user.sName..",...? ?>8-O")
      end
         return 1
   elseif trg and (trg == ListComm) then
      user:SendPM(TrigBot,GetTrigs())      --Send list in pm
      --user:SendData(TrigBot,GetTrigs())   --Send list in main
      return
   elseif msg and not cmd then
      local s, e, pre = string.find(data, "^%b<>%s(%p)")
      if pre and GetPrefixes()[1] == pre then
         return
      end
      for key, value in trigs do --
         if RunStatus == "on" and ( string.find( msg, key) ) and string.len(msg)==string.len(key) then -- exact first word
         --if RunStatus == "on" and ( string.find( msg, key) ) then      --any part of text
            answer, x = string.gsub(value,"%b[]", user.sName)--
            local filter = string.gsub(data,"%b<> ","")
            SendToAll(user.sName,filter )
            SendToAll(TrigBot,answer )
            return 1
         end
      end
   end
end

GetTrigs = function()
local reply = "\r\n\r\n\tCurrent Triggers:\r\n"..string.rep("o",150).."\r\n"
   for i,v in trigs do
      reply = reply.." [ "..i.." ] "
   end
   return reply.."\r\n"..string.rep("o",150).."\r\n\tEnd Of Listing"
end


SMF spam blocked by CleanTalk