Hi
i have a little problem with this Hubmail Bot.
It's supposed to send a PM to User when he receives a "mail" but it doesn't. I cant find the mistake and hope to find some help here :) plzz
Mail = "-HotMail-" -- // BotNAme
mcmd = "!" -- // Command prefix
MaxMails = 10; -- // Max mail per user
HMailAdmin = {"Admin"}
MailsMail = "snail@hubmail.hub"
MailSpeed = "SnailMail"
MailDesc = "!help als pm f?r die hilfe"
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,"Du hast "..sumit.." nachricht(en) - schreibe !read um mehr zu erfahren")
break; end
local sumit = 0;
end;
end;
function Error(user,arg,arg2,msg,date1)
if nil == arg or "" == arg then
arg = "Gebe bitte einen User als Empf?nger ein!"
end;
if nil == arg2 or "" == arg2 then
arg2 = "Gebe bitte einen hmail namen ein!"
end
if nil == msg or "" == msg then
msg = "Gebe bitte eine Nachricht ein!"
end
if nil == date1 then
date1 = "unbekannt"
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 = "Gebe bitte einen User als Empf?nger ein!"
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,"Best?tigen und senden mit !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","Deine Inbox Limite wurde erreicht, l?sche einige hmails",date()}
user:SendPM(Mail,"Sorry der Empf?nger hat keinen Platz mehr f?r deine nachricht, versuchs sp?ter nochmal")
return 1;
end;
else
Inbox[towho] = {}
Inbox[towho][thread] = {loweruser,mail,date1}
end
user:SendPM(Mail,"Nachricht wurde best?tigt und gesendet")
if GetItemByName(towho) then
item = GetItemByName(towho)
item:SendPM(Mail,"Du hast eine Hmail bekommen von: "..user.sName..", gebe !read "..thread.." ein um sie zu lesen")
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,"Nachricht Namen sind wie folgt:")
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,"Nachricht Namen sind wie folgt:")
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,"Du hast 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,"Was willst du l?schen?")
elseif Inbox[loweruser][argx] then
Inbox[loweruser][argx] = {}
Inbox[loweruser][argx] = nil
user:SendPM(Mail,"Erfolgreich: "..argx.." aus deiner Inbox gel?scht!")
else
user:SendPM(Mail,"Nachricht Namen sind wie folgt:")
for i,v in Inbox[loweruser] do
user:SendPM(Mail,i)
end;
user:SendPM(Mail,"Syntax: !read ")
end;
else
user:SendPM(Mail,"Du hast 0 Mail")
end
elseif cmd == mcmd.."help" then
local tmp = "\r\n\r\n"
tmp = tmp.."\t!hmail - Eine Nachricht an User schreiben\r\n"
tmp = tmp.."\t!send - Best?tigen und senden der geschriebenen Nachricht!\r\n"
tmp = tmp.."\t!read - Inbox Liste\r\n"
tmp = tmp.."\t!read - Eine Nachricht aus deiner inbox lesen!\r\n"
tmp = tmp.."\t!del - Eine Nachricht aus deiner inbox l?schen!\r\n"
tmp = tmp.."\t!help - Diese Hilfe!\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,"Du hast eine mass hmail von: "..user.sName.." bekommen, gebe !read "..arg.." ein um sie zu lesen")
end;
user:SendPM(Mail,"MassHMail erfolgreich an alle hmail Konten gesendet")
else
user:SendPM(Mail,"Du hast keinen HMailAdmin Konto")
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,"Was willst du l?schen?")
-- // elseif msg == nil then
-- // user:SendPM(Mail,"Was Senden??")
-- // else
-- // Error(user,arg,arg2,msg)
-- // Outbox[user.sName] = {arg2,msg,arg,"Not Implemented"}
-- // user:SendPM(Mail,"Best?tigen und senden mit !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;
last time i checked the last 1 i released worked fine
http://board.univ-angers.fr/thread.php?threadid=1731&boardid=12&sid=f325a8a273c7802f4e7f15b6d7b578b3&page=2
-/pha