help with releasebot
 

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

help with releasebot

Started by biggam, 07 April, 2005, 13:30:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

biggam

sup

i got release bot for lua 5 and using RC10b and Ptokax 16.09 and i want the releases to come in PM when someone connects if u understand so wen i connect it pops up im pm with all the releases. thank you

jiten

Maybe if u posted the script, it'd be easier for us to help u.
Btw, i recommend u using FreshStuff. There u had only to change this value:

-- Show latest stuff on entry 1=yes, 0=no
ShowOnEntry = 1

Cheers

biggam

kool here is the
-- -- Verry simple release script nothing fancy
-- Make a file called releases.txt in \Scripts Folder
-- Made By Optimus
-- Converted the script into LUA 5 by 6Marilyn6Manson6
-- Filehandling problem fixed by Madman

sBot = "??w-??wR?l????'?"

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

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

function Main()
	frmHub:RegBot(sBot)
end

function ChatArrival(user, data)
	if (string.sub(data, 1, 1) == "<" ) then
		data=string.sub(data,1,string.len(data)-1) 
			_,_,cmd=string.find(data, "%b<>%s+(%S+)")

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

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

				if desc == nil then
					description = "No "..display2.." specified!"
					s,e,cmd,release = string.find( 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 +new 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)
	local file = io.input(file);
	while 1 do
	local line = io.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()
	file:read()
end

function News(what)
-- 	appendto(file) 
-- 		write(what.."\n")
-- 	writeto()
	local file = io.open(file, "a+") -- "a+"
	file:write(what.."\n")
	file:close()
end

jiten

#3
Try this one:

-- Verry simple release script nothing fancy
-- Make a file called releases.txt in \Scripts Folder
-- Made By Optimus
-- converted to Lua 5 by jiten 
-- Added: Sending releases on connect to every user
-- Thanks do Dessamator for dealing with the table handling

tTable= {}

sBot = "=ReleaseBot="
timedate = os.date()
file = "releases.txt"

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

function Main()
	frmHub:RegBot(sBot)
	SetTimer(1)
	StartTimer()
end


function ChatArrival(user, data)
	data=string.sub(data,1,string.len(data)-1) 
	_,_,cmd=string.find(data, "%b<>%s+(%S+)")
	if (cmd=="!read") then
		ReadRelease(user, data, cmd)
		return 1

	elseif (cmd=="!write") then
		if user.bOperator or user.iProfile == 2 then
			s,e,cmd,release,desc = string.find( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
			if desc == nil then
				description = "No "..display2.." specified!"
				s,e,cmd,release = string.find( 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 !read in Main-Chat to show "..display1..".")
			return 1
		else
			user:SendData(sBot, "*** !write is only available to [VIP] and above!")
			return 1
		end
	end
end

function NewUserConnected(user,data)
	tTable[user.sName] = {}
	tTable[user.sName]["t"] = "1"
end

OpConnected = NewUserConnected

function News(what)
	local h = io.open(file, "a+")
	if h then
		h:write(what.."\n")
		h:close()
	else
		user:SendPM(sBot,file.." doesn't exist")
	end
end

function ReadRelease(user, data, cmd)
	local release = ""
	local f = io.open(file, "r")
	if f then
		while 1 do
			local line = f:read()
			if (line == nil) then 
				break
			else
				release = release.."	"..line.."\r\n"
			end
		end
		f:close()
		msg = ("\r\n\r\n".."       "..display3.."s posted by users: ".."\r\n\r\n"..release)
		user:SendPM(sBot,msg)
	else
		user:SendPM(sBot,file.." doesn't exist")
	end
end

function OnTimer()
	local release = ""
	local f = io.open(file, "r")
	if f then
		while 1 do
			local line = f:read()
			if (line == nil) then 
				break
			else
				release = release.."	"..line.."\r\n"
			end
		end
		f:close()
		msg = ("\r\n\r\n".."       "..display3.."s posted by users: ".."\r\n\r\n"..release)
		
		local i,v
		for i,v in tTable do
			score = tTable[i]["t"]
			score = score - 1
			tTable[i]["t"] =score
			if tTable[i]["t"] == 0 then
				GetItemByName(i):SendPM(sBot,msg)
			end
		end
	end
end

*EDIT* Less "PtokaX like" eheh
Cheers

biggam


jiten

#5
Firstly, add a release and then reconnect.
It u did it correctly, something like this will popup when reconnecting:

[15:16] <=ReleaseBot=> 

       Releasess posted by users: 

	By: jiten	 Date: 04/07/05 15:15:26
	Item: Test
	Description: No Description specified!

If u didn't, this will appear:

[15:15] <=ReleaseBot=> releases.txt doesn't exist

Cheers

biggam

nah i did do it right i added something then when i reconect nothing happen nothing ops up

biggam


biggam


biggam

acctually it comes up but not in PM it comes up in mainchat before the MOTD and all that.

Thank You

Herodes

biggam: you can edit your posts too ,.. prevents post mologue ;)
QuoteOriginally posted by biggam
acctually it comes up but not in PM it comes up in mainchat before the MOTD and all that.

Thank You
jiten: this sounds like a PtokaX way to do things. First let the scripts do their stuff and then PtokaX shall do its own.. and because you are sending the data on NewUserConnected it comes up before the MOTD and stuff ..

biggam

okay... so wat should i do...

jiten

Quotejiten: this sounds like a PtokaX way to do things. First let the scripts do their stuff and then PtokaX shall do its own.. and because you are sending the data on NewUserConnected it comes up before the MOTD and stuff ..

I understood the NewUserConnected and data coming up before MOTD part but, I still got some doubts how to mod this script so that it wouldn't happen in case I used SendData.
Can u explain/show it so that I could learn a bit more?

biggam

Who you asking me or Herodes? kool

jiten

QuoteOriginally posted by biggam
Who you asking me or Herodes? kool

Herodes...  :D

Herodes

Maybe putting the messages and the nick in a table with a predifined countdown. reading through the following script may give you the idea I am trying to pass..
tTable= {
	["nick_of_user"] = { ["timeleft"] = 5, ["msg"] = "data to send" },
}
Bot = "thenameofthebot"
function Main()
	SetTimer(1000)
	StartTimer()
end

function OnTimer()
	for i,v in tTable do
		v.timeleft = v.timeleft-1
		if v.timeleft == 0 then
			SendToNick( i, "thenameofthebot", v.msg )
			tTable[i] = nil;
		end
	end
end

biggam

yo man can't you just give me a script that is a release bot that will come up in Private message on connect to every user profile. thank you.

btw the script you already gave me worked once then when i reconect it came up before the MOTD and it says private message from release bot :...... but in maint chat.

  :]

jiten

QuoteOriginally posted by biggam
yo man can't you just give me a script that is a release bot that will come up in Private message on connect to every user profile. thank you.

btw the script you already gave me worked once then when i reconect it came up before the MOTD and it says private message from release bot :...... but in maint chat.

  :]

First post updated.

Btw, have u ticked "Popup messages from users that are not online" and unticked "Ignore messages from users that are not online" in File - Settings - Advanced ?
Maybe, that's the reason for the private messages to appear in main chat.

Cheers

SMF spam blocked by CleanTalk