Hi!
Is it possible to send an PM to all users who are offline and when they login they will get it?
I run Ptokax 0.3.4.0 and Robocop 10.021
Thanks in advance!
Regards,
BrotherBear
My stupid try :D help plz
ChatArrival = function(user,data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%#%?](%S+)")
if cmd then
local tCmds = {
["offlinemsg"] = function (user,data)
for key,value in frmHub:GetOnlineUsers()
if not user.bConnected then
user:SendPM(..user is not connected)
else
user:SendPM("msg send...")
SendMsg(user)
end
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data)
end
SendMsg = function(user)
?????
end
Hi Markitos!
I got this error:
Offlinmess.lua:8: `do' expected near `if'
Something like this?
tOffline = {}
ChatArrival = function(user,data)
local s,e,cmd = string.find(data, "^%b<>%s+%!(%S+).*|$")
if cmd and string.lower(cmd) == "offline" then
local s,e,msg = string.find(data,"^%b<>%s+%S+%s+(.*)")
if msg then
tOffline = { sUser = user.sName, sMsg = msg }
user:SendData(frmHub:GetHubBotName(),"*** Your message has been stored and will be sent to users on connect!")
end
return 1
end
end
NewUserConnected = function(user)
if next(tOffline) then user:SendPM(tOffline.sUser,"*** Offline Message: "..tOffline.sMsg) end
end
Markitos, regarding your code:
- It's missing a "do" in the for loop:
for key,value in frmHub:GetOnlineUsers() do
- This line:
if not user.bConnected then
Is checking if the user who typed the command is offline. Is that what you pretended? Seems like you wanted to check if an online user (by checking in the frmHub:GetOnlineUsers() table) was offline. And that's not possible :)
- Is trying to concatenate a string.
[sBot] could be set as a var or use frmHub:GetHubBotName(). So, could be like:
user:SendPM(sBot,"user is not connected")
Nice try though :)
sBot = frmHub:GetHubBotName()
tOffline = {}
Main = function()
frmHub:RegBot(sBot)
end
ChatArrival = function(user,data)
local s,e,cmd = string.find(data, "^%b<>%s+%!(%S+).*|$")
if cmd and user.bRegistered and string.lower(cmd) == "offline" then
local s,e,msg = string.find(data,"^%b<>%s+%S+%s+(.*)")
if msg then
tOffline = { sUser = user.sName, sMsg = msg }
user:SendData(sBot,"*** Your message has been stored and will be sent to users on connect!")
end
return 1
end
end
NewUserConnected = function(user)
if next(tOffline) then user:SendPM(tOffline.sUser,"*** Offline Message: "..tOffline.sMsg) end
end
P.s - thanks for your replies (jiten & mutor)
Jiten i didnt understand this line
if next(tOffline) then user:SendPM(tOffline.sUser,"*** Offline Message: "..tOffline.sMsg) end
QuoteFormat tags dont work inside code tags? ?M.
This script is only for one user, right?
What i mean was if I can send a PM to ALLl Users that are OFFLINE, not one nick at a time.
Quote from: Mutor on 21 March, 2006, 00:47:31
It is curently leaving a message for onself and the table config is wrong.
Also, the nick is not being cleared when user connects, so that it would be
sent each time the nick logs in. Im fairly certain thats not the intended op.
Well, that script was meant to do that, so that after some inputs we could completely fulfill the request. It's just that there wasn't (isn't?) much info available.
At this level, I didn't want to store each user in a table after being sent the offline message as it would get enormous (if used in a big hub). But, if it's requested, why not? :)
-- Offline PMer
-- By Madman, 21.03.06
-- Request by BrotherBear
-- You need to create a folder in the scripts folder called OfflinePMer
-- Version 1.1
-- Fixed: SendMsg Bug
-- Added: So Op's get the msg to
-- Changed: The cmd to offpm
function ChatArrival(curUser, data)
local data = string.gsub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)%s+")
if cmd == "offpm" and curUser.bOperator then
local s,e,Msg = string.find(data, "%b<>%s+%S+%s+(.+)")
local Users = ""
local file = io.open("OfflinePMer/Online.dat", "w+")
file:write("")
for _,User in frmHub:GetOnlineUsers() do
Users = Users..string.lower(User.sName).."\n"
end
file:write(Users)
file:close()
if Msg then
local MsgFile = io.open("OfflinePMer/Msg.txt", "w+")
MsgFile:write(Msg)
MsgFile:close()
curUser:SendData(frmHub:GetHubBotName(), "Message created with no problem") return 1
else
curUser:SendData(frmHub:GetHubBotName(), "Syntax is !" ..cmd.. " <msg>") return 1
end
end
end
function NewUserConnected(curUser)
SendMsg = nil
local ofile = io.open("OfflinePMer/Online.dat")
if ofile then
for line in io.lines("OfflinePMer/Online.dat") do
if line == string.lower(curUser.sName) then
SendMsg = nil
break
else
SendMsg = 1
end
end
end
ofile:close()
if SendMsg then
local file = io.input("OfflinePMer/Msg.txt")
local line = string.gsub(io.read("*a"), "\n", "\r\n")
curUser:SendPM(frmHub:GetHubBotName(), line)
file:close()
local oFile = io.open("OfflinePMer/Online.dat", "a+")
oFile:write(string.lower(curUser.sName).."\n")
oFile:close()
end
end
-- Comment -- the line under this if you don't want to send pm to Ops
OpConnected = NewUserConnected
Give this a try....
Quote from: Mutor on 21 March, 2006, 15:58:47
What further info is required? The request seems pretty straightforward.
It seems. But, I have another perspective:
From the moment the script is loaded, every (or most) of the connecting users are the ones who were offline. And that's a start... though, not the perfect (the perfect one would store all online users in a table and compare them with the ones connecting and then send or not the message, as you know).
If BrotherBear wanted it different, he would request and then the script would be modded according to his needs. I just didn't want to start with the end.
Hi you all and thanks for careing in this matter :)
Thanks Madman, I will try it, what is the command, can't find it, must be blind......where did I go....I'm looooooooost ;)
I Run a Rebhub Only with maxusers 250-300.
Can't the script get users from the file in cfg\RegisteredUsers.xml time to time and check those who are Online and put them in a Online.dat or Online.tbl file, when a user is goin offline script creates another Offline.dat or Offline.tbl file?
Then we could use the Offline file to distribute PM to them or am I thinking wrong or it would be to much for the hubsoft to handle?
if cmd == "offline" then
curUser:SendData(frmHub:GetHubBotName(), "Syntax is !" ..cmd.. " <msg>") return 1
prefix is !
command is offline
total command is= !offline
;)
Dooh!
Need glasses :D
Thanks 6Marilyn6Manson6 and Your Avatar Rocks :)
Madman, I did get this when I typed !offline Message
*** Offline messages can only be send to registered users!
When I typed !offline Nick Message it worked
Quote from: BrotherBear on 21 March, 2006, 20:25:46
Dooh!
Need glasses :D
Thanks 6Marilyn6Manson6 and Your Avatar Rocks :)
Thanks boy :D
Quote from: BrotherBear on 21 March, 2006, 20:28:24
Madman, I did get this when I typed !offline Message
*** Offline messages can only be send to registered users!
When I typed !offline Nick Message it worked
*** Offline messages can only be send to registered users!
This line not is in this script and you can receive this line from this script :P..... I think problem is in Robocop ;)
Jepp, that's right 6Marilyn6Manson6, Robocop has an !offline command, I change it in the script above to !offpm then it worked, thanks for guideing me right :)
But, hmm, question is if it is a But, hehe, when the same user log out and in again, he/she will get the PM again.
Here comes a real But, if it is important PM (And these mostly are) it doesn't matter if they get it several times :)
Thank you all for this script :)
Quote from: BrotherBear on 21 March, 2006, 21:07:41
But, hmm, question is if it is a But, hehe, when the same user log out and in again, he/she will get the PM again.
Dunno exatly what you mean... But no user should get the PM twice... after sending msg to user it opens the Online file and adds the users name in it..
Quote from: Madman on 21 March, 2006, 22:34:49
Quote from: BrotherBear on 21 March, 2006, 21:07:41
But, hmm, question is if it is a But, hehe, when the same user log out and in again, he/she will get the PM again.
Dunno exatly what you mean... But no user should get the PM twice... after sending msg to user it opens the Online file and adds the users name in it..
Hi Madman
They get it every time they login and in the Online.dat file the user apears several times, like this:
[REG]Nick
[REG]Nick
[Reg]Nick
[Reg]Nick1
[Reg]Nick1
[Reg]Nick1
[VIP]Nick
etc...
They don't disapear when they logoff.
Quote from: BrotherBear on 22 March, 2006, 17:30:54
Hi Madman
They get it every time they login and in the Online.dat file the user apears several times, like this:
[REG]Nick
[REG]Nick
[Reg]Nick
[Reg]Nick1
[Reg]Nick1
[Reg]Nick1
[VIP]Nick
etc...
They don't disapear when they logoff.
Fixed the double... and they aint supposed to disaper when go offline...
They will be stored in the Online.dat untill you write a new msg.
Nice Madman, it worked great :)
Is there a way that only OP's or higher can write the !offpm command ?
Quote from: BrotherBear on 22 March, 2006, 19:15:54
Is there a way that only OP's or higher can write the !offpm command ?
Duuh! Knew there was something i forgot...
Change
if cmd == "offpm" then
to
if cmd == "offpm" and curUser.bOperator then
Script has been updated...
Your my man Madman, thank you Very Much :)
Try it at once.