i'm stuck in conversion Lua 4 to 5
 

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

i'm stuck in conversion Lua 4 to 5

Started by Psycho_Chihuahua, 22 April, 2006, 18:29:52

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Psycho_Chihuahua

Hi there me again  ;D

I've been asked to convert this darn bot (a type of wishboard) and i dont know where i've gone wrong. No errors but it doesn't work either

botname = "HubBot"
bot_email = "HubBot@HELVETIA" 
bot_speed = "GanjaLan(ThC)" 
bot_descr = "Schreib #wunsch als PM an HubBot." 
bot_share_size = 0 * 1024 *1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email
TimeSpanInMinutes = 360 --//Hier die Zeit eintragen

function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email.. 
"$"..bot_share_size.."$"
SetTimer(TimeSpanInMinutes*33000) 
StartTimer() 
end

function NewUserConnected(curUser) 
curUser:SendData( my_info_string ) 
end 

function OpConnected(curUser) 
curUser:SendData( my_info_string ) 
end

function OnTimer() 

--//Notiere dass eine "|" die neue zeile ausradiert

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HIHO!!!!, Ich bin das hubinterne Wunschbrett.")
SendToAll("    Suchst du etwas bestimmtes???")
SendToAll("    W?nsche es!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  Um eine Datei zu w?nschen schreibe #wunsch Als PM")
SendToAll("  an HubBot.  Versuche so genau wie m?glich zu sein.")
SendToAll("  Guck hier ?fters mal vorbei um zu sehen ob jemand die Datei hat f?r dich. PM mit !lesen an HubBot")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

function tokenize (inString,token)
_WORDS = {}
local matcher = "([^?"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end

function GetArgs(data)
s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
return arg,arg2
end

function DataArrival(user, data)
if(string.sub(data, 1, 4) == "$To:") then
data=string.sub(data,1,string.len(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="#wunsch") then
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname,"    Dies ist Das hubinterne Wunschbrett!")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Schreibe #wunsch um diese Hilfe zu lesen.")
user:SendPM(botname," Schreibe !wunsch <datei> um eine Datei zu w?nschen.")
user:SendPM(botname," Schreibe !lesen um gepostete W?nsche/Updates zu lesen.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Versuche so genau wie m?glich zu sein.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")


elseif (cmd=="!wunsch") then
SendToAll("***Neuer Wunsch hinzugef?gt***")
arg= GetArgs(data)
local handle=openfile("request.dat","a")
write(handle,"("..user.sName..") sucht nach :"..arg.."?")
user:SendPM(botname,"Wunsch Eingabe gespeichert ....")
closefile(handle)


elseif (cmd=="!lesen") then
handle2=openfile("request.dat","r")
if (handle2==nil) then
else
line = read(handle2,"*a")
line=string.sub(line,1,string.len(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
user:SendPM(botname,linearray[i])
end
closefile(handle2)
end

end
end
end
end
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Madman

#1
First of...
DataArrival should be ToArrival
and
if(string.sub(data, 1, 4) == "$To:") then
and it's end can be removed

Now.. The file handling...
First of... Swear! and curse at filehandling ;) it's always been a bitch to convert...
instead of openfile we now use io.open
write(handle, "text") is changed to handle:write("text")
closefile:(handle) is now handle:close()

*** Side note, handle can be changed to anything, most ppl use file

Post your progress.... =)

*Edit*
Btw.. U missed a strfind...
And... Get it tabbed... ;p make's it easier to read...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Markitos

TimeSpanInMinutes = 360 --//Hier die Zeit eintragen

function Main()
	frmHub:RegBot("HubBot",1,"Schreib #wunsch als PM an HubBot." , "HubBot@HELVETIA")
	SetTimer(TimeSpanInMinutes*33000)
	StartTimer()
end

function OnTimer()
--//Notiere dass eine "|" die neue zeile ausradiert

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HIHO!!!!, Ich bin das hubinterne Wunschbrett.")
SendToAll("    Suchst du etwas bestimmtes???")
SendToAll("    W?nsche es!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  Um eine Datei zu w?nschen schreibe #wunsch Als PM")
SendToAll("  an HubBot.  Versuche so genau wie m?glich zu sein.")
SendToAll("  Guck hier ?fters mal vorbei um zu sehen ob jemand die Datei hat f?r dich. PM mit !lesen an HubBot")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

function tokenize (inString,token)
	_WORDS = {}
	local matcher = "([^?"..token.."]+)"
	string.gsub(inString, matcher, function (w) table.insert(_WORDS,w) end)
	return _WORDS
