i need a script for all users include offline user with 2 major function :1 MM to all user (including offline)
2 a spesific massege for a spesific off line user.
thanks for supporting
QuoteOriginally posted by bsalsa
i need a script for all users include offline user with 2 major function :1 MM to all user (including offline)
2 a spesific massege for a spesific off line user.
thanks for supporting
so i presume you mean only registered users offline?
yes
1 function is :
i want to send a massege to a registered user that is currently offline,
and 1 more function: to massmassage all registered including users that are offline
thanks
bsalsa said:
Quotei want to send a massege to a registered user that is currently offline
I think it is what you are looking for.....
sBotName = "MyOwnBot"
function Main()
--frmHub:RegBot(sBotName)
end
function tokenize (inString,token)
_WORDS = {}
local matcher = "([^?"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end
function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
return arg,arg2
end
function DataArrival(user, data)
if(strsub(data, 1, 1) == "<") then
s,e,msg = strfind(data, "%b<>%s+(.+)")
if (strsub(msg, 1, 5) == "!memo") then
SendToNick(user.sName, "<"..sBotName.."> You must send this command in PM to "..sBotName)
end
elseif(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == sBotName) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (cmd=="!memo") then
arg,arg2 = Get2Args(data)
local handle=openfile("messages/"..arg..".msg","a")
write(handle,""..user.sName.." : "..arg2.."?")
mess="Message sent to "
SendPmToNick(from, sBotName, " "..mess.." "..arg.." : "..arg2)
closefile(handle)
end
end
end
end
function NewUserConnected(curUser)
handle2=openfile("messages/"..curUser.sName..".msg","r")
sMsgText="Message from"
if (handle2==nil) then
else
line = read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
curUser:SendPM(sBotName,sMsgText.." "..linearray[i])
end
closefile(handle2)
end
a,b=remove("messages/"..curUser.sName..".msg")
end
OpConnected = NewUserConnected
This script sends a message to a user which is not online. The user don't have to be a REG one...
sory but not working
i saved the script s awaybot and by your instructions i need to send a pm to the bot but i it does not show itself.
what did i do wrong?
thanks
sBotName = "MyOwnBot"
function Main()
frmHub:RegBot(sBotName)
end
function tokenize (inString,token)
_WORDS = {}
local matcher = "([^?"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end
function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
return arg,arg2
end
function DataArrival(user, data)
if(strsub(data, 1, 1) == "<") then
s,e,msg = strfind(data, "%b<>%s+(.+)")
if (strsub(msg, 1, 5) == "!memo") then
SendToNick(user.sName, "<"..sBotName.."> You must send this command in PM to "..sBotName)
end
elseif(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == sBotName) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (cmd=="!memo") then
arg,arg2 = Get2Args(data)
local handle=openfile("messages/"..arg..".msg","a")
write(handle,""..user.sName.." : "..arg2.."?")
mess="Message sent to "
SendPmToNick(from, sBotName, " "..mess.." "..arg.." : "..arg2)
closefile(handle)
end
end
end
end
function NewUserConnected(curUser)
handle2=openfile("messages/"..curUser.sName..".msg","r")
sMsgText="Message from"
if (handle2==nil) then
else
line = read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
curUser:SendPM(sBotName,sMsgText.." "..linearray[i])
end
closefile(handle2)
end
a,b=remove("messages/"..curUser.sName..".msg")
end
OpConnected = NewUserConnected
LOL
sorry..... the RegBot was not valid in the function Main ( --frmHub:RegBot(sBotName) )
now its better ( it has no errors + its uploaded
but it do not do its job ( or maybe i do mistake in the format of the command ..
please be kind to complete the task
regards
Well, What's Wrong
it does not send an off line message
Sorry.... the command line is !memo . Please don't type the <> characters :]
i am sorry but it stil dont work
!msg
messages = dofile("messages.dat") or {}
function NewUserConnected(user)
local tmp = messages[user.sName]
if tmp then
local n = getn(tmp)
user:SendData(">> "..n.." messages for you..")
for i = 1, getn(tmp) do
user:SendData(">> "..tmp[i][1]..": "..tmp[i][2])
end
messages[user.sName] = nil
savemessages()
end
end
OpConnected = NewUserConnected
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s?(.*)|$")
if s then
cmd = strlower(cmd)
if cmd == "msg" then
local s, e, nick, msg = strfind(args, "(%S+)%s?(.*)")
if s then
local tmp = GetItemByName(nick)
if tmp then
tmp:SendData(">> "..user.sName..": "..msg)
user:SendData(">> "..nick.." is online he/she got your message")
else
messages[nick] = messages[nick] or {}
tinsert(messages[nick], { user.sName, msg })
user:SendData(">> message saved")
savemessages()
end
else
user:SendData(">> syntax: !msg ")
end; return 1
end
end
end
end
function savemessages()
local f = openfile("messages.dat", "w+")
assert(f, "messages.dat")
write(f, "return {\n")
for nick, table in messages do
write(f, "\t"..format("[%q]", nick).." = {\n")
for i = 1, getn(table) do write(f, "\t\t{ "..format("%q", table[i][1])..", "..format("%q", table[i][2]).."},\n") end
write(f, "\t},\n")
end write(f, "}") closefile(f)
end
even nre script dont work
i registereg the function as
sBotName = "offline"
function Main()
frmHub:RegBot(sBotName)
end
icreated a messages.dat file (empty) in the script folder
i used command format :!msg to the offlise script (as a pm)
and no offline massege appiers
and no online massege also :) and by the way i need it to be as a pm.
i see it beucome a chalenge...
thanks for all the help
Quoteit does not send an off line message
Did you create a subfolder "messages" (...Ptokax\scripts\messages)?
Test with it... it works fine for me.
i created :scripts/messages
and it dont work
what do i do wrong?
I'm confused.... it works well on my PC ?(
Try this one, it's the same script but it's the original one (maybe I have made an error when cpoying the first one...)
-------------------------------
-- D?claration des variables --
-------------------------------
botname = "-=Ninie=-"
sBotName = "Ninie"
-----------------------------------
-- Fin d?claration des variables --
-----------------------------------
function Main()
frmHub:RegBot(botname)
end
function tokenize (inString,token)
_WORDS = {}
local matcher = "([^?"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end
function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
return arg,arg2
end
function DataArrival(user, data)
if(strsub(data, 1, 1) == "<") then
s,e,msg = strfind(data, "%b<>%s+(.+)")
if (strsub(msg, 1, 5) == "!memo") then
SendToNick(user.sName, "<"..sBotName.."> Cette commande est ? envoyer en PV ? ninie. A moins que tu veuilles que tout le monde voit ton message perso ??? Rassures-toi, personne n'a vu celui-ci ;-))")
end
elseif(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (cmd=="!memo") then
arg,arg2 = Get2Args(data)
local handle=openfile("messages/"..arg..".msg","a")
write(handle,""..user.sName.." : "..arg2.."?")
mess="Message laiss? pour "
SendPmToNick(from, botname, " "..mess.." "..arg.." : "..arg2)
closefile(handle)
end
end
end
end
function NewUserConnected(curUser)
handle2=openfile("messages/"..curUser.sName..".msg","r")
sMsgText="Message de la part de"
if (handle2==nil) then
else
line = read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
curUser:SendPM(botname,sMsgText.." "..linearray[i])
--SendPmToNick(from, botname,"Le user suivant a lu le message que tu lui avait laiss? ==> "..linearray[i])
end
closefile(handle2)
end
a,b=remove("messages/"..curUser.sName..".msg")
end
function OpConnected(curUser)
handle2=openfile("messages/"..curUser.sName..".msg","r")
sMsgText="Message de la part de"
if (handle2==nil) then
else
line = read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
curUser:SendPM(botname,sMsgText.." "..linearray[i])
--SendPmToNick(from, botname,"Le user suivant a lu le message que tu lui avait laiss? ==> "..linearray[i])
end
closefile(handle2)
end
a,b=remove("messages/"..curUser.sName..".msg")
end
You still have to create the "messages" subfolder. and the command is still !memo and in PM from the Bot (botname)
And check if you have some errors in ptokax, and copy them here please...
syntax errors in the last 1
you dont need to reg the bot and you dont need to make an empty file
the command doesnt show in mainchat so theres no need to write it in pm
youre doing your best to make it a challenge for yourself :)
about that you are totaly right!!!
and i am sorry !
but all works for pnline user but not for offline user
when an offline user connects he get no messaglook on whar i got :
[17:59:01] >> [IL]Eran is online he/she got your message
[17:59:28] *** Parts: [IL]Eran
[17:59:58] >> message saved
all is ok but when this user connects he do not get the messege. by the way it do not delete the old messeges.(and if it possible i want the massege as a pm)
and i used your script :
messages = dofile("messages.dat") or {}
function NewUserConnected(user)
local tmp = messages[user.sName]
if tmp then
local n = getn(tmp)
user:SendData(">> "..n.." messages for you..")
for i = 1, getn(tmp) do
user:SendData(">> "..tmp[1]..": "..tmp[2])
end
messages[user.sName] = nil
savemessages()
end
end
OpConnected = NewUserConnected
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s?(.*)|$")
if s then
cmd = strlower(cmd)
if cmd == "msg" then
local s, e, nick, msg = strfind(args, "(%S+)%s?(.*)")
if s then
local tmp = GetItemByName(nick)
if tmp then
tmp:SendData(">> "..user.sName..": "..msg)
user:SendData(">> "..nick.." is online he/she got your message")
else
messages[nick] = messages[nick] or {}
tinsert(messages[nick], { user.sName, msg })
user:SendData(">> message saved")
savemessages()
end
else
user:SendData(">> syntax: !msg ")
end; return 1
end
end
end
end
function savemessages()
local f = openfile("messages.dat", "w+")
assert(f, "messages.dat")
write(f, "return {\n")
for nick, table in messages do
write(f, "\t"..format("[%q]", nick).." = {\n")
for i = 1, getn(table) do write(f, "\t\t{ "..format("%q", table[1])..", "..format("%q", table[2]).."},\n") end
write(f, "\t},\n")
end write(f, "}") closefile(f)
end
My typing ... i am sory again.
now i will write in english :)
"but all works for online user but not for offline user .
when an offline user connects ,he get no message.
look on whar i got : "
?(
I don't know what to say... it works very well for me.
Are you using dc++ or like? Maybe your PMs are listen in the main chat? Because this script sends PM in a PM window by default....
Check if you have a ".msg " file created in your "messages " folder. This file must have the name of the user (username .msg) and it's a txt file format (you can edit it into UltraEdit).
And check if you have error messages in your Ptokax Debug Window, and if yes, please paste them here.
excuse me, a bit off topic maybe..
but why are you using php tags around the script?
just for syntax high-lighting or are you actually running this stuff on a webserver?
[ sorry: major noob to this.. ]
there is no ptokax errors but on the other hand there is no file like : usernsme.msg and there is n folder in the name of :messages
should i creat 1 ? where ?
thanks
Quoteshould i creat 1 ? where ?
Yes you have to create a new subfolder called "messages" in the Script folder (...\Ptokax\Scripts\messages)
finely it works
!msg
code:--------------------------------------------------------------------------------messages = dofile("messages.dat") or {}
function NewUserConnected(user)
local tmp = messages[user.sName]
if tmp then
local n = getn(tmp)
user:SendData(">> "..n.." messages for you..")
for i = 1, getn(tmp) do
user:SendData(">> "..tmp[1]..": "..tmp[2])
end
messages[user.sName] = nil
savemessages()
end
end
OpConnected = NewUserConnected
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s?(.*)|$")
if s then
cmd = strlower(cmd)
if cmd == "msg" then
local s, e, nick, msg = strfind(args, "(%S+)%s?(.*)")
if s then
local tmp = GetItemByName(nick)
if tmp then
tmp:SendData(">> "..user.sName..": "..msg)
user:SendData(">> "..nick.." is online he/she got your message")
else
messages[nick] = messages[nick] or {}
tinsert(messages[nick], { user.sName, msg })
user:SendData(">> message saved")
savemessages()
end
else
user:SendData(">> syntax: !msg ")
end; return 1
end
end
end
end
function savemessages()
local f = openfile("messages.dat", "w+")
assert(f, "messages.dat")
write(f, "return {\n")
for nick, table in messages do
write(f, "\t"..format("[%q]", nick).." = {\n")
for i = 1, getn(table) do write(f, "\t\t{ "..format("%q", table[1])..", "..format("%q", table[2]).."},\n") end
write(f, "\t},\n")
end write(f, "}") closefile(f)
end--------------------------------------------------------------------------------
how can i change it for :
1 send the offline message as a pm ?
2 an option to send mm to all users together (user that are online and offline) and that will send the message imidietly the the online user and will store it for the offline users and will post them as sooon as they connects
thanks