Show TXT files with a CMD
 

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

Show TXT files with a CMD

Started by Event_Horizon, 21 June, 2004, 12:07:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Event_Horizon

is it possible to show a txt file in mainchat with a selfcreated CMD like /show try.txt & in mainchat will be show the filecontent.

^^ this is just an example - if there is a way to do this with a regular client (oDC / DC++)tell me how plz

THX ahead
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

Corayzon

what do u mean exactly?

do you want to files to been shown from the server directory to all users? or just to your user?

or you mean for your own program directory for bcdc?

Event_Horizon

well i'll try to explain it:

I use a MP9 plug-in for showing title & artist on websites - this plug-in creates a TXT called NP_info.txt -> contents looks like this :

The Track  - Cloudskipper - Back To The Drawing Board - CD1

Blows through Event_Horizon's ears

& I wanna get this showed in the mainchat by a command ( in my Hub & in other Hubs if possible) without changing to BCDC or any other kind of client ( using oDC)

hope u get my point
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

NightLitch

will hopefully works not tested

-- Simple Load-Text Command Bot By: NightLitch 2004/06/21

BotName = "-DEViL-"
command = "+show"

function DataArrival(curUser,data)
	if (strsub(data, 1, 1) == "<") then 
		data = strsub(data,1,strlen(data)-1)
		local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )
		if cmd==command then
			local _,_,file = strfind(data, "%b<>%s+%S+%s+(%S+)" )
			if file==nil then
				curUser:SendData(BotName, "Syntax: "..command.." filename.txt")
				return 1
			end
			curUser:SendData(BotName, TextFile(file))
			return 1
		end
	end
end

function TextFile(file)
	readfrom(file, "r")
	local message = ""
	while 1 do
		local line = read()
		if line == nil then break return "File not found"
		else
			message = message..line.."\r\n"
		end
	end
	readfrom()
	return message
end

/NL
//NL

Event_Horizon

NL i think u misunderstood me - I wanna do this with the client & not with a script

& thx for the script - maybe there is another use 4 it ;)
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

NightLitch

QuoteOriginally posted by Event_Horizon
NL i think u misunderstood me - I wanna do this with the client & not with a script

& thx for the script - maybe there is another use 4 it ;)

Ah you want a BCDC++ script of it ?
//NL

NightLitch

Only way is with a script for either PtokaX of BCDC++ or Phantom DC++ or any other Lua Client... Can't be done as far as I now with regular DC++ or oDC....
//NL

Event_Horizon

k THX

if u can give me a script 4 BCDC I'll try it
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

NightLitch

#8
Here you go hope it does what you want...

*** UPDATED ***

fixed a bug in the file opening...

---------------------------------------------------
---------------------------------------------------
-- Text-Bot by: NightLitch 2004/06/21
-- Load Diff. Text Files from a folder
-- BCDC++ Script
-- Command must be sent to Client/Hub
---------------------------------------------------
---------------------------------------------------
-- Command
Command = "+show"

-- Folder where the files being stored
Folder = "TextFiles/"
---------------------------------------------------
---------------------------------------------------
dcpp:setListener( "pm", "GetPM",
function( hub, user, text )
	local s,e,cmd,file = string.find(text, "(%S+)%s*(%S*)")
	if cmd==Command then
		if file==nil or file=="" then
			SendPM(hub, user, "Syntax: "..Command.." filename.txt")
			return 1
		end
		SendPM(hub, user, LoadText(Folder..file))
		return 1
	end
end)
---------------------------------------------------
function SendPM(hub, user, txt)
	DC():SendHubMessage( hub:getId(), "$To: "..user:getNick().." From: "..hub:getOwnNick().." $<"..hub:getOwnNick().."> "..txt.."|" )
end
---------------------------------------------------
function LoadText(file)
	local msg = ""
	str = io.open( file )
	if str==nil then 
		return file.." not found"
	else
		str:close()
		str = io.input ( file )
		for line in str:lines() do
			msg = msg..line.."\r\n"
		end
		str:close()
		return msg
	end
end
---------------------------------------------------

/NL
//NL

Event_Horizon

#9
THX alot - will try it intermedialy :D

*edit:

sorry M8 but it shows nothing ( using BCDC 401b ) & no MSGes in the debug window  ?(  ?(  ?(
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

NightLitch

QuoteOriginally posted by Event_Horizon
THX alot - will try it intermedialy :D

*edit:

sorry M8 but it shows nothing ( using BCDC 401b ) & no MSGes in the debug window  ?(  ?(  ?(

huh that was strange... works really good on my client 0.401a
//NL

NightLitch

Update:

---------------------------------------------------
---------------------------------------------------
-- Text-Bot by: NightLitch 2004/06/21
-- Can be used in Main & PM
-- Load Diff. Text Files from a folder
-- BCDC++ Script
---------------------------------------------------
---------------------------------------------------
-- Command
Command = "#show"

-- Folder where the files being stored
Folder = "TextFiles/"
---------------------------------------------------
---------------------------------------------------
dcpp:setListener( "pm", "GetPM",
function( hub, user, text )
	if Execute(hub, user, text)==1 then return 1 end
end)
---------------------------------------------------
dcpp:setListener( "chat", "GetCHAT",
function( hub, user, text )
	if Execute(hub, user, text)==1 then return 1 end
end)
---------------------------------------------------
function Execute(hub, user, text)
	local s,e,cmd,file = string.find(text, "(%S+)%s*(%S*)")
	if cmd==Command then
		if file==nil or file=="" then
			SendPM(hub, user, "Syntax: "..Command.." file   NOTE: without .txt")
			return 1
		end
		SendPM(hub, user, LoadText(Folder..file..".txt"))
		return 1
	end
end
---------------------------------------------------
function SendPM(hub, user, txt)
	DC():SendHubMessage( hub:getId(), "$To: "..user:getNick().." From: "..hub:getOwnNick().." $<"..hub:getOwnNick().."> "..txt.."|" )
end
---------------------------------------------------
function LoadText(file)
	local msg = ""
	str = io.open( file )
	if str==nil then 
		return file.." not found"
	else
		str:close()
		str = io.input ( file )
		for line in str:lines() do
			msg = msg..line.."\r\n"
		end
		str:close()
		return msg
	end
end
---------------------------------------------------
//NL

Event_Horizon

1st on works now

sorry was my mistake - didn't send the command as PM

& how can I get the file shown in mainchat not in PM ?
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

NightLitch

QuoteOriginally posted by Event_Horizon
1st on works now

sorry was my mistake - didn't send the command as PM

& how can I get the file shown in mainchat not in PM ?

gonna give you that version tomorrow... night night for now... /NL
//NL

Event_Horizon

don't forget me NL :D

wanna have some fun with it ;)
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

Event_Horizon

can someone modifi the first BCDC script to show the responce in mainchat

*** plz move this to BCDC scripting PLZ

THX
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

SMF spam blocked by CleanTalk