end

function GetArgs(data)
	local s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
	return arg,arg2
end

function ToArrival(user, data)
		local s,e,whoTo = string.find(data,"$To:%s+(%S+)")
		if (whoTo == botname) then
			local s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
			if (cmd=="#wunsch") then
				user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
				user:SendPM(botname,"    Dies ist Das hubinterne Wunschbrett!")
				user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
				user:SendPM(botname," Schreibe #wunsch um diese Hilfe zu lesen.")
				user:SendPM(botname," Schreibe !wunsch <datei> um eine Datei zu w?nschen.")
				user:SendPM(botname," Schreibe !lesen um gepostete W?nsche/Updates zu lesen.")
				user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
				user:SendPM(botname," Versuche so genau wie m?glich zu sein.")
				user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			elseif (cmd=="!wunsch") then
				SendToAll("***Neuer Wunsch hinzugef?gt***")
				arg= GetArgs(data)
				local file= io.open("request.dat","a+")
				file:write(("..user.sName..") sucht nach :"..arg.."?")
				user:SendPM(botname,"Wunsch Eingabe gespeichert ....")
				file:close()
			elseif (cmd=="!lesen") then
				file2=io.open("request.dat","r")
				if (file2==nil) then
					else
						line = io.read(handle2,"*a")
						line=string.sub(line,1,string.len(line)-1)
						linearray=tokenize(line,"?")
						for i=1,linearray.n do
							user:SendPM(botname,linearray[i])
						end
						io.close(file2)
				end
			end
		end
end


That's my progress...not tested.

Psycho_Chihuahua

Well heres my go at it - everything works except the read bit - if i use the !lesen cmd the script crashes [ [21:11] Syntax ...\Desktop\0.3.4.0f0.Lua5.02.dbg\scripts\wunschbot.lua:83: bad argument #1 to `read' (invalid option) ]

Oh and i did a bit of tabbing (but it still looks like crap)
botname = "HubBot"
bot_email = "HubBot@HELVETIA" 
bot_speed = "GanjaLan(ThC)" 
bot_descr = "Schreib #wunsch als PM an HubBot." 
bot_share_size = 0 * 1024 *1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email
TimeSpanInMinutes = 360 --//Hier die Zeit eintragen

function Main()
	frmHub:RegBot(botname)
		my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email.. 
		"$"..bot_share_size.."$"
		SetTimer(TimeSpanInMinutes*33000) 
	StartTimer() 
end

function NewUserConnected(curUser) 
	curUser:SendData( my_info_string ) 
end 

function OpConnected(curUser) 
	curUser:SendData( my_info_string ) 
end

function OnTimer() 

--//Notiere dass eine "|" die neue zeile ausradiert

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HIHO!!!!, Ich bin das hubinterne Wunschbrett.")
SendToAll("    Suchst du etwas bestimmtes???")
SendToAll("    W?nsche es!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  Um eine Datei zu w?nschen schreibe #wunsch Als PM")
SendToAll("  an HubBot.  Versuche so genau wie m?glich zu sein.")
SendToAll("  Guck hier ?fters mal vorbei um zu sehen ob jemand die Datei hat f?r dich. PM mit !lesen an HubBot")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

function tokenize (inString,token)
		_WORDS = {}
	local matcher = "([^?"..token.."]+)"
		gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
	return _WORDS
end

function GetArgs(data)
		s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
	return arg,arg2
end

function ToArrival(user, data)
		if(string.sub(data, 1, 4) == "$To:") then
			data=string.sub(data,1,string.len(data)-1)
			s,e,whoTo = string.find(data,"$To:%s+(%S+)")
		if (whoTo == botname) then
			s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="#wunsch") then
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname,"    Dies ist Das hubinterne Wunschbrett!")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname," Schreibe #wunsch um diese Hilfe zu lesen.")
			user:SendPM(botname," Schreibe !wunsch <datei> um eine Datei zu w?nschen.")
			user:SendPM(botname," Schreibe !lesen um gepostete W?nsche/Updates zu lesen.")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname," Versuche so genau wie m?glich zu sein.")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")


