PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: ketso on 07 November, 2003, 19:06:06

Title: Want to send different messages ...
Post by: ketso on 07 November, 2003, 19:06:06
To unregistered users and registered users.

All unregistered get: Welcome bla bla bla bla bla ......

All other gets : Welcome

Got it to work on Owner, operator,  OP, but not on VIP and REG.

If i set the privilege "kick" on them i get it to work, but i dont want to give that to VIP/REG.
How can i make this happend? (i use PtokaX TD4)
Title:
Post by: NightLitch on 07 November, 2003, 19:16:59
instead of using:

if curUser.bOperator then

use

if curUser.siProfile == 2 then


0 = MASTER, 1 = OP, 2 = VIP, 3 = REG, -1 = USER


hope it helps...

/NightLitch
Title:
Post by: NightLitch on 07 November, 2003, 19:19:44
for multiple users like you want VIP & REG to use one and NonREG one try this one:



function NewUserConnected(curUser)
if curUser.siProfile == 2 or curUser.siProfile == 3 then
curUser:SendData(BotName,"Welcome for VIP & REG")
else
curUser:SendData(BotName,"Welcome for Non REG")
end
end


/NightLitch
Title:
Post by: ketso on 07 November, 2003, 22:46:49
I'm new in this and now i have messed it up on this file (forgot to take backup)

-- InFoBot
Bot = "-InFo-"

function Main()
frmHub:RegBot(Bot)
end
function NewUserConnected(curUser) --this got all wrong now (and next line :)
if curUser.siProfile == -1 then
function curUser(curUser)
handle = openfile("txt/regged.txt", "r")
      if (handle ~= nil) then
        local line = read(handle)
        local sMsg = "\r\n"
        while line do
          sMsg = sMsg..line.."\r\n"
          line = read(handle)
end
answer = ""..sMsg..""
      SendToOps(Bot, answer)
      closefile(handle)
end
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("+help")) ) then   
handle = openfile("txt/help.txt", "r")
      if (handle ~= nil) then
        local line = read(handle)
        local sMsg = "\r\n"
        while line do
          sMsg = sMsg..line.."\r\n"
          line = read(handle)
end
answer = ""..sMsg..""
      user:SendPM(Bot, answer)
      closefile(handle)
   end
     end
end
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("+info")) ) then
      handle = openfile("txt/info.txt", "r")
      if (handle ~= nil) then
        local line = read(handle)
        local sMsg = "\r\n"
        while line do
          sMsg = sMsg..line.."\r\n"
          line = read(handle)
end
answer = ""..sMsg..""
      user:SendPM(Bot, answer)
      closefile(handle)
      end
    end
end
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("+rules")) ) then
      handle = openfile("txt/rules.txt", "r")
      if (handle ~= nil) then
        local line = read(handle)
        local sMsg = "\r\n"
        while line do
          sMsg = sMsg..line.."\r\n"
          line = read(handle)
end
answer = ""..sMsg..""
      user:SendPM(Bot, answer)
      closefile(handle)
      end
    end
end
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("+news")) ) then
      handle = openfile("txt/news.txt", "r")
      if (handle ~= nil) then
        local line = read(handle)
        local sMsg = "\r\n"
        while line do
          sMsg = sMsg..line.."\r\n"
          line = read(handle)
end
answer = ""..sMsg..""
      user:SendPM(Bot, answer)
      closefile(handle)
      end
    end
end
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("+agreedto")) ) then
      handle = openfile("txt/agree.txt", "r")
      if (handle ~= nil) then
        local line = read(handle)
        local sMsg = "\r\n"
        while line do
          sMsg = sMsg..line.."\r\n"
          line = read(handle)
end
answer = ""..sMsg..""
      user:SendPM(Bot, answer)
      closefile(handle)
      end
    end
end
if strsub(data, 1, 9+strlen(Bot)) == "$GetINFO "..Bot then
      user:SendData("$MyINFO $ALL "..Bot.." zInFo v.0.1$ $LAN(T3)\001$$0$")
end
end
Title:
Post by: NightLitch on 07 November, 2003, 23:35:25
really messy... hehe.. but I can fix it for ya, later... If not somebody else is quicker...

/NightLitch
Title:
Post by: NightLitch on 08 November, 2003, 00:18:21
Here you go just a start have explained a few things... but not much....

