PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: majinsoftware on 14 February, 2004, 05:31:24

Title: !network script please
Post by: majinsoftware on 14 February, 2004, 05:31:24
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
Title:
Post by: DorianG on 14 February, 2004, 13:04:39
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
Title:
Post by: NightLitch on 14 February, 2004, 13:19:47
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
Title:
Post by: Yokozuna on 14 February, 2004, 14:27:36
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
Title:
Post by: majinsoftware on 14 February, 2004, 14:54:32
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. ?(
Title:
Post by: DorianG on 15 February, 2004, 13:23:47
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.
Title:
Post by: majinsoftware on 16 February, 2004, 04:02:33
Error

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

:(

I am useing ptokax 0.3.2.6 TD 4
Title:
Post by: pHaTTy on 16 February, 2004, 04:16:52
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
Title:
Post by: pHaTTy on 16 February, 2004, 04:18:39

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

Title:
Post by: pHaTTy on 16 February, 2004, 04:20:38
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

Title:
Post by: pHaTTy on 16 February, 2004, 04:23:55
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

Title:
Post by: DorianG on 16 February, 2004, 11:52:06
Thank Phatty.
fortune that you are us that correct and solve the problems. :)
Title:
Post by: pHaTTy on 16 February, 2004, 12:23:31
QuoteOriginally posted by DorianG
Thank Phatty.
fortune that you are us that correct and solve the problems. :)

np at all glad i could help ;)
Title:
Post by: majinsoftware on 16 February, 2004, 19:58:42
Thank you pH?tt? Finaly got one that works thanks for you expert knolage.
Title:
Post by: pHaTTy on 16 February, 2004, 20:20:40
np very welcome :)