PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: BlazeXxX on 31 October, 2003, 03:34:43

Title: Send Msg to UnRegged Users
Post by: BlazeXxX on 31 October, 2003, 03:34:43
-- Start Copying from this line
--// Script for sending chat messages to all non-registered users
--// Format: !nonregmsg message
--// Works for operators only (all users with Key)
--//
--// by Ptaczek, 21-8-2003
--// v1.0
--//
--// Note: the nonRegistered users list is lost after script restart!

nonRegUsers = {};

function DataArrival(user, data)
if( user.bOperator and strsub(data,1,1) == "<" ) then
local msg = strsub(data, strlen(user.sName)+4, -2)
if( strsub(msg,1,1) == "!" ) then
local cmd,args
_,_,cmd,args = strfind(msg,"([%w%p]+) ([%w%s%p]+)")
if( cmd == "!nonregmsg" ) then
SendToNonReg(user, args)
return 1
end
end
end
end

function SendToNonReg(user, msg)
local fullmsg = "<"..user.sName.."> "..msg
for nick, i in nonRegUsers do
SendPmToNick(nick, "RegBot", fullmsg)
end
end

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

function UserDisconnected(user)
if( nonRegUsers[user.sName] ) then
nonRegUsers[user.sName] = nil
end
end

-- Finish Copying
Title:
Post by: [NL]trucker on 31 October, 2003, 10:50:58
BlazeXxX

i like your idear but......

is it possiblle to make the script read from a txt.file?

in tha case it would be easier to edit the message and to add more messages.

like "!nonregmsg" txt1 or txt2.
Title:
Post by: BlazeXxX on 31 October, 2003, 16:41:37
Ooops... I mentioned in top line, its not my script.. Its written by Ptacezk.. I think its possible to do it.. Just wait for some ppl like.. [NL]Pur, Phatty,Skrolster,Klownietklowniet or others who is good at scripting :)
Title:
Post by: pHaTTy on 31 October, 2003, 18:23:41
QuoteOriginally posted by [NL]trucker
BlazeXxX

i like your idear but......

is it possiblle to make the script read from a txt.file?

in tha case it would be easier to edit the message and to add more messages.

like "!nonregmsg" txt1 or txt2.

Im not sure i quite understand what you mean, can you explain a little please

so you mean when they enter the hub? they get a msg from a txt file and not have to have user input?
Title:
Post by: pHaTTy on 31 October, 2003, 20:02:42
btw here is a quick little edit whilst im back


--// Script for sending chat messages to all non-registered users
--// Format: !nonregmsg message
--// Works for operators only (all users with Key)
--//
--// by Ptaczek, 21-8-2003
--// v1.0
--//
--// Note: the nonRegistered users list is lost after script restart!
--// Some little edits by Phatty


Prefix = "!"
Command = "nonregmsg"

nonRegUsers = {};

function SendToNonReg(user, msg)
local fullmsg = "<"..user.sName.."> "..msg
for nick, i in nonRegUsers do
SendPmToNick(nick, "RegBot", fullmsg)
end
end

function NewUserConnected(user)
if (user.iProfile == 1) then
nonRegUsers[user.sName] = 1;
end
end

function UserDisconnected(user)
if( nonRegUsers[user.sName] ) then
nonRegUsers[user.sName] = nil
end
end

function DataArrival(user, data)
if( user.bOperator and strsub(data,1,1) == "<" ) then
local msg = strsub(data, strlen(user.sName)+4, -2)
if( strsub(msg,1,1) == Prefix ) then
local cmd,args
_,_,cmd,args = strfind(msg,"([%w%p]+) ([%w%s%p]+)")
if( cmd == Prefix..Command ) then
SendToNonReg(user, args)
return 1
end
end
end
end



l8rr,,
Title:
Post by: turkiye on 31 October, 2003, 20:17:57
NICE!
Title:
Post by: BlazeXxX on 31 October, 2003, 23:06:53
(uk-kingdom)pH?tt?: What he means is like:

!nonregmsg txtfile1
OR
!nonregmsg txtfile2

So He would have two text files, he can choose which one should be Mass msged to unregistered users.. If you get what i meant :)
Title:
Post by: pHaTTy on 01 November, 2003, 14:18:38
Ahhh ic :o) thx i will get right on it as soon as i get 5 ;)
Title:
Post by: pHaTTy on 01 November, 2003, 14:41:47
not got much time but ive quickly wrote this

Untested so use with care


Command = "!nonregmsg"

nonRegUsers = {}


function NewUserConnected(user)
if (user.iProfile == 1) then
nonRegUsers[user.sName] = 1
end
end

function UserDisconnected(user)
if( nonRegUsers[user.sName] ) then
nonRegUsers[user.sName] = nil
end
end

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

