need help with modifying this script
 

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

need help with modifying this script

Started by enterence, 23 November, 2004, 05:03:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

enterence

hi there..
this is my present release bot script..
it gives me all the releases in the release.txt file...
but i only want the last 30 releases...
can someone help me with this...
any help will be appriciated...
thanks alot
sBot = "-Rls-Bot-"

timedate = date()
file = "releases.txt"

display1 = "Item"
display2 = "Description"
display3 = "Releases"

function Main()
   frmHub:RegBot(sBot)
end

function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
         _,_,cmd=strfind(data, "%b<>%s+(%S+)")

      if (cmd=="+rls") then
         ReadRelease(user, data, cmd)
         return 1

      elseif (cmd=="+add") then
         if user.bOperator or user.iProfile == 2 then
            s,e,cmd,release,desc = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

            if desc == nil then
               description = "No "..display2.." specified!"
               s,e,cmd,release = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
            else
               description = desc
            end
            if release == nil then
               user:SendData(sBot, "*** No "..display1.." specified!")
               return 1
            end

            News("By: "..user.sName.."\t Date: "..timedate.."\r\n"..display1..": "..release.."\r\n"..display2..": "..description.."\r\n")
            SendToAll(sBot, "New "..display3.." Added....By <"..user.sName.."> Type +rls in Main-Chat to show "..display1..".")
            return 1
         else
            user:SendData(sBot, "*** +add is only availible to [VIP] and above!")
            return 1
         end
      end
   end
end

function ReadRelease(user, data, cmd)
   local release = ""
   readfrom(file)
   while 1 do
   local line = read()
   if (line == nil) then
   break
   else
   release = release.."   "..line.."\r\n"
   end
   end
   user:SendPM(sBot, "\r\n\r\n".."       "..display3.."s posted by users: ".."\r\n\r\n"..release)
   readfrom()
end

function News(what)
   appendto(file)
      write(what.."\n")
   writeto()
end

NightLitch

#1
This might work, haven't tried it, did it in 5min in school so enjoy!

sBot = "-Rls-Bot-" 

timedate = date() 
file = "releases.txt" 
temp = {n=0}

display1 = "Item" 
display2 = "Description" 
display3 = "Releases" 

function Main() 
	frmHub:RegBot(sBot) 
end 

function DataArrival(user, data) 
	if (strsub(data, 1, 1) == "<" ) then 
		data=strsub(data,1,strlen(data)-1) 
		_,_,cmd=strfind(data, "%b<>%s+(%S+)") 
		if (cmd=="+rls") then 
			ReadRelease(user, data, cmd) 
			return 1 
		elseif (cmd=="+add") then 
			if user.bOperator or user.iProfile == 2 then 
				s,e,cmd,release,desc = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" ) 
				if desc == nil then 
					description = "No "..display2.." specified!" 
					s,e,cmd,release = strfind( data, "%b<>%s+(%S+)%s+(%S+)" ) 
				else 
					description = desc 
				end 
				if release == nil then 
					user:SendData(sBot, "*** No "..display1.." specified!") 
					return 1 
				end 
				News("By: "..user.sName.."\t Date: "..timedate.."\r\n"..display1..": "..release.."\r\n"..display2..": "..description.."\r\n") 
				SendToAll(sBot, "New "..display3.." Added....By <"..user.sName.."> Type +rls in Main-Chat to show "..display1..".") 
				return 1 
			else 
				user:SendData(sBot, "*** +add is only availible to [VIP] and above!") 
				return 1 
			end 
		end 
	end 
end 

function ReadRelease(user, data, cmd)
	local release = "" 
	readfrom(file) 
	while 1 do 
		local line = read() 
		if (line == nil) then 
			break 
		else 
		tinsert(temp, line)			
		end 
	end
	c1,c2 = 10, temp.n
	for i = 1,getn(temp) do
		if c1 == 10 then
			release = release.." "..temp[c2].."\r\n" 
			c1 = c1 - 1
			c2 = c2 - 1
		else
			release = release.." "..temp[c2].."\r\n" 
			c1 = c1 - 1
			c2 = c2 - 1
		end
		if c1 == 0 then break end
	end
	user:SendPM(sBot, "\r\n\r\n".." "..display3.."s posted by users: ".."\r\n\r\n"..release) 
	readfrom() 
	temp = nil 
	temp = {n=0}
end 

function News(what) 
	appendto(file) 
	write(what.."\n") 
	writeto() 
end

/NightLitch
//NL

enterence

thanks alot mate..
i found one done by nerbos and it is way more than what i wanted....
thanks alot for your time and effort.. i will use your and see how it works...
thank you soo much again ...
peace

SMF spam blocked by CleanTalk