!network script please
 

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

!network script please

Started by majinsoftware, 14 February, 2004, 05:31:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

majinsoftware

Hello can some one please give me a working link or the code for a script that reads a TXT file and desplays it on main chat on command of !network

And also can you make it so it is hidden in the user list cos i dont like bots showing up in the user list it makes it look messy.

Thank you. :D

DorianG

Bot = "NetWork"		--//Set the name of bot

function Main()
end

function ReadLine()
	while 1 do
		local line = read()
		if line == nil then
			break
		else
			user:SendPM(Bot, line)	--//Send the message on PM
		end
	end
	readfrom()
end

function ReadFile()
	readfrom("files/network.txt")	--//Name of Directory (files) and name of file (network.txt)
	ReadLine()
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		local s,e,cmd = nil
		s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
		if cmd == "!network" then
			ReadFile()
		end
	end
end

Try that  ;) The Bot is hiden in the user list. And the message is sent in PM

NightLitch

Well are you sure that the bot is sending this in PM ??

My knowledge says the bot need to be registered (shown)

to be able to show the PM otherwise it just come in mainchat.

But can have missed something.

/NL
//NL

Yokozuna

It is depending on your local DC++ settings.
If you have ticked the option "Ignore messages from offline users (effective against bots)", then it is shown in main and not as a PM.
If the option is unticked, it is shown in PM.



Yokozuna

majinsoftware

#4
Thank you keep up the good work :D :D :D :D :D :D  :D
Just one problem is nothing happends on the command is it because i am useing ptokax TD4.
it doesnt come up with any errors. ?(

DorianG

Thank NightLitch,
I'm very happy when you help me.
Your experience is always respected.
I don't know very well the LUA language and your experience help me to know it good.
Thank you.

majinsoftware

Error

Syntax Error: attempt to index global `user' (a nil value)

:(

I am useing ptokax 0.3.2.6 TD 4

pHaTTy

QuoteOriginally posted by Yokozuna
It is depending on your local DC++ settings.
If you have ticked the option "Ignore messages from offline users (effective against bots)", then it is shown in main and not as a PM.
If the option is unticked, it is shown in PM.



Yokozuna

hmm no its a common big, it has nothink todo with this option, if the bot is offline u stillrecieve it in main if u have it ticked or not ;)

altho not sure about the new odc
Resistance is futile!

pHaTTy

Bot = "NetWork"		--//Set the name of bot

function ReadLine(user)
	while 1 do
		local line = read()
		if line == nil then
			break
		else
			user:SendPM(Bot, line)	--//Send the message on PM
		end
	end
	readfrom()
end

function ReadFile(user)
	readfrom("files/network.txt")	--//Name of Directory (files) and name of file (network.txt)
	ReadLine(user)
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		local s,e,cmd = nil
		s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
		if cmd == "!network" then
			ReadFile(user)
		end
	end
end
Resistance is futile!

pHaTTy

but here use this

Bot = "NetWork"		    --//Set the name of bot
Dir = "files/network.txt"   --//Name of Directory (files) and name of file (network.txt)


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

		if cmd == "!network" then
			readfrom(Dir)
			while 1 do
				local line = read()
				if line == nil then
					break
				else
					user:SendData(Bot, line)
				end
			end
			readfrom()
		end
	end
end
Resistance is futile!

pHaTTy

this is better for hdd

Bot = "NetWork"		    --//Set the name of bot
Dir = "files/network.txt"   --//Name of Directory (files) and name of file (network.txt)

Network = ""

function Main()
	NetworkLoad()
end

function NetworkLoad()
	readfrom(Dir)
	while 1 do
		local line = read()
		if line == nil then
			break
		else
			Network = Network.."\r\n"..line
		end
	end
	readfrom()
end

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

		if cmd == "!network" then
			user:SendData(Bot, Network)
		end
	end
end
Resistance is futile!

DorianG

Thank Phatty.
fortune that you are us that correct and solve the problems. :)

pHaTTy

QuoteOriginally posted by DorianG
Thank Phatty.
fortune that you are us that correct and solve the problems. :)

np at all glad i could help ;)
Resistance is futile!

majinsoftware

Thank you pH?tt? Finaly got one that works thanks for you expert knolage.

pHaTTy

np very welcome :)
Resistance is futile!

SMF spam blocked by CleanTalk