PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Cid on 09 March, 2005, 01:24:44

Title: Converting Triggerbot, please
Post by: Cid on 09 March, 2005, 01:24:44
here the thing i would like to use with new PtokaX:

-- You can add ur own files
-- For example make a file named help.txt in the docs folder and then type in main !show help
-- ATM you cant make files with spaces like....Friday the 13th.txt <<< this will not work, but will add soon :)
-- Don't forget to make a folder named docs inside script folder
-- Added no such file error
-- Added who-to now, !show   =  example !show pmme test
-- There is pmme, me, or all
-- Added !lock
-- Added !version
-- Added self prefix
-- Fixed 1 line read only

Bot = "Trig"
Version = "0.5"

mcmd="!"

Blacklist={}

function Main()
frmHub:RegBot(Bot)
end

function WhileRead(user,data)
   while 1 do
      line = read("*a")
      if line == nil then
         user:SendData(Bot,"I know of no such file")
         break end
      if to == "me" then
         user:SendData(Bot,line)
      elseif to == "all" then
         SendToAll(Bot,line)
      elseif to == "pmme" then
         user:SendPM(Bot,line)
      elseif to == nil then
         user:SendPM(Bot,line)
      end
   readfrom()
   return 1
   end
end

function LockOut(user)
if arg == "on" then
   user:SendData(Bot,"You have blacklisted: "..to)
   Blacklist[to]=1
   buser = GetItemByName(to)
   buser:SendPM(Bot,"You have been blacklisted")
   return 1
elseif arg == "off" then
   user:SendData(Bot,"You have removed "..to.." from the blacklist")
   Blacklist[to]=nil
   buser = GetItemByName(to)
   buser:SendPM(Bot,"You have been removed from the blacklist")
   return 1
   end
end


function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd,to,arg = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(%S+)")

   if cmd == mcmd.."show" then
      if Blacklist[user.sName]==nil then
         readfrom("docs/"..arg..".txt")
         WhileRead(user,data)
         return 1
      else
         user:SendData(Bot,"I am denying you access to this command")
         return 1
      end
   elseif cmd == mcmd.."lock" then
      if user.bOperator then
         LockOut(user)
         return 1   
      end
   end
end

   s,e,cmd = strfind(data,"%b<>%s+(%S+)")
   if cmd == mcmd.."version" then
      user:SendData(Bot,"I am Trigy "..Version..", edited by Token")
   return 1
   end
end
Title:
Post by: Jelf on 09 March, 2005, 13:48:43
Here ya go...
-- You can add ur own files
-- For example make a file named help.txt in the docs folder and then type in main !show help
-- ATM you cant make files with spaces like....Friday the 13th.txt <<< this will not work, but will add soon :)
-- Don't forget to make a folder named docs inside script folder
-- Added no such file error
-- Added who-to now, !show = example !show pmme test
-- There is pmme, me, or all
-- Added !lock
-- Added !version
-- Added self prefix
-- Fixed 1 line read only
-- Fixed so no script error if user not online when !lock is used By Jelf
-- Converted to Lua5 By Jelf 09/03/05

Bot = "Trig"
Version = "0.5"

mcmd="!"

Blacklist={}
--------------------------
function Main()

frmHub:RegBot(Bot)
end
---------------------
function LockOut(user)

if arg == "on" then
user:SendData(Bot,"You have blacklisted: "..to)
Blacklist[to]=1
buser = GetItemByName(to)
if buser then
buser:SendPM(Bot,"You have been blacklisted")
return 1
else
end
elseif arg == "off" then
user:SendData(Bot,"You have removed "..to.." from the blacklist")
Blacklist[to]=nil
buser = GetItemByName(to)
if buser then
buser:SendPM(Bot,"You have been removed from the blacklist")
return 1
else
end
end
end
-------------------------
function ChatArrival(user,data)

if string.sub(data, 1, 1) == "<" then
data=string.sub(data,1,string.len(data)-1)
s,e,cmd,to,arg = string.find(data,"%b<>%s+(%S+)%s+(%S+)%s+(%S+)")
if cmd == mcmd.."show" then
if Blacklist[user.sName]==nil then
local handle = io.open("docs/"..arg..".txt","r")
if (handle ~= nil) then
local line = handle:read("*all")
if to == "me" then
user:SendData(Bot,line)
elseif to == "all" then
SendToAll(Bot,line)
elseif to == "pmme" then
user:SendPM(Bot,line)
elseif to == nil then
user:SendPM(Bot,line)
end
handle:flush()
handle:close()
return 1
else
user:SendData(Bot,"I know of no such file")
return 1
end
else
user:SendData(Bot,"I am denying you access to this command")
return 1
end
elseif cmd == mcmd.."lock" then
if user.bOperator then
LockOut(user)
return 1
end
end
end
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd == mcmd.."version" then
user:SendData(Bot,"I am Trigy "..Version..", edited by Token")
return 1
end
end
Title:
Post by: Cid on 09 March, 2005, 15:52:00
thanx a lot!
it works superb, whohooo! :D