-- guestbook.lua, created by amutex 12.01.2003 --thx to nathanos for the fine pm-pasing and Dirtyfinger for tokenizing botname = "GuestBook" 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 = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)") return arg,arg2 end function Main() frmHub:RegBot(botname) end function DataArrival(user, data) if(strsub(data, 1, 4) == "$To:") then data=strsub(data,1,strlen(data)-1) s,e,whoTo = strfind(data,"$To:%s+(%S+)") if (whoTo == botname) then s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)") if (cmd=="#addGBookentry") then arg= GetArgs(data) local handle=openfile("guestbook.dat","a") write(handle,"("..user.sName..") wrote :"..arg.."§") user:SendPM(botname,"Guestbook entry saved ....") closefile(handle) end if (cmd=="#help") then user:SendPM(botname,"This is our Guestbook! Feel free to ....") end if (cmd=="#readGBook") then handle2=openfile("guestbook.dat","r") if (handle2==nil) then else line = read(handle2,"*a") line=strsub(line,1,strlen(line)-1) linearray=tokenize(line,"§") for i=1,linearray.n do user:SendPM(botname,linearray[i]) end closefile(handle2) end end end end end