Daemon HMailer v2 by Phatty
 

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

Daemon HMailer v2 by Phatty

Started by pHaTTy, 28 March, 2004, 09:11:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pHaTTy

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,,
Resistance is futile!

pHaTTy

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
Resistance is futile!

pHaTTy

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
Resistance is futile!

[NL]trucker

phatty :-)

nice work m8 keep it coming.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


spurlos

Good stuff
Fix plz, to bot read commands from MAIN chat too..
And it some bug with "date" function in script

pHaTTy

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?
Resistance is futile!

spurlos

------- 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 -----------

pHaTTy

hmmm i will have a look soon and maybe update it somemore, btw works fine in G7.1 ;-)
Resistance is futile!

spurlos

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 ,)

yepyepyep4711

#9
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

spurlos

#10
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

yepyepyep4711

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)

spurlos

I dont understand, why troubles must become..
How much messages must be in memory, that the script won't restart?

yepyepyep4711

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

toras

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 :)
Owner of the bestest little SweHub on DC

[Sweden Rocks]  

srbc.no-ip.com

pHaTTy

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
Resistance is futile!

pHaTTy

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
Resistance is futile!

UwV?

#17
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..
Music = Love
                              &
                   plop rulez
                          (feed [en]danger[ed][ous] things so they will grow!!)  

UwV?

#18
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 .. ...
Music = Love
                              &
                   plop rulez
                          (feed [en]danger[ed][ous] things so they will grow!!)  

pHaTTy

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
Resistance is futile!

jsjen

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

UwV?

#21
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 ..
Music = Love
                              &
                   plop rulez
                          (feed [en]danger[ed][ous] things so they will grow!!)  

pHaTTy

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 =)
Resistance is futile!

UwV?

Music = Love
                              &
                   plop rulez
                          (feed [en]danger[ed][ous] things so they will grow!!)  

pHaTTy

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
Resistance is futile!

SMF spam blocked by CleanTalk