-- 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
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.
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 :)
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?
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,,
NICE!
(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 :)
Ahhh ic :o) thx i will get right on it as soon as i get 5 ;)
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,,
So it sends like !nonregmsg 1 or !nonregmsg 2 ??? like that?
nah say you make a file names test.txt
then the command wud be !nonregmsg test
l8rr,, ;)
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
nice try..
but -1 is not a valid profile
ptokaz doesnt keep a list of unregged users
im abit confused actually from the first script
if (user.iProfile == -1) then
???
notice that... just tried to be sure... And Yes...
Didn't work...
boommer.... :-D
/NightLitch
1 is Operator Status
and -1 is NonRegUsers
Hmmmm, ye i figured that bit out, but.............i dont see why ur way does not work.....:S
hmmmmmmmmm
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 :)
Could someone put up the final script cause im totally lost on what is going on.
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...
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
Thx Opti ;)