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
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?
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
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 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 ;)
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 ?
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....
k THX
if u can give me a script 4 BCDC I'll try it
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
THX alot - will try it intermedialy :D
*edit:
sorry M8 but it shows nothing ( using BCDC 401b ) & no MSGes in the debug window ?( ?( ?(
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
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
---------------------------------------------------
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 ?
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
don't forget me NL :D
wanna have some fun with it ;)
can someone modifi the first BCDC script to show the responce in mainchat
*** plz move this to BCDC scripting PLZ
THX