elseif (cmd=="!wunsch") then
	SendToAll("***Neuer Wunsch hinzugef?gt***")
		arg= GetArgs(data)
	local file=io.open("request.dat","a")
		file:write(""..user.sName.." sucht nach :"..arg.."?")
			user:SendPM(botname,"Wunsch Eingabe gespeichert ....")
			file:close()
		elseif (cmd=="!lesen") then
			file2=io.open("request.dat","r")
		if (file2==nil) then
	else
		line = io.read(file2,"*a")
		line=string.sub(line,1,string.len(line)-1)
		linearray=tokenize(line,"?")
	for i=1,linearray.n do
		user:SendPM(botname,linearray[i])
		end
	file2:close()
end

end
end
end
end
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

jiten

Just as an addition to what has been said:

- linearray.n should be replaced with table.getn(linearray);
- There's no need to parse whoTo twice, as well as From:

Regarding Markitos' code:

- botname must be set, or else, the script won't "work";
- In !lesen command, to read all file's content it should be: file2:read("*all"); also, mind the file vars (file2 ~= handle2);
- In the same command, you should close the file with: file2:close();
- In !wunsch command, there should be a if to make sure that args exists;
- If you don't string.sub ToArrival's data, you must include the endpipe in your string.find's.

There are other things that could be changed, but, these are the critical ones.

jiten

Quote from: Psycho_Chihuahua on 22 April, 2006, 20:15:33
Well heres my go at it - everything works except the read bit - if i use the !lesen cmd the script crashes [ [21:11] Syntax ...\Desktop\0.3.4.0f0.Lua5.02.dbg\scripts\wunschbot.lua:83: bad argument #1 to `read' (invalid option) ]

Try this:

local line = file2:read("*all")

Psycho_Chihuahua

#6
Quote from: jiten on 22 April, 2006, 20:25:33
Quote from: Psycho_Chihuahua on 22 April, 2006, 20:15:33
Well heres my go at it - everything works except the read bit - if i use the !lesen cmd the script crashes [ [21:11] Syntax ...\Desktop\0.3.4.0f0.Lua5.02.dbg\scripts\wunschbot.lua:83: bad argument #1 to `read' (invalid option) ]

Try this:

local line = file2:read("*all")


na this damn script still keeps crashing :(

[ :83: bad argument #1 to `read' (invalid option) ]

The good thing is that everything else works: as in - if no file request.dat is created -- wishes are saved to request.dat

but it just don't like reading it
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

jiten

Quote from: Psycho_Chihuahua on 22 April, 2006, 20:32:20
na this damn script still keeps crashing :(

[ :83: bad argument #1 to `read' (invalid option) ]

Regarding your code:

- In !lesen, replace line = io.read(file2,"*a") with local line = file2:read("*all");
- Again in !lesen, replace linearray.n with table.getn(linearray);
- In your tokenize function, replace tinsert with table.insert, and gsub with string.gsub.

Psycho_Chihuahua

thanks jiten that did the trick ;) it works fine now  :o
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Markitos

They still dont work...
sBot = "Bot"
iTimeSpanInMinutes = 360 --//Hier die Zeit eintragen

function Main()
	frmHub:RegBot(sBot,1,"Schreib #wunsch als PM an HubBot." , "HubBot@HELVETIA")
	SetTimer(iTimeSpanInMinutes*33000)
	StartTimer()
end

function OnTimer()
--//Notiere dass eine "|" die neue zeile ausradiert
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HIHO!!!!, Ich bin das hubinterne Wunschbrett.")
SendToAll("    Suchst du etwas bestimmtes???")
SendToAll("    W?nsche es!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  Um eine Datei zu w?nschen schreibe #wunsch Als PM")
SendToAll("  an HubBot.  Versuche so genau wie m?glich zu sein.")
SendToAll("  Guck hier ?fters mal vorbei um zu sehen ob jemand die Datei hat f?r dich. PM mit !lesen an HubBot")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
end

function tokenize (inString,token)
	_WORDS = {}
	local matcher = "([^?"..token.."]+)"
	string.gsub(inString, matcher, function (w) table.insert(_WORDS,w) end)
	return _WORDS
end

function GetArgs(data)
	local s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
	return arg,arg2
end

function ToArrival(user, data)
	local s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+[%!%+](%S+)|$")
	if whoTo == sBot then
		if (cmd=="wunsc") then
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname,"    Dies ist Das hubinterne Wunschbrett!")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname," Schreibe #wunsch um diese Hilfe zu lesen.")
			user:SendPM(botname," Schreibe !wunsch <datei> um eine Datei zu w?nschen.")
			user:SendPM(botname," Schreibe !lesen um gepostete W?nsche/Updates zu lesen.")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname," Versuche so genau wie m?glich zu sein.")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
		elseif (cmd=="wunsch") then
			SendToAll("***Neuer Wunsch hinzugef?gt***")
			 arg= GetArgs(data)
				local file= io.open("request.dat","a+")
				file:write(""..user.sName.." sucht nach :"..arg.."?")
				user:SendPM(botname,"Wunsch Eingabe gespeichert ....")
				file:close()
			end
		elseif (cmd=="lesen") then
			file2=io.open("request.dat","r")
			if (file2~=handle2) then
				else
					line =read("*all")
					line=string.sub(line,1,string.len(line)-1)
					linearray=tokenize(line,"?")
					for i=1,table.getn(linearray) do
						user:SendPM(botname,linearray[i])
					end
					file2:close()
			end
		end
end

Psycho_Chihuahua

This one works Markitos ;)

botname = "Wunschbrett"
bot_email = "HubBot@HELVETIA" 
bot_speed = "GanjaLan(ThC)" 
bot_descr = "Schreib #wunsch als PM an HubBot." 
bot_share_size = 0 * 1024 *1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email
TimeSpanInMinutes = 360 --//Hier die Zeit eintragen in Minuten


function Main()
	frmHub:RegBot(botname)
		my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email.. 
		"$"..bot_share_size.."$"
		SetTimer(TimeSpanInMinutes*33000) 
	StartTimer() 
end

function NewUserConnected(curUser) 
	curUser:SendData( my_info_string ) 
end 

function OpConnected(curUser) 
	curUser:SendData( my_info_string ) 
end

function OnTimer() 

--//Notiere dass eine "|" die neue zeile ausradiert

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HIHO!!!!, Ich bin das hubinterne Wunschbrett.")
SendToAll("    Suchst du etwas bestimmtes???")
SendToAll("    W?nsche es!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  Um eine Datei zu w?nschen schreibe #wunsch Als PM")
SendToAll("  an HubBot.  Versuche so genau wie m?glich zu sein.")
SendToAll("  Guck hier ?fters mal vorbei um zu sehen ob jemand die Datei hat f?r dich. PM mit !lesen an HubBot")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

function tokenize (inString,token)
		_WORDS = {}
	local matcher = "([^?"..token.."]+)"
		string.gsub(inString, matcher, function (w) table.insert(_WORDS,w) end)
	return _WORDS
end

function GetArgs(data)
		s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
	return arg,arg2
end

function ToArrival(user, data)
		if(string.sub(data, 1, 4) == "$To:") then
			data=string.sub(data,1,string.len(data)-1)
			s,e,whoTo = string.find(data,"$To:%s+(%S+)")
		if (whoTo == botname) then
			s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="#wunsch") then
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname,"    Dies ist Das hubinterne Wunschbrett!")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname," Schreibe #wunsch um diese Hilfe zu lesen.")
			user:SendPM(botname," Schreibe !wunsch <datei> um eine Datei zu w?nschen.")
			user:SendPM(botname," Schreibe !lesen um gepostete W?nsche/Updates zu lesen.")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname," Versuche so genau wie m?glich zu sein.")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
			user:SendPM(botname,"Alle Befehle an den Wunschbrett Bot sind als PM senden")
			user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")


