--FreshStuff v.2.0
--You need a folder called "txt" in your Ptokax scripts folder, like this /scripts/txt/
--Name this bot to anything you like
bot = "[gG?]Network"
--Name the commands to what U like
--This command adds stuff, syntax : +addalbum THESTUFF
cmd1 = "+addalbum"
--This command shows the stuff, syntax : +albums THESTUFF
cmd2 = "+albums"
--This command deletes an entry, syntax : +delalbum THESTUFFNUMBER
cmd3 = "+delalbum"
File1 = "AlbumsAll.txt"
File2 = "AlbumsConnect.txt"
function Main()
frmHub:RegBot(bot)
end
newtunes={}
curtime = date("[%d-%m-%Y]")
function NewUserConnected(curUser)
DoNotOpenFile(curUser, File2)
end
function OpConnected(curUser)
DoNotOpenFile(curUser, File2)
end
function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
if (strfind(strlower(data), strlower(cmd1))) and curUser.bOperator then
s,e,cmd,tune = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
if ( tune == nil or tune == "" ) then
curUser:SendPM(bot, " If you want to add a tune type +addalbum YOURSTUFF in main chat ")
return 1
else
ReadTunes1(File1)
curtune=" [gG?] "..tune.." "
newtunes[1]=curtune
SendToAll(newtunes[1])
WriteAddtunes1(File1)
WriteNewTunes1(File2)
return 1
end
end
if (strfind(strlower(data), strlower(cmd2))) then
OpenFile(curUser, File1)
end
if (strfind(strlower(data), strlower(cmd3))) and curUser.bOperator then
if curUser.bOperator then
s,e,cmd,num = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
num2=tonumber (num)
if ( num2 == nil ) then
curUser:SendPM(bot, " To delete a Tune type +delalbum THESTUFFNUMBER!!! in main chat ")
return 1
else
ReadTunes2(File1)
newtunes[num2]=nil
curUser:SendPM(bot, " Tune Nr. "..num2.." was deleted.")
WriteAddtunes1(File1)
WriteNewTunes1(File2)
return 1
end
end
end
end
end
----------------------------------------------------------------------
function ReadTunes1(File1)
local handle = openfile("txt/"..File1, "r")
if (handle) then
local line = read(handle)
while line do
s,e,ind,val = strfind( line, "(%S+)%s+(.*)")
ind = ind+1
newtunes[ind]=val
line = read(handle)
end
closefile(handle)
end
end
----------------------------------------------------------------------
function ReadTunes2(File1)
local handle = openfile("txt/"..File1, "r")
var1 = 0
if (handle) then
local line = read(handle)
while line do
var1 = var1 +1
s,e,ind,val = strfind( line, "(%S+)%s+(.*)")
newtunes[var1]=val
line = read(handle)
end
closefile(handle)
end
end
----------------------------------------------------------------------
function WriteAddtunes1(File1)
local handle = openfile("txt/"..File1, "w")
var2 = 0
for index, value in newtunes do
var2 = var2+1
write(handle,var2.." "..value.."\r\n")
if var2 == 20 then
break
end
end
closefile(handle)
end
----------------------------------------------------------------------
function WriteNewTunes1(File2)
local handle = openfile("txt/"..File2, "w")
var3 = 0
for index, value in newtunes do
var3 = var3+1
write(handle,var3.." "..value.."\r\n")
if var3 == 5 then
break
end
end
closefile(handle)
end
----------------------------------------------------------------------
function OpenFile(curUser, File)
local msgfromtxt ="\r\n"
readfrom("txt/"..File)
while 1 do
local line = read()
if ( line == nil ) then
break
else
msgfromtxt = msgfromtxt.." "..line.."\r\n"
end
end
--end
curUser:SendPM(bot, "\r\n"..
"\r\n"..
" --------- The Latest Albums -------- \r\n"..
msgfromtxt.."\r\n"..
" --------- The Latest Albums -------- \r\n"..
"\r\n")
readfrom()
end
--------------------------------------------------------------------------------
hi.. this script works yea but i want it to do one more thing to make it perfect.. u c wen i add something like Name - Text and then hit the command +albums, the txt comes at the top (number 1). this can be a problem if there are lots of them cse the new ones wont show and the old ones wil be at the bottom. so i was wondering.. is there a way to make it come at the bottom wen u addalbum instead of the top... plzzz help.. cheers :))