Mailbot doesnt PM User by new Mail
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Mailbot doesnt PM User by new Mail

Started by Psycho_Chihuahua, 01 August, 2004, 16:39:59

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Psycho_Chihuahua

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;
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

pHaTTy

Resistance is futile!

SMF spam blocked by CleanTalk