elseif (cmd=="!wunsch") then
	SendToAll("***Neuer Wunsch hinzugef?gt***")
		arg= GetArgs(data)
	local file=io.open("request.dat","a")
		file:write(""..user.sName.." sucht nach :"..arg.."?")
			user:SendPM(botname,"Wunsch Eingabe gespeichert ....")
			file:close()
		elseif (cmd=="!lesen") then
			file2=io.open("request.dat","r")
		if (file2==nil) then
	else
		local line = file2:read("*all");
				line=string.sub(line,1,string.len(line)-1)
				linearray=tokenize(line,"?")
			for i=1,table.getn(linearray) do
				user:SendPM(botname,linearray[i])
			end
	file2:close()
end

end
end
end
end


i'm busy translating it to englisch now ;)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Markitos

Yes i know...but in order to learn i must code in my own style, create bugs and fix 'em  :)

Psycho_Chihuahua

#12
true, ok then i will wait with my one ;)


by the way in this script cmd's are to be posted as PM to the bot
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Markitos

Quote from: Psycho_Chihuahua on 22 April, 2006, 22:30:20
true, ok then i will wait with my one ;)


by the way in this script cmd's are to be posted as PM to the bot
Yes i know, that's why ToArrival exists  ;)

Psycho_Chihuahua

PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

SMF spam blocked by CleanTalk