if cmd == Command then
for nick, i in nonRegUsers do
  readfrom(file,".txt")
while 1 do
line = read()
SendPmToNick(nick,user.sName..line)
end
readfrom()
end
end
end
end



l8rr,,
Title:
Post by: BlazeXxX on 01 November, 2003, 15:06:56
So it sends like !nonregmsg 1 or !nonregmsg 2 ??? like that?
Title:
Post by: pHaTTy on 01 November, 2003, 17:53:57
nah say you make a file names test.txt

then the command wud be !nonregmsg test

l8rr,, ;)
Title:
Post by: NightLitch on 01 November, 2003, 18:29:17
Haven't tried this one...

But with this code you should be able too restart as you wish without losing the users...

Could be wrong, maybe don't work...

Command = "!nonregmsg"

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

if cmd == Command then
local ru = GetUsersByProfile(GetProfileName(-1))
for nick, i in ru do
readfrom(file,".txt")
while 1 do
line = read()
SendPmToNick(nick,user.sName..line)
end
readfrom()
end
end
end
end

/NightLitch
Title:
Post by: tezlo on 01 November, 2003, 18:33:01
nice try..
but -1 is not a valid profile
ptokaz doesnt keep a list of unregged users
Title:
Post by: pHaTTy on 01 November, 2003, 18:36:55
im abit confused actually from the first script

if (user.iProfile == -1) then

???
Title:
Post by: NightLitch on 01 November, 2003, 18:36:56
notice that... just tried to be sure... And Yes...

Didn't work...

boommer.... :-D

/NightLitch
Title:
Post by: NightLitch on 01 November, 2003, 18:37:51
1 is Operator Status

and -1 is NonRegUsers
Title:
Post by: pHaTTy on 01 November, 2003, 18:39:37
Hmmmm, ye i figured that bit out, but.............i dont see why ur way does not work.....:S

hmmmmmmmmm
Title:
Post by: BlazeXxX on 02 November, 2003, 03:19:55
Hmm Well I checked most of the scripts and Tezlo is right... Unless you store the users that is connecting in a table and read them as unregged users.. and then make use of it.. or else check the RegisteredUsers.dat file and make it send the msg to the users who is not in that file.. Either way would work for sure :)
Title: Could someone put up the final script
Post by: jsjen on 27 December, 2003, 09:04:20
Could someone put up the final script cause im totally lost on what is going on.
Title: hehehehe
Post by: Flux on 27 December, 2003, 09:51:33
same here i am lost too hehehehe. maybe also it's cause i am stoned too. hehehe what is the final script between them or is there a newer update...
Title:
Post by: Optimus on 27 December, 2003, 12:53:56
mmm, i allready posted 1 like this sometime ago... that saves all to file so that after Restartscripts all are still there, etc

-- Made by Optimus
-- 08/12/03
-- make a file called unRegUsers.txt

sBot = "-=unRegUsers=-"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
   frmHub:RegBot(sBot)
   doloadTable(unRegUserFile)
   if frmHub:GetUsersCount() == 0 then unRegUsers = {}
      dosaveTable(user,data)
   end
end

function NewUserConnected(user)
   if user.iProfile == -1 then
      doLog_unRegUsers(user, data)
   end
end
function UserDisconnected(user)
   if unRegUsers[user.sName] then
      unRegUsers[user.sName] = nil
      dosaveTable(user,data)
   end
end

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

      if user.bOperator then
         if (cmd == "!xmass") then            
            s,e,cmd,message = strfind(data,"%b<>%s+(%S+)%s+(.+)")

            if message then
               tosend = ""
               if (strlen ( message)*2/3+2) < 76 then
               border = strrep ("-", strlen (message)*2/3+2)
               else
               border = strrep ("-", 75)
               end
               tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"

               if unRegUsers then
                  for name,_ in unRegUsers do
                     SendPmToNick(name,sBot, tosend)
                  end
               end
            else
               user:SendData(sBot, "*** Please Enter a Message!")
            end
         end
      end
   end
end

function doLog_unRegUsers(user, data)
   if unRegUsers[user.sName] == nil then
      unRegUsers[user.sName] = 1
      dosaveTable(user,data)
   end
end

function doloadTable(unRegUserFile)
   assert(readfrom(unRegUserFile))
   dostring(read("*all"))
   readfrom()
end

function dosaveTable(user,data)
   writeto(unRegUserFile)
   write("unRegUsers = {")
   for a,b in unRegUsers do
   if b then
   write(format("[%q]=",a)..b..",")
   end
   end
   write("}" )
   writeto()
end
Title:
Post by: BlazeXxX on 28 December, 2003, 17:07:28
Thx Opti ;)