ok ive finshed new gekko mod, and here is the stand alone
--//Mail Bot by Phatty v2
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
Mail = "-Daemon-"
mcmd = "!"
assert(dofile("table.txt")) --make a file named tables.txt with Inbox = {} inside;
Outbox = {}
MaxMails = 5
function Main()
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
end
function OnExit()
save()
end
function Error(user,arg,arg2,msg)
if arg == nil or arg == "" then
arg = "Please enter a user to send to!"
end
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if msg == nil or msg == "" then
msg = "Please enter a message to send!"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function DataArrival(user,data)
if ( strsub(data, 1, 5) == "$To: " ) then
s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
s,e,old,data = strfind(data, "(%S+)>(.*)")
--SendToAll(Mail,"DEBUG: "..data)
if whoto == Mail then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1
--end
elseif cmd == mcmd.."send" then
towho = Outbox[user.sName][3]
mail = Outbox[user.sName][2]
thread = Outbox[user.sName][1]
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1
end
if count < MaxMails then
Inbox[towho][thread] = {user.sName,mail}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1
end
else
Inbox[towho] = {}
Inbox[towho][thread] = {user.sName,mail}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
return 1
elseif cmd == mcmd.."read" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[user.sName][argx] then
local dFrom = Inbox[user.sName][argx][1]
local dMessage = Inbox[user.sName][argx][2]
ShowMail(user,dFrom,argx,dMessage)
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[user.sName][argx] then
Inbox[user.sName][argx] = {}
Inbox[user.sName][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
end
end
end
end
function ShowMail(user,arg,arg2,msg)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
i still have alot todo (add)
everything is to be sent as pm to deamon
later,,
hmmm
--//Mail Bot by Phatty v2.02
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
Mail = "-Daemon-"
mcmd = "!"
assert(dofile("table.txt"))
Outbox = {}
MaxMails = 5
function Main()
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
end
function OnExit()
save()
end
OpConnected = NewUserConnected
function NewUserConnected(user)
if Inbox[user.sName] then
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM("HMail: You have "..sumit.." message(s) - type !read to learn more")
break
end
local sumit = 0
end
end
function Error(user,arg,arg2,msg)
if arg == nil or arg == "" then
arg = "Please enter a user to send to!"
end
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if msg == nil or msg == "" then
msg = "Please enter a message to send!"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function DataArrival(user,data)
if ( strsub(data, 1, 5) == "$To: " ) then
s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
s,e,old,data = strfind(data, "(%S+)>(.*)")
--SendToAll(Mail,"DEBUG: "..data)
if whoto == Mail then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1
--end
elseif cmd == mcmd.."send" then
towho = Outbox[user.sName][3]
mail = Outbox[user.sName][2]
thread = Outbox[user.sName][1]
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1
end
if count < MaxMails then
Inbox[towho][thread] = {user.sName,mail}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1
end
else
Inbox[towho] = {}
Inbox[towho][thread] = {user.sName,mail}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
return 1
elseif cmd == mcmd.."read" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,sumit.." - "..i)
end
local sumit = 0
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[user.sName][argx] then
local dFrom = Inbox[user.sName][argx][1]
local dMessage = Inbox[user.sName][argx][2]
ShowMail(user,dFrom,argx,dMessage)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,sumit.." - "..i)
end
local sumit = 0
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[user.sName][argx] then
Inbox[user.sName][argx] = {}
Inbox[user.sName][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."reply" then
if Inbox[user.sName] then
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if arg2 == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif msg == nil then
user:SendPM(Mail,"Send What??")
else
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
end
end
end
end
end
end
function ShowMail(user,arg,arg2,msg)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
Added date n time when recieved from sent ;-)
--//Mail Bot by Phatty v2.04
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
Mail = "-Daemon-"
mcmd = "!"
assert(dofile("table.txt"))
Outbox = {}
MaxMails = 5
function Main()
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
end
function OnExit()
save()
end
OpConnected = NewUserConnected
function NewUserConnected(user)
if Inbox[user.sName] then
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM("HMail: You have "..sumit.." message(s) - type !read to learn more")
break
end
local sumit = 0
end
end
function Error(user,arg,arg2,msg,date)
if arg == nil or arg == "" then
arg = "Please enter a user to send to!"
end
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if msg == nil or msg == "" then
msg = "Please enter a message to send!"
end
if date == nil then
date = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function DataArrival(user,data)
if ( strsub(data, 1, 5) == "$To: " ) then
s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
s,e,old,data = strfind(data, "(%S+)>(.*)")
--SendToAll(Mail,"DEBUG: "..data)
if whoto == Mail then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
Error(user,arg,arg2,msg,date())
Outbox[user.sName] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1
--end
elseif cmd == mcmd.."send" then
towho = Outbox[user.sName][3]
mail = Outbox[user.sName][2]
thread = Outbox[user.sName][1]
date = Outbox[user.sName][4]
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1
end
if count < MaxMails then
Inbox[towho][thread] = {user.sName,mail,date}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1
end
else
Inbox[towho] = {}
Inbox[towho][thread] = {user.sName,mail,date}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
return 1
elseif cmd == mcmd.."read" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,sumit.." - "..i)
end
local sumit = 0
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[user.sName][argx] then
local dFrom = Inbox[user.sName][argx][1]
local dMessage = Inbox[user.sName][argx][2]
local dDate = Inbox[user.sName][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,sumit.." - "..i)
end
local sumit = 0
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[user.sName][argx] then
Inbox[user.sName][argx] = {}
Inbox[user.sName][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."reply" then
if Inbox[user.sName] then
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if arg2 == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif msg == nil then
user:SendPM(Mail,"Send What??")
else
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
end
end
end
end
end
end
function ShowMail(user,arg,arg2,msg,date)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
phatty :-)
nice work m8 keep it coming.
Good stuff
Fix plz, to bot read commands from MAIN chat too..
And it some bug with "date" function in script
QuoteOriginally posted by spurlos
Good stuff
Fix plz, to bot read commands from MAIN chat too..
And it some bug with "date" function in script
be bit more specific please, what is wrong with it?
------- paste -----------
[17:56] !hmail spurlos test hello my little friend
[17:56] <-Daemon->
To: spurlos
Date/Time: 04/01/04 17:56:52
Thread: test
Message: hello my little friend
[17:56] <-Daemon-> Confirm and send by typing !send
[17:56] !send
[17:56] <-Daemon-> Message has been confirmed and sent
[17:56] <-Daemon-> You have received a hmail from: spurlos, type !read test to view it
[17:57] !hmail spurlos test2 Thats message kill script!
------- paste -----------
That's all..
And in this moment on PtokaX script window show error:
------- paste -----------
Syntax Error: attempt to call global `date' (a string value)
------- paste -----------
I can write a lot of message (!hmail command), but after !send command script broken..
Example (after reload script):
-------------- paste --------------
[17:58] !hmail rita test hello my little friend
[17:58] <-Daemon->
To: rita
Date/Time: 04/01/04 17:58:37
Thread: test
Message: hello my little friend
[17:58] <-Daemon-> Confirm and send by typing !send
[17:58] !hmail ersgfdg wwtest hello my little friend
[17:58] <-Daemon->
To: ersgfdg
Date/Time: 04/01/04 17:58:47
Thread: wwtest
Message: hello my little friend
[17:58] <-Daemon-> Confirm and send by typing !send
[17:58] !hmail rita test2 hello my little friend
[17:58] <-Daemon->
To: rita
Date/Time: 04/01/04 17:58:58
Thread: test2
Message: hello my little friend
[17:58] <-Daemon-> Confirm and send by typing !send
[17:59] !send
[17:59] <-Daemon-> Message has been confirmed and sent
[17:59] !hmail cdgvdf tertest hello my little friend
------------- paste -----------
hmmm i will have a look soon and maybe update it somemore, btw works fine in G7.1 ;-)
It's cool, usefull script.. I'm find error myself..
In was conflict with local variable named "date" and "date()" function.. Renamin' all "date" variable to "date1" fix this error -)
sorry for my super english ,)
Edit take 3: Ok it took some work, but it works (still some bugs, like it always say you have 1 message, even if you have more, but it works).
--//Mail Bot by Phatty v2.04.3
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
--//date variable prob found by spurlos corrected, bot email, desc, speed and share added, some debbugging - yepyepyep4711 28/04/2004
Mail = "-YourPost-"
gb = 1024 * 1024 * 1024
bot_email = "YourPost@koeln.de"
bot_speed = "4711 kbs"
bot_descr = "!help as pm for the help"
bot_share_size = 47.11 * gb
mcmd = "!"
assert(dofile("table.txt")) --make a file named tables.txt with Inbox = {} inside;
Outbox = {}
MaxMails = 5
function Main()
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
my_info_string = "$MyINFO $ALL "..Mail.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email..
"$"..bot_share_size.."$"
end
function OnExit()
save()
end
function NewUserConnected(user)
user:SendData( my_info_string )
if Inbox[user.sName] then
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,"You have "..sumit.." message(s) - type !read to learn more")
break
end
local sumit = 0
end
end
OpConnected = NewUserConnected
function Error(user,arg,arg2,msg,date1)
if arg == nil or arg == "" then
arg = "Please enter a user to send to!"
end
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if msg == nil or msg == "" then
msg = "Please enter a message to send!"
end
if date1 == nil then
date1 = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function DataArrival(user,data)
if ( strsub(data, 1, 5) == "$To: " ) then
s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
s,e,old,data = strfind(data, "(%S+)>(.*)")
--SendToAll(Mail,"DEBUG: "..data)
if whoto == Mail then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
Error(user,arg,arg2,msg,date())
Outbox[user.sName] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1
--end
elseif cmd == mcmd.."send" then
towho = Outbox[user.sName][3]
mail = Outbox[user.sName][2]
thread = Outbox[user.sName][1]
date1 = Outbox[user.sName][4]
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1
end
if count < MaxMails then
Inbox[towho][thread] = {user.sName,mail,date1}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1
end
else
Inbox[towho] = {}
Inbox[towho][thread] = {user.sName,mail,date1}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
return 1
elseif cmd == mcmd.."read" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,sumit.." - "..i)
end
local sumit = 0
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[user.sName][argx] then
local dFrom = Inbox[user.sName][argx][1]
local dMessage = Inbox[user.sName][argx][2]
local dDate = Inbox[user.sName][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1
user:SendPM(Mail,sumit.." - "..i)
end
local sumit = 0
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
if Inbox[user.sName] then
s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[user.sName][argx] then
Inbox[user.sName][argx] = {}
Inbox[user.sName][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end
user:SendPM(Mail,"Syntax: !read ")
end
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."reply" then
if Inbox[user.sName] then
s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if arg2 == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif msg == nil then
user:SendPM(Mail,"Send What??")
else
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
end
end
end
end
end
end
function ShowMail(user,arg,arg2,msg,date1)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
enjoy
And wot is the problem with counting messages?
-------------------------------
function NewUserConnected(user)
if Inbox[strlower(user.sName)] then
local sumit = 0
for i,v in Inbox[strlower(user.sName)] do
sumit = sumit + 1
-- break
end
if sumit > 0 then
SendToNick(user.sName,"Mail: U have "..sumit.." messages.. Type !read ")
user:SendPM(Mail,"U have "..sumit.." messages.. Type !read")
end
local sumit = 0
end
end
you're right. With that, there's no more problem. : )
But why did you add
SendToNick(user.sName,"Mail: U have "..sumit.." messages.. Type !read ")
?
and it needs some more parsing, if any message with quotation marks in it is in memory when you stop the script/hub, the script won't restart because the table besomes unreadable (as plop found out)
I dont understand, why troubles must become..
How much messages must be in memory, that the script won't restart?
try the following:
1-start script
2-send message to someone with " in it, like 'I just wanted to say "hello", so hello'
3-restart scripts
4-you'll see the script won't restart
Hi Phatty and all forumers :-)
I'm finally back on track again, *phew*
Man have I had some serious problems getting a new connection since i moved in to town :/
Anyhoo now i've got a faster and hopefully more stabile line.
So what's up on the forum then? Any new interesting scripts or whatever for me to run in my testhub?
Hugs to y'all from a happy Susie :)
hmm if i cud read the script i wud fix it while im here, but i cant its all in lines down :/
try keep in some kind of form with tabs
god
--//Mail Bot by Phatty v2.04.3
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
--//date variable prob found by spurlos corrected
--//Spurlos - bot email, desc, speed and share added, some debbugging - yepyepyep4711 28/04/2004 --//Obselete, no tabs retabbed and redone-Phatty
--//GRRRRRR RETABBED!!!! for debugging - Phatty
assert(dofile("table.txt")) --make a file named tables.txt with Inbox = {} inside;
Mail = "-HotMail-" -- // BotNAme
mcmd = "!" -- // Command prefix
MaxMails = 10; -- // Max mail per user
MailsMail = "me@hubmail.hub"
MailSpeed = "SnailMail"
MailDesc = "!help as pm for the help"
function Main()
Outbox = {}
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
MailInfoString = "$MyINFO $ALL "..Mail.." "..MailDesc.."$ $"..MailSpeed..strchar(1).."$"..MailsMail.."$"..0.."$"
end
function OnExit()
save() -- // Save mails b4 script totally clears memory
end
OpConnected = NewUserConnected; function NewUserConnected(user)
user:SendData(MailInfoString)
if Inbox[user.sName] then
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,"You have "..sumit.." message(s) - type !read to learn more")
break; end
local sumit = 0;
end;
end;
function Error(user,arg,arg2,msg,date1)
if nil == arg or "" == arg then
arg = "Please enter a user to send to!"
end;
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if nil == msg or "" == msg then
msg = "Please enter a message to send!"
end
if nil == date1 then
date1 = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function DataArrival(user,data)
if ( strsub(data, 1, 5) == "$To: " ) then
local s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
local s,e,data = strfind(data, "%S+>(.*)") -- // old becomes obselete
if Mail == whoto then
data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
Error(user,arg,arg2,msg,date())
Outbox[user.sName] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1;
elseif cmd == mcmd.."send" then
towho = Outbox[user.sName][3]
mail = Outbox[user.sName][2]
thread = Outbox[user.sName][1]
date1 = Outbox[user.sName][4]
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1;
end;
if count < MaxMails then
Inbox[towho][thread] = {user.sName,mail,date1}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1;
end;
else
Inbox[towho] = {}
Inbox[towho][thread] = {user.sName,mail,date1}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
return 1;
elseif cmd == mcmd.."read" then
if Inbox[user.sName] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if nil == argx then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[user.sName][argx] then
local dFrom = Inbox[user.sName][argx][1]
local dMessage = Inbox[user.sName][argx][2]
local dDate = Inbox[user.sName][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
if Inbox[user.sName] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[user.sName][argx] then
Inbox[user.sName][argx] = {}
Inbox[user.sName][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."reply" then
if Inbox[user.sName] then
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if nil == arg2 then
user:SendPM(Mail,"What do you want to erase?")
elseif nil = msg then
user:SendPM(Mail,"Send What??")
else
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
end; end; end; end; end; end;
function ShowMail(user,arg,arg2,msg,date1)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
trying to run that last "tabbed" version i got this ???
--------------pasted--------
Syntax error: ambiguous syntax (decimal point x string concatenation);
last token read: `0..' at line 30 in file `..HUb\scripts\z.04.Mail Bot by Phatty v2.04.3.lua'
--------------------------------
so i tryed the one posted before that one .. .... .. :0(
----------------pasted-----------
Syntax error: assertion failed! file error
stack traceback:
1: function `assert' [C]
2: main of file `...HUb\scripts\z.04.Mail Bot by Phatty v2.04.3.lua' at line 21
---------------------------------------
Then i read the code... (intead of the comments)
.. (the comment say's tables .txt..
where the value = "table.txt") ... hehe :0P
i rename the tablefile & works :0)
so ... then i tried the last posted version again .. but still that " last token read: `0..' at line 30 " error on script startup ..
love the script :0))
hope this is not another one of "my problems" and that it helps you to get it sorted .. ..
greets..
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t" ..mcmd.."hmail - Send a message to a user\r\n"
tmp = tmp.."\t" ..mcmd.."send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t" ..mcmd.."read - Lists your inbox\r\n"
tmp = tmp.."\t" ..mcmd.."read - Reads a message from inbox!\r\n"
tmp = tmp.."\t" ..mcmd.."read - Delete a message from inbox!\r\n"
tmp = tmp.."\t" ..mcmd.."help - This help, you stupid!\r\n"
----------------------------------------------------------------
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type " ..mcmd.."read "..thread.." to view it")
-------------------------------------------------------------
etc. etc.
did it all through the script.. and it works ;0) if you want i post it but i have used the "untabbed version" and it is only little work so i guess not .. ...
sorry couple mistakes while tabbing i guess here ya go and added filecheck
btw
NOTE: Ignore the reply command ive not finsihed adding
--//Mail Bot by Phatty v2.04.4
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
--//date variable prob found by spurlos corrected
--//Spurlos - bot email, desc, speed and share added, some debbugging - yepyepyep4711 28/04/2004 --//Obselete, no tabs retabbed and redone-Phatty
--//GRRRRRR RETABBED!!!! for debugging - Phatty
--//Fixed and added tablefile check -- // Phatty
Mail = "-HotMail-" -- // BotNAme
mcmd = "!" -- // Command prefix
MaxMails = 10; -- // Max mail per user
MailsMail = "me@hubmail.hub"
MailSpeed = "SnailMail"
MailDesc = "!help as pm for the help"
filecheckx = openfile("table.txt", "r")
if filecheckx then
assert(dofile("table.txt"))
else
Inbox = {}
end
closefile(filecheckx)
function Main()
Outbox = {}
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
MailInfoString = "$MyINFO $ALL "..Mail.." "..MailDesc.."$ $"..MailSpeed..strchar(1).."$"..MailsMail.."$".."0".."$"
end
function OnExit()
save() -- // Save mails b4 script totally clears memory
end
OpConnected = NewUserConnected; function NewUserConnected(user)
user:SendData(MailInfoString)
if Inbox[user.sName] then
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,"You have "..sumit.." message(s) - type !read to learn more")
break; end
local sumit = 0;
end;
end;
function Error(user,arg,arg2,msg,date1)
if nil == arg or "" == arg then
arg = "Please enter a user to send to!"
end;
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if nil == msg or "" == msg then
msg = "Please enter a message to send!"
end
if nil == date1 then
date1 = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function DataArrival(user,data)
if strsub(data, 1, 5) == "$To: " then
local s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
local s,e,data = strfind(data, "%S+>(.*)") -- // old becomes obselete
if Mail == whoto then
data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
Error(user,arg,arg2,msg,date())
Outbox[user.sName] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1;
elseif cmd == mcmd.."send" then
towho = Outbox[user.sName][3]
mail = Outbox[user.sName][2]
thread = Outbox[user.sName][1]
date1 = Outbox[user.sName][4]
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1;
end;
if count < MaxMails then
Inbox[towho][thread] = {user.sName,mail}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1;
end;
else
Inbox[towho] = {}
Inbox[towho][thread] = {user.sName,mail,date1}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
elseif cmd == mcmd.."read" then
if Inbox[user.sName] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[user.sName][argx] then
local dFrom = Inbox[user.sName][argx][1]
local dMessage = Inbox[user.sName][argx][2]
local dDate = Inbox[user.sName][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
if Inbox[user.sName] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[user.sName][argx] then
Inbox[user.sName][argx] = {}
Inbox[user.sName][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[user.sName] do
user:SendPM(Mail,i)
end;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."reply" then
if Inbox[user.sName] then
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if arg2 == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif msg == nil then
user:SendPM(Mail,"Send What??")
else
Error(user,arg,arg2,msg)
Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
user:SendPM(Mail,"Confirm and send by typing !send")
end; end; end; end; end; end;
function ShowMail(user,arg,arg2,msg,date1)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
I get these 2 errors
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: bad argument #1 to `strfind' (string expected, got nil)
have I done something wrong?
no emails can be collected and sent ones dont seem to be saves to txt file
Great !! i installed the re-tabbed version now
(after replacing all the ! in bot reply for "..cmcd.." 's) ;0) and runs smooth..
but i found a little "buggy" thingy ..
---------------------pasted1-------------------------------------
[23:37] <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read mes1 to view it
[23:37] <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read mes2 to view it
[00:01] @read mes1
[00:01] <-=SpaceMail=->
From: ~_DeRidderOpHetBlauwePaard_~
Time/Date: 05/15/04 23:37:06
Thread: mes1
Message: blablabla
[00:01] @read mes2
[00:01] <-=SpaceMail=-> Message Names are as follows:
[00:01] <-=SpaceMail=-> 1 - mes1
[00:01] <-=SpaceMail=-> Syntax: @read
-------------------------------------------------------- so what happened here ? ..
well i did a test to see if "UwV " and "uWv " would be treated as different usres by the script ..
and they do ..
but .. they both get a message when send one of them mail it seems .. ;-)
so i tryed again and ..
------------------pasted2-----------------------------------------
[00:49]
- <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read helloa to view it
- <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read helloa2 to view it
- @read helloa
- <-=SpaceMail=-> Message Names are as follows:
- <-=SpaceMail=-> 1 - helloa2
- <-=SpaceMail=-> Syntax: @read
[00:47] yes ..
[00:47] i send you two mails ..
[00:47] one to purplh ..
[00:57] and one to PurplH
[00:57] but cant read ?
[00:58] @read helloa2
[00:58] that one only ..
[00:58] is in the nickname thingy ..
[00:59] PuplH .. get a message when purplh gets a mail ..
[00:59] but no reading his mail i guess .. lol
[00:59] so use the correct " CasEinG " with the username
[01:00] <-=SpaceMail=->
From: ~_DeRidderOpHetBlauwePaard_~
Time/Date: 05/16/04 00:07:23
Thread: helloa2
Message: so i have installed this new script ,, is a hubmail system .. you can mail eachother :0) i think this is one of the more usefull scipts in development at this moment ... so i am putting it through the tests .. part of the test is to see if username is case-sensitive so .. again
[01:00] :)
[01:00] :0)
[01:00] works
[01:00] great
--------------------------------------------------- ...
i think the script ROCKS !! thanks for this one ..
QuoteOriginally posted by UwV?
Great !! i installed the re-tabbed version now
(after replacing all the ! in bot reply for "..cmcd.." 's) ;0)
and runs smooth..
but i found a little "buggy" thingy ..
---------------------pasted1-------------------------------------
[23:37] <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read mes1 to view it
[23:37] <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read mes2 to view it
[00:01] @read mes1
[00:01] <-=SpaceMail=->
From: ~_DeRidderOpHetBlauwePaard_~
Time/Date: 05/15/04 23:37:06
Thread: mes1
Message: blablabla
[00:01] @read mes2
[00:01] <-=SpaceMail=-> Message Names are as follows:
[00:01] <-=SpaceMail=-> 1 - mes1
[00:01] <-=SpaceMail=-> Syntax: @read
--------------------------------------------------------
so what happened here ? ..
well i did a test to see if "UwV " and "uWv " would be treated as different usres by the script ..
and they do ..
but .. they both get a message when send one of them mail it seems .. ;-)
so i tryed again and ..
------------------pasted2-----------------------------------------
[00:49]
- <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read helloa to view it
- <-=SpaceMail=-> You have received a hmail from: ~_DeRidderOpHetBlauwePaard_~, type @read helloa2 to view it
- @read helloa
- <-=SpaceMail=-> Message Names are as follows:
- <-=SpaceMail=-> 1 - helloa2
- <-=SpaceMail=-> Syntax: @read
[00:47] yes ..
[00:47] i send you two mails ..
[00:47] one to purplh ..
[00:57] and one to PurplH
[00:57] but cant read ?
[00:58] @read helloa2
[00:58] that one only ..
[00:58] is in the nickname thingy ..
[00:59] PuplH .. get a message when purplh gets a mail ..
[00:59] but no reading his mail i guess .. lol
[00:59] so use the correct " CasEinG " with the username
[01:00] <-=SpaceMail=->
From: ~_DeRidderOpHetBlauwePaard_~
Time/Date: 05/16/04 00:07:23
Thread: helloa2
Message: so i have installed this new script ,, is a hubmail system .. you can mail eachother :0) i think this is one of the more usefull scipts in development at this moment ... so i am putting it through the tests .. part of the test is to see if username is case-sensitive so .. again
[01:00] :)
[01:00] :0)
[01:00] works
[01:00] great
--------------------------------------------------- ...
i think the script ROCKS !! thanks for this one ..
ok i can fix that, will fix that soon as i get a few mins spare =)
.
bit tired but thin this is it
--//Mail Bot by Phatty v2.04.4
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
--//date variable prob found by spurlos corrected
--//Spurlos - bot email, desc, speed and share added, some debbugging - yepyepyep4711 28/04/2004 --//Obselete, no tabs retabbed and redone-Phatty
--//GRRRRRR RETABBED!!!! for debugging - Phatty
--//Fixed and added tablefile check -- // Phatty
--//Fixed Nick trick --//Phatty
Mail = "-HotMail-" -- // BotNAme
mcmd = "!" -- // Command prefix
MaxMails = 10; -- // Max mail per user
MailsMail = "me@hubmail.hub"
MailSpeed = "SnailMail"
MailDesc = "!help as pm for the help"
filecheckx = openfile("table.txt", "r")
if filecheckx then
assert(dofile("table.txt"))
else
Inbox = {}
end
closefile(filecheckx)
function Main()
Outbox = {}
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
MailInfoString = "$MyINFO $ALL "..Mail.." "..MailDesc.."$ $"..MailSpeed..strchar(1).."$"..MailsMail.."$".."0".."$"
end
function OnExit()
save() -- // Save mails b4 script totally clears memory
end
OpConnected = NewUserConnected; function NewUserConnected(user)
user:SendData(MailInfoString)
if Inbox[user.sName] then
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,"You have "..sumit.." message(s) - type !read to learn more")
break; end
local sumit = 0;
end;
end;
function Error(user,arg,arg2,msg,date1)
if nil == arg or "" == arg then
arg = "Please enter a user to send to!"
end;
if arg2 == nil or arg2 == "" then
arg2 = "Please enter a hmail name!"
end
if nil == msg or "" == msg then
msg = "Please enter a message to send!"
end
if nil == date1 then
date1 = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function DataArrival(user,data)
if strsub(data, 1, 5) == "$To: " then
local s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
local s,e,data = strfind(data, "%S+>(.*)") -- // old becomes obselete
if Mail == whoto then
data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
--arg = "Please enter a user to send it to!"
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
local arg = strlower(arg)
Error(user,arg,arg2,msg,date())
Outbox[user.sName] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1;
elseif cmd == mcmd.."send" then
loweruser = strlower(user.sName)
towho = Outbox[loweruser][3]
mail = Outbox[loweruser][2]
thread = Outbox[loweruser][1]
date1 = Outbox[loweruser][4]
towho = strlower(towho)
if Inbox[towho] then
local count = 0
for i,v in Inbox[towho] do
count = count + 1;
end;
if count < MaxMails then
Inbox[towho][thread] = {loweruser,mail}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails"}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1;
end;
else
Inbox[towho] = {}
Inbox[towho][thread] = {loweruser,mail,date1}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
elseif cmd == mcmd.."read" then
local loweruser = strlower(user.sName)
if Inbox[loweruser] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0;
for i,v in Inbox[loweruser] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[loweruser][argx] then
local dFrom = Inbox[loweruser][argx][1]
local dMessage = Inbox[loweruser][argx][2]
local dDate = Inbox[loweruser][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[loweruser] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
local loweruser = strlower(user.sName)
if Inbox[loweruser] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[loweruser][argx] then
Inbox[loweruser][argx] = {}
Inbox[loweruser][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[loweruser] do
user:SendPM(Mail,i)
end;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
-- // elseif cmd == mcmd.."reply" then
-- // This is invalid
-- // if Inbox[user.sName] then
-- // local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
-- // if arg2 == nil then
-- // user:SendPM(Mail,"What do you want to erase?")
-- // elseif msg == nil then
-- // user:SendPM(Mail,"Send What??")
-- // else
-- // Error(user,arg,arg2,msg)
-- // Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
-- // user:SendPM(Mail,"Confirm and send by typing !send")
-- // end;
-- // end;
end; end; end; end;
function ShowMail(user,arg,arg2,msg,date1)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end
write("},\n")
end
write("\t},\n")
end
write("}")
writeto()
end
will test it first thing tommorow :0)
i have already send all users the next message earlyer ..
@hmail username welcome
____________ new @ Space-Network.. SpaceMail !!________________
why? because it is FUN :0)
For who? .. for ALL!!
How much? for FREE !!
The commands ?
-- @hmail - Send a message to a user
-- @send - Confirm the message to be sent from outbox!
-- @read - Lists your inbox
-- @read - Reads a message from inbox!
-- @del - Delete a message from inbox!
-- @help - This stupid help!
ALL commands must be send to this mailbot in a PM ..
N.B.
MinD The CaSE ... mail to 'uWv' will not arrive to me ..
mail to: "UwV" will ..
_____________________________________________________________
p.s.
Little bugs are still in the script ..
like.. maybe you noticed you see you have 1 mail but your inbox total will say 0
so all you little buggies be awared.. for the motto is :
we will, we will,... catch you! , catch you! ;)
char case in nick name cause a problem.
If message was send to "spUrloS", spurlos receive confirmation of message recieve, but if try to read message it say, that is no new messages..
i add strlower function on any user var..
example:
function NewUserConnected(user)
if Inbox[strlower(user.sName)] then
local sumit = 0
and so on..
Who's fastest ?
Phatty is ! .. .... ;0)
Im running robocop should I change this to gekko?
I just get errors
little update, fixed some bugs and added massmail for ppl that have accounts will receive only
--//Mail Bot by Phatty v2.04.5
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
--//date variable prob found by spurlos corrected
--//Spurlos - bot email, desc, speed and share added, some debbugging - yepyepyep4711 28/04/2004 --//Obselete, no tabs retabbed and redone-Phatty
--//GRRRRRR RETABBED!!!! for debugging - Phatty
--//Fixed and added tablefile check -- // Phatty
--//Fixed Nick trick --//Phatty
--//Fixed few bugs and added massmail -- // Phatty
Mail = "-HotMail-" -- // BotNAme
mcmd = "!" -- // Command prefix
MaxMails = 10; -- // Max mail per user
HMailAdmin = {"phatty","someoneelse","maybesomeoneelse"}
MailsMail = "me@hubmail.hub"
MailSpeed = "SnailMail"
MailDesc = "!help as pm for the help"
filecheckx = openfile("table.txt", "r")
if filecheckx then
assert(dofile("table.txt"))
else
Inbox = {}
end
closefile(filecheckx)
function Main()
Outbox = {}
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
MailInfoString = "$MyINFO $ALL "..Mail.." "..MailDesc.."$ $"..MailSpeed..strchar(1).."$"..MailsMail.."$".."0".."$"
end
function OnExit()
save() -- // Save mails b4 script totally clears memory
end
OpConnected = NewUserConnected; function NewUserConnected(user)
user:SendData(MailInfoString)
if Inbox[user.sName] then
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,"You have "..sumit.." message(s) - type !read to learn more")
break; end
local sumit = 0;
end;
end;
function Error(user,arg,arg2,msg,date1)
if nil == arg or "" == arg then
arg = "Please enter a user to send to!"
end;
if nil == arg2 or "" == arg2 then
arg2 = "Please enter a hmail name!"
end
if nil == msg or "" == msg then
msg = "Please enter a message to send!"
end
if nil == date1 then
date1 = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function DataArrival(user,data)
if strsub(data, 1, 5) == "$To: " then
local s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
local s,e,data = strfind(data, "%S+>(.*)") -- // old becomes obselete
if Mail == whoto then
data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
local loweruser = strlower(user.sName)
--arg = "Please enter a user to send it to!"
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if nil == arg or nil == arg2 or nil == msg then
user:SendPM(Mail,"Syntax: "..mcmd.."hmail usersnick msgname message")
return 1;
end
local arg = strlower(arg)
Error(user,arg,arg2,msg,date())
Outbox[loweruser] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1;
elseif cmd == mcmd.."send" then
local loweruser = strlower(user.sName)
towho = Outbox[loweruser][3]
mail = Outbox[loweruser][2]
thread = Outbox[loweruser][1]
date1 = Outbox[loweruser][4]
towho = strlower(towho)
if Inbox[towho] then
local count = 0;
for i,v in Inbox[towho] do
count = count + 1;
end;
if count < MaxMails then
Inbox[towho][thread] = {loweruser,mail,date1}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails",date()}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1;
end;
else
Inbox[towho] = {}
Inbox[towho][thread] = {loweruser,mail,date1}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
elseif cmd == mcmd.."read" then
local loweruser = strlower(user.sName)
if Inbox[loweruser] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0;
for i,v in Inbox[loweruser] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[loweruser][argx] then
local dFrom = Inbox[loweruser][argx][1]
local dMessage = Inbox[loweruser][argx][2]
local dDate = Inbox[loweruser][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[loweruser] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
local loweruser = strlower(user.sName)
if Inbox[loweruser] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[loweruser][argx] then
Inbox[loweruser][argx] = {}
Inbox[loweruser][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[loweruser] do
user:SendPM(Mail,i)
end;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."massmail" then
if HMailAdmin[user.sName] then
local s,e,arg,msg = strfind(data,"%s+%S+%s+(%S+)%s+(.*)") -- // messagename/message
if nil == arg or nil == msg then
user:SendPM(Mail,"Syntax: "..mcmd.."massmail msgname message")
return 1;
end
Error(user,"All users",arg,msg,date())
for muh,hah in Inbox do
Inbox[muh][arg] = {strlower(user.sName),msg,date()}
SendPmToNick(Inbox[muh][arg],Mail,"You have received a mass hmail from: "..user.sName..", type !read "..arg.." to view it")
end;
user:SendPM(Mail,"MassHMail successfully delivered to all known hmail accounts")
else
user:SendPM(Mail,"You do not own a HMailAdmin account")
end;
-- // elseif cmd == mcmd.."reply" then
-- // This is invalid
-- // if Inbox[user.sName] then
-- // local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
-- // if arg2 == nil then
-- // user:SendPM(Mail,"What do you want to erase?")
-- // elseif msg == nil then
-- // user:SendPM(Mail,"Send What??")
-- // else
-- // Error(user,arg,arg2,msg)
-- // Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
-- // user:SendPM(Mail,"Confirm and send by typing !send")
-- // end;
-- // end;
end; end; end; end;
function ShowMail(user,arg,arg2,msg,date1)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end;
write("},\n")
end;
write("\t},\n")
end;
write("}")
writeto()
end;
ok ok I give up
what files should I have to run this script?
I have ptokax3.2.6 td4 and the hotmail.lua and table.txt
I had to create table.txt myself (I thought that must have been right cause the error stops)
I then do this
[17:25] !hmail sid testing sending a test message
[17:25] <-HotMail->
To: sid
Date/Time: 05/17/04 17:25:05
Thread: testing
Message: sending a test message
[17:25] <-HotMail-> Confirm and send by typing !send
[17:25] !send
then it doesnt send?????
whats missing?????? please :(
hmmm well how many users in hub seems to slow the sending down....so give it some time, and dont restat scripts, remember td4 wont save the mail on reboot, i will add forcesave command for td4
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
Syntax Error: attempt to index global `Inbox' (a nil value)
this is after waiting 15 minutes. I dont understand it.
hmm ok lets try inbox in function then
--//Mail Bot by Phatty v2.04.5
--//Please dont remove credits, you may use in you script package as loing as u follow the conditions
--//This bot comes as is...
--//Credits must be given...
--//Give me more time i got more commands to ad :-P
--//date variable prob found by spurlos corrected
--//Spurlos - bot email, desc, speed and share added, some debbugging - yepyepyep4711 28/04/2004 --//Obselete, no tabs retabbed and redone-Phatty
--//GRRRRRR RETABBED!!!! for debugging - Phatty
--//Fixed and added tablefile check -- // Phatty
--//Fixed Nick trick --//Phatty
--//Fixed few bugs and added massmail -- // Phatty
Mail = "-HotMail-" -- // BotNAme
mcmd = "!" -- // Command prefix
MaxMails = 10; -- // Max mail per user
HMailAdmin = {"phatty","someoneelse","maybesomeoneelse"}
MailsMail = "me@hubmail.hub"
MailSpeed = "SnailMail"
MailDesc = "!help as pm for the help"
function Main()
local filecheckx = openfile("table.txt", "r")
if filecheckx then
assert(dofile("table.txt"))
else
Inbox = {}
end
closefile(filecheckx)
Outbox = {}
frmHub:UnregBot(Mail)
frmHub:RegBot(Mail)
MailInfoString = "$MyINFO $ALL "..Mail.." "..MailDesc.."$ $"..MailSpeed..strchar(1).."$"..MailsMail.."$".."0".."$"
end
function OnExit()
save() -- // Save mails b4 script totally clears memory
end
OpConnected = NewUserConnected; function NewUserConnected(user)
user:SendData(MailInfoString)
if Inbox[user.sName] then
local sumit = 0;
for i,v in Inbox[user.sName] do
sumit = sumit + 1;
user:SendPM(Mail,"You have "..sumit.." message(s) - type !read to learn more")
break; end
local sumit = 0;
end;
end;
function Error(user,arg,arg2,msg,date1)
if nil == arg or "" == arg then
arg = "Please enter a user to send to!"
end;
if nil == arg2 or "" == arg2 then
arg2 = "Please enter a hmail name!"
end
if nil == msg or "" == msg then
msg = "Please enter a message to send!"
end
if nil == date1 then
date1 = "unknown"
end
local tmp = "\r\n\r\n"
tmp = tmp.."\tTo: "..arg.."\r\n"
tmp = tmp.."\tDate/Time: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function DataArrival(user,data)
if strsub(data, 1, 5) == "$To: " then
local s,e,whoto,from,data = strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)%s+(.*)")
local s,e,data = strfind(data, "%S+>(.*)") -- // old becomes obselete
if Mail == whoto then
data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"(%S+)")
if cmd == mcmd.."hmail" then
local loweruser = strlower(user.sName)
--arg = "Please enter a user to send it to!"
local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
if nil == arg or nil == arg2 or nil == msg then
user:SendPM(Mail,"Syntax: "..mcmd.."hmail usersnick msgname message")
return 1;
end
local arg = strlower(arg)
Error(user,arg,arg2,msg,date())
Outbox[loweruser] = {arg2,msg,arg,date()}
user:SendPM(Mail,"Confirm and send by typing !send")
return 1;
elseif cmd == mcmd.."send" then
local loweruser = strlower(user.sName)
towho = Outbox[loweruser][3]
mail = Outbox[loweruser][2]
thread = Outbox[loweruser][1]
date1 = Outbox[loweruser][4]
towho = strlower(towho)
if Inbox[towho] then
local count = 0;
for i,v in Inbox[towho] do
count = count + 1;
end;
if count < MaxMails then
Inbox[towho][thread] = {loweruser,mail,date1}
else
local thread = "inboxfull"
Inbox[towho][thread] = {"HubMaster","You have reached your inbox limit, please delete some hmails",date()}
user:SendPM(Mail,"Sorry the user you tried to mail has not enough room to recieve the mail, please try again soon")
return 1;
end;
else
Inbox[towho] = {}
Inbox[towho][thread] = {loweruser,mail,date1}
end
user:SendPM(Mail,"Message has been confirmed and sent")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"You have received a hmail from: "..user.sName..", type !read "..thread.." to view it")
end
elseif cmd == mcmd.."read" then
local loweruser = strlower(user.sName)
if Inbox[loweruser] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0;
for i,v in Inbox[loweruser] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
elseif Inbox[loweruser][argx] then
local dFrom = Inbox[loweruser][argx][1]
local dMessage = Inbox[loweruser][argx][2]
local dDate = Inbox[loweruser][argx][3]
ShowMail(user,dFrom,argx,dMessage,dDate)
else
user:SendPM(Mail,"Message Names are as follows:")
local sumit = 0
for i,v in Inbox[loweruser] do
sumit = sumit + 1;
user:SendPM(Mail,sumit.." - "..i)
end;
local sumit = 0;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."del" then
local loweruser = strlower(user.sName)
if Inbox[loweruser] then
local s,e,arg,argx = strfind(data,"(%S+)%s+(%S+)")
if argx == nil then
user:SendPM(Mail,"What do you want to erase?")
elseif Inbox[loweruser][argx] then
Inbox[loweruser][argx] = {}
Inbox[loweruser][argx] = nil
user:SendPM(Mail,"Succesfully deleted: "..argx.." from your inbox!")
else
user:SendPM(Mail,"Message Names are as follows:")
for i,v in Inbox[loweruser] do
user:SendPM(Mail,i)
end;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"You have 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Send a message to a user\r\n"
tmp = tmp.."\t!send - Confirm the message to be sent from outbox!\r\n"
tmp = tmp.."\t!read - Lists your inbox\r\n"
tmp = tmp.."\t!read - Reads a message from inbox!\r\n"
tmp = tmp.."\t!del - Delete a message from inbox!\r\n"
tmp = tmp.."\t!help - This help stupid!\r\n"
user:SendPM(Mail,tmp)
elseif cmd == mcmd.."massmail" then
if HMailAdmin[user.sName] then
local s,e,arg,msg = strfind(data,"%s+%S+%s+(%S+)%s+(.*)") -- // messagename/message
if nil == arg or nil == msg then
user:SendPM(Mail,"Syntax: "..mcmd.."massmail msgname message")
return 1;
end
Error(user,"All users",arg,msg,date())
for muh,hah in Inbox do
Inbox[muh][arg] = {strlower(user.sName),msg,date()}
SendPmToNick(Inbox[muh][arg],Mail,"You have received a mass hmail from: "..user.sName..", type !read "..arg.." to view it")
end;
user:SendPM(Mail,"MassHMail successfully delivered to all known hmail accounts")
else
user:SendPM(Mail,"You do not own a HMailAdmin account")
end;
-- // elseif cmd == mcmd.."reply" then
-- // This is invalid
-- // if Inbox[user.sName] then
-- // local s,e,arg,arg2,msg = strfind(data,"%s+%S+%s+(%S+)%s+(%S+)%s+(.*)")
-- // if arg2 == nil then
-- // user:SendPM(Mail,"What do you want to erase?")
-- // elseif msg == nil then
-- // user:SendPM(Mail,"Send What??")
-- // else
-- // Error(user,arg,arg2,msg)
-- // Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
-- // user:SendPM(Mail,"Confirm and send by typing !send")
-- // end;
-- // end;
end; end; end; end;
function ShowMail(user,arg,arg2,msg,date1)
local tmp = "\r\n\r\n"
tmp = tmp.."\tFrom: "..arg.."\r\n"
tmp = tmp.."\tTime/Date: "..date1.."\r\n"
tmp = tmp.."\tThread: "..arg2.."\r\n"
tmp = tmp.."\tMessage: "..msg.."\r\n"
user:SendPM(Mail,tmp)
return 1;
end;
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end;
write("},\n")
end;
write("\t},\n")
end;
write("}")
writeto()
end;
Syntax Error: attempt to index global `Inbox' (a nil value)
still the same error!
This came up aswell after 35 minutes
Syntax Error: bad argument #1 to `strfind' (string expected, got nil)
How can i help you work out the answer?
We really would like this to work.
QuoteOriginally posted by jsjen
Syntax Error: attempt to index global `Inbox' (a nil value)
still the same error!
This came up aswell after 35 minutes
Syntax Error: bad argument #1 to `strfind' (string expected, got nil)
How can i help you work out the answer?
We really would like this to work.
try diable other scripts until ya have tested and if works tell me, and maybe i come by hub and take a look =)
Nice one Phatty Keep those scripts coming
8)
Laterzzzzzz :o)
I GOT IT. lol I sat and read the script for about 2 hours trying to work out what was going on.
and this was the key (lol)
function Main()
local filecheckx = openfile("table.txt", "r")
if filecheckx then
assert(dofile("table.txt"))
else
Inbox = {}
end
closefile(filecheckx)
Outbox = {}
in the table.txt I had to put Inbox = {} and Outbox = {}
is there anything else that is meant to be in that file?
are there meant to be other files apart from the -hotmail-.lua and table.txt
I love it thanks mate
yeh just Inbox, outbox is in script as its only temp storage for user
I was wondering. if they message were meant to be saved to the txt file
jsjen
i,m not sure if it is the meaning that the messages got saved to a txt file but it sure looks like it :-)
function save()
writeto("table.txt")
write("Inbox = {\n")
for a,b in Inbox do
write("\t[\""..a.."\"] = {\n")
for c,d in Inbox[a] do
write("\t\t[\""..c.."\"] = {")
for e,f in Inbox[a][c] do
write("\""..f.."\",")
end;
write("},\n")
end;
write("\t},\n")
end;
write("}")
writeto()
but what i didnt saw was that the message was removed iafter they are read or that the mailbox was flushed after an certain period of time.
this looks something that needs looking after because if your users mail a lot you get a huge filedatabase .
hmmm after reading the script a bit more carefull i noticed
a maximum amount of mails users can receive it was set to 10 after that when someone tries to mail that user
he gets a message that his mailbox was fulland the message couldnt be send :-) [nice work phatty]
and if i,m correct the users who mailbox was full gets a message that he needs to clean his messagebox.