--TrigChat 1.02 --by Mutor -- --Responds to trigger words typed in main chat. --Add / Remove triggers as you wish. -- -- Changes: -- + No longer triggers on user nicks. -- + Triggers are now in an external file loaded at startup. -- + Start & Stop script commands. -- + Option to run script at server/script restart or not. -- + List of triggers sent in PM. -- -- Your triggers should follow this format: -- trigs = { -- brb = "Hurry back...[User]", --like this -- ["Hi"] = "Hi, [User], Welcome to "..frmHub:GetHubName().."!" --or this, btw=no comma for last trigger -- } -- -- ---Editable Section--------------------- bot = "[Sentry]" -- Change this to your Px bot. Prefix = "+" -- Command Prefix RunComm = "ton" -- Command to start TrigChat StopComm = "toff" -- Command to stop TrigChat ListComm = "tlist" -- Command to list trigger words RunStatus = "1" -- Start TrigChat on or off -> 1=on 0=off triggers = "Trigs.txt" -- External file conatining your triggers table -- ---End Editable Section-------------- -- function Main() --frmHub:RegBot(bot) -- Enable this if you dont want to use your Px bot. LoadFromFile(triggers) end function DataArrival(user, data) s,e,cmd = strfind(data, "%b<>%s+(%S+)(%S+)") if (cmd==Prefix..StopComm) and user.bOperator then RunStatus = "0" SendToAll(bot,"TrigChat stopped... >8-I") return 1 elseif (cmd==Prefix..RunComm) and user.bOperator then RunStatus = "1" SendToAll(bot,"TrigChat started... >8-O") return 1 elseif (cmd==Prefix..ListComm) then user:SendData("Fetching available trigger words..........") for key, value in trigs do user:SendPM(bot,"\t"..key) end return 1 elseif strsub(data, 1, 1) == "<" then local s, e, pre = strfind(data, "^%b<> (.)") if pre == "!" or pre == "+" or pre == "?" then return end -- disallow command input data=strsub(data,1,strlen(data)-1) s,e,nick,msg = strfind(data,"(%S+)%s+(.+)") sdata=msg trigfound=0 -- check for trigs in table for key, value in trigs do -- if RunStatus == "1" and ( strfind( sdata, key) ) then answer, x = gsub(value,"%b[]", user.sName)-- SendToAll( bot, answer ) trigfound=1 break end end if (trigfound==0)then end end end function LoadFromFile(file) if (readfrom(file) ~= nil) then readfrom(file) dostring(read("*all")) readfrom() end end