PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: [NL]trucker on 10 February, 2004, 11:49:55

Title: mass script
Post by: [NL]trucker on 10 February, 2004, 11:49:55
hello you fine folks

i could use a script where i can send a message to either
Vips or regged users or unreggged users from a txt file.
and if posibble on a timer but no need for the bot to register in hub.

my profile list for these are :

unreg -1
reg = 6
vip= 5

and the txt files would be :

Unreg.txt
Reg.txt
Vips.txt

and i wanted to put the txt files in a dir called usertxt.
so if any of you fine scripters has some spare time...... :D
Title:
Post by: kepp on 10 February, 2004, 16:29:57
Hope this helps you


sBot = "-==LOL==-"

function Main()
   --frmHub:RegBot(sBot)
end

function NewUserConnected(user)
   if user.iProfile == -1 then
      READuser(user)
   elseif user.iProfile == 6 then
      READuserReg(user)
   elseif user.iProfile == 5 then
      READuserVip(user)
   end
end

function READIT(user)
   while 1 do
   local line = read()
      if line == nil then break end
         user:SendPM(sBot,line)
      end
   end
   readfrom()
end


function READuser(user)
   readfrom("text/usermsg.txt")
   READIT(user)
end

function READuserReg(user)
   readfrom("text/regmsg.txt")
   READIT(user)
end

function READuserVip(user)
   readfrom("text/vipmsg.txt")
   READIT(user)
end
Title:
Post by: [NL]trucker on 11 February, 2004, 13:10:15
Kepp

thnx m8 im gonna try this one and let you know how it works.


by the way am i the only one who cant see your post other then by giving a reply to it?

i have noticed this in other post you made that there were no lines and i allready had made a comment in this when i did discover that you indeed made a reply ...strange things are happening .

Title:
Post by: [NL]trucker on 11 February, 2004, 14:05:16
Kepp


i just noticed this script does send a message on login
and i would like it so that I could send a message whenever I want so with a command like !send vip that it then reads the message from txtfile and sends it to all online  vips.

could you make that for me?
Title:
Post by: kepp on 16 February, 2004, 12:58:27

sBot = "-==LOL==-"

VIP = {}
REG = {}
UNREG = {}

function Main()
   --frmHub:RegBot(sBot)
end

function NewUserConnected(user)
   if user.iProfile == -1 then
      if UNREG[user.sName]==nil then
         UNREG[user.sName]=1
      end

   elseif user.iProfile == 6 then
      if REG[user.sName]==nil then
         REG[user.sName]=1
      end

   elseif user.iProfile == 5 then
      if VIP[user.sName]==nil then
         VIP[user.sName]=1
      end
   end
end

function UserDisconnect(user)
   VIP[user.sName]=nil;
   REG[user.sName]=nil;
   UNREG[user.sName]=nil;
end

function MassReg(user, data)
   readfrom("text/regmsg.txt")
      while 1 do
      local line = read()
         if line == nil then break end
            for i,v in REG do
            SendPmToNick(i,sBot,line)
         end
      end
   end
   readfrom()
end

function MassUnregg(user, data)
   readfrom("text/unregmsg.txt")
      while 1 do
      local line = read()
         if line == nil then break end
            for i,v in UNREG do
            SendPmToNick(i,sBot,line)
         end
      end
   end
   readfrom()
end

function MassVIP(user, data)
   readfrom("text/vipmsg.txt")
      while 1 do
      local line = read()
         if line == nil then break end
            for i,v in UNREG do
            SendPmToNick(i,sBot,line)
         end
      end
   end
   readfrom()
end

function DataArrival(user, data)
   if (strsub(data,1,1) == "<") then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd=strfind(data,"%b<>%s+(%S+)")
      if cmd=="+massvip" then
         MassVIP(user, data) return 1
         
      elseif cmd=="+massunreg" then
         MassUnregg(user, data) return 1
       
      elseif cmd=="+massreg" then
         MassReg(user, data) return 1
      end
   end
end

I haven't tested it... Sorry, lack of time now!!
But i think it should work...

Actually i haven't noticed anything at all, Weird :S
Title:
Post by: kepp on 16 February, 2004, 13:04:50
A little fix... Noticed too many ends :)
By the way, You must register the bot!!
else they will recieve it in main!!
sBot = "-==LOL==-"

VIP = {}
REG = {}
UNREG = {}

function Main()
   --frmHub:RegBot(sBot)
end

function NewUserConnected(user)
   if user.iProfile == -1 then
      if UNREG[user.sName]==nil then
         UNREG[user.sName]=1
      end

   elseif user.iProfile == 6 then
      if REG[user.sName]==nil then
         REG[user.sName]=1
      end

   elseif user.iProfile == 5 then
      if VIP[user.sName]==nil then
         VIP[user.sName]=1
      end
   end
end

function UserDisconnect(user)
   VIP[user.sName]=nil;
   REG[user.sName]=nil;
   UNREG[user.sName]=nil;
end

function MassReg(user, data)
   readfrom("text/regmsg.txt")
      while 1 do
      local line = read()
         if line == nil then break end
            for i,v in REG do
            SendPmToNick(i,sBot,line)
      end
   end
   readfrom()
end

function MassUnregg(user, data)
   readfrom("text/unregmsg.txt")
      while 1 do
      local line = read()
         if line == nil then break end
            for i,v in UNREG do
            SendPmToNick(i,sBot,line)
      end
   end
   readfrom()
end

function MassVIP(user, data)
   readfrom("text/vipmsg.txt")
      while 1 do
      local line = read()
         if line == nil then break end
            for i,v in UNREG do
            SendPmToNick(i,sBot,line)
       end
   end
   readfrom()
end

function DataArrival(user, data)
   if (strsub(data,1,1) == "<") then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd=strfind(data,"%b<>%s+(%S+)")
      if cmd=="+massvip" then
         MassVIP(user, data) return 1
         
      elseif cmd=="+massunreg" then
         MassUnregg(user, data) return 1
       
      elseif cmd=="+massreg" then
         MassReg(user, data) return 1
      end
   end
end