Can do it more simple later if you want...

-- InFoBot
--By: NightLitch to ketso
--
-- NOTE: Don't forget to create following files in txt-folder:
-- regged.txt, nonreg.txt, help.txt, rules.txt, info.txt,  news.txt & agree.txt
--

--// Set Botname
Bot = "-InFo-"
--// Registred Users Welcome File
REGFile = ("txt/regged.txt")
--// Non-Registred Users Welcome File
NONFile = ("txt/nonreg.txt")


--// This is fired when hub starts or scripts restarted
function Main()
frmHub:RegBot(Bot)
end

--// This is fired when a new user logs in...
function NewUserConnected(curUser)
if curUser.siProfile == 2 or curUser.siProfile == 3 then
REGGEDTEXTLOAD(curUser)
else
NONREGTEXTLOAD(curUser)
end
end

--// Read Registred Users File
function REGGEDTEXTLOAD(curUser)
handle = openfile(REGFile, "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendData(Bot, answer)
closefile(handle)
end
end
--// Read Non-Registred Users File
function NONREGTEXTLOAD(curUser)
handle = openfile(NONFile, "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendData(Bot, answer)
closefile(handle)
end
end

--// Send Data Arrival
function DataArrival(curUser, data)
if( strsub(data, 1, 1) == "<" ) then

----------------------------------------------------------------------------------
--// Help Command
if( strfind( strlower(data), strlower("+help")) ) then
handle = openfile("txt/help.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// Info Command
elseif( strfind( strlower(data), strlower("+info")) ) then
handle = openfile("txt/info.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// Rule Command
elseif( strfind( strlower(data), strlower("+rules")) ) then
handle = openfile("txt/rules.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// News Command
elseif( strfind( strlower(data), strlower("+news")) ) then
handle = openfile("txt/news.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// Agreeto Command
elseif( strfind( strlower(data), strlower("+agreedto")) ) then
handle = openfile("txt/agree.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
end
end
end



/NightLitch
Title:
Post by: ketso on 08 November, 2003, 01:15:27
This give me nonreg.txt file on both unregged, vip, reg

I have a leecher script that give nonregged users a message and that works. (none regged users get that message) But I want one spesial message for the regged ppl too.

I chanced it to this:
-----------------------------------------------------------------------
--// Set Botname
Bot = "-InFo-"
--// Registred Users Welcome File
REGFile = ("txt/regged.txt")

--// This is fired when hub starts or scripts restarted
function Main()
   frmHub:RegBot(Bot)
end

--// This is fired when a new user logs in...
function NewUserConnected(curUser)
   if curUser.siProfile == 2 or curUser.siProfile == 3 then
      REGGEDTEXTLOAD(curUser)
   end
end

--// Read Registred Users File
function REGGEDTEXTLOAD(curUser)
   handle = openfile(REGFile, "r")
   if (handle ~= nil) then
      local line = read(handle)
      local sMsg = "\r\n"
      while line do
         sMsg = sMsg..line.."\r\n"
         line = read(handle)
      end
      answer = ""..sMsg..""
      curUser:SendData(Bot, answer)
      closefile(handle)
   end
end
-----------------------------------------------------------------------

But this gives no message again :S
(yes, i do got txt/regged.txt)

Title:
Post by: ketso on 08 November, 2003, 15:33:58
i use -- LEECHBLOCKER 02 -- for PtokaX TD4  and that gives messages to -1 users.
Title:
Post by: NightLitch on 08 November, 2003, 15:36:42
I see no problem in my script...
Title:
Post by: NightLitch on 08 November, 2003, 15:40:24
ok notice on bug or a thing I wrote wrong


curUser.siProflie should be:

curUser.iProfile


this is the functioning code:

-- InFoBot
--By: NightLitch to ketso
--
-- NOTE: Don't forget to create following files in txt-folder:
-- regged.txt, nonreg.txt, help.txt, rules.txt, info.txt,  news.txt & agree.txt
--

--// Set Botname
Bot = "-InFo-"
--// Registred Users Welcome File
REGFile = ("txt/regged.txt")
--// Non-Registred Users Welcome File
NONFile = ("txt/nonreg.txt")


--// This is fired when hub starts or scripts restarted
function Main()
frmHub:RegBot(Bot)
end

--// This is fired when a new user logs in...
function NewUserConnected(curUser) --this got all wrong now (and next line :)
if curUser.iProfile == 2 or curUser.iProfile == 3 then
REGGEDTEXTLOAD(curUser)
else
NONREGTEXTLOAD(curUser)
end
end

--// Read Registred Users File
function REGGEDTEXTLOAD(curUser)
handle = openfile(REGFile, "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendData(Bot, answer)
closefile(handle)
end
end
--// Read Non-Registred Users File
function NONREGTEXTLOAD(curUser)
handle = openfile(NONFile, "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendData(Bot, answer)
closefile(handle)
end
end

--// Send Data Arrival
function DataArrival(curUser, data)
if( strsub(data, 1, 1) == "<" ) then

----------------------------------------------------------------------------------
--// Help Command
if( strfind( strlower(data), strlower("+help")) ) then
handle = openfile("txt/help.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// Info Command
elseif( strfind( strlower(data), strlower("+info")) ) then
handle = openfile("txt/info.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// Rule Command
elseif( strfind( strlower(data), strlower("+rules")) ) then
handle = openfile("txt/rules.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// News Command
elseif( strfind( strlower(data), strlower("+news")) ) then
handle = openfile("txt/news.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
----------------------------------------------------------------------------------
--// Agreeto Command
elseif( strfind( strlower(data), strlower("+agreedto")) ) then
handle = openfile("txt/agree.txt", "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendPM(Bot, answer)
closefile(handle)
end
return 1
end
end
end

/NightLitch
Title:
Post by: ketso on 08 November, 2003, 17:05:16
Y E S !
There it was.

I removed for unregged users sinse they got it from leecher script.

Now i got:
function NewUserConnected(curUser)
if curUser.iProfile == 2 or curUser.iProfile == 3 then
REGGEDTEXTLOAD(curUser)
end
end

If i want one message for 4, 5 and another one for 6, 7 i set two more "function NewUserConnected(curUser) if curUs......." (with respective nr of course) ?

Thanks a lot for the help, i realy appreciate the help your given me.
Title:
Post by: ketso on 09 November, 2003, 01:01:47
I trying to give su, operator and master the one message i have made in txt/privi.txt
It dosn't give error, but it dosn't work either.
--// Set Botname
Bot = "-InFo-"
--// Registred Users Welcome File
REGFile = ("txt/regged.txt")
--// privileged users (like operator/su)
PRIVIFile = ("txt/privi.txt")

--// This is fired when hub starts or scripts restarted
function Main()
frmHub:RegBot(Bot)
end

--// This is fired when a new user logs in...
function NewUserConnected(curUser)
if curUser.iProfile == 2 or curUser.iProfile == 3 then
REGGEDTEXTLOAD(curUser)
end
end

function NewUserConnected(curUser)
if curUser.iProfile == 1 or curUser.iProfile == 4 or curUser.iProfile == 0 then
PRIVILEGEDTEXTLOAD(curUser)
end
end

--// Read Registred Users File
function REGGEDTEXTLOAD(curUser)
handle = openfile(REGFile, "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendData(Bot, answer)
closefile(handle)
end
end

--// Read privileged users File
function PRIVILEGEDTEXTLOAD(curUser)
handle = openfile(PRIVIFile, "r")
if (handle ~= nil) then
local line = read(handle)
local sMsg = "\r\n"
while line do
sMsg = sMsg..line.."\r\n"
line = read(handle)
end
answer = ""..sMsg..""
curUser:SendData(Bot, answer)
closefile(handle)
end
end

--// Send Data Arrival
function DataArrival(curUser, data)
if( strsub(data, 1, 1) == "<" ) then

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

Altso tried to use this:--// This is fired when a new user logs in...
function NewUserConnected(curUser)
if curUser.iProfile == 2 or curUser.iProfile == 3 then
REGGEDTEXTLOAD(curUser)
else
if curUser.iProfile == 1 or curUser.iProfile == 4 or curUser.iProfile == 0 then
PRIVILEGEDTEXTLOAD(curUser)
end
end
end

I must find out how to trigger several messages, so i can give one message to each profile. (i tried a lot here now, but a lot gives error and nothing of it works)