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
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
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
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
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. ?(
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.
Error
Syntax Error: attempt to index global `user' (a nil value)
:(
I am useing ptokax 0.3.2.6 TD 4
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
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
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
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
Thank Phatty.
fortune that you are us that correct and solve the problems. :)
QuoteOriginally posted by DorianG
Thank Phatty.
fortune that you are us that correct and solve the problems. :)
np at all glad i could help ;)
Thank you pH?tt? Finaly got one that works thanks for you expert knolage.
np very welcome :)