hey everyone,
i use this code to display "message" in the main chat to a user who has just connected:
function NewUserConnected(sUser)
SendToNick(sUser, "message")
end
but it doesn't seem to work.
consequently, this code for displaying a text file as the MOTD doesn't work either:
MOTD_FILE = "MOTD.txt"
function NewUserConnected(sUser)
SendToNick(sUser, TextFile(MOTD_FILE))
end
function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil the break
else
message = message..line.."\n"
end
end
readfrom()
return message
end
any help would be very appreciated!
thanks!
This should work. It gives no errors in my hub.
MOTD_FILE = "motd.txt"
function NewUserConnected(sUser)
SendPm(sUser, "message")
end
function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end
Grtzzz
DJ Bert
try this :)
motd = "MOTD.txt" -- textfile
bot = "welcome" -- botname Give it the same name as your main bot
function Main()
frmHub:RegBot(bot)
end
OpConnected = NewUserConnected
function NewUserConnected(sUser)
sUser:SendPM(bot,TextFile(motd))
end
function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end
thanks so much for your help guys!! works great now!!
here's the code:
MOTD = "MOTD.txt" -- textfile
function NewUserConnected(sUser)
sUser:SendData(TextFile(MOTD))
end
function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end