Add example logout stanza for RiPuk's bbs ad archive

This commit is contained in:
Andrew Pamment 2017-10-17 16:11:14 +10:00
parent 7feead5819
commit 1b0c1a6906

View File

@ -0,0 +1,40 @@
-- To use this with Magicka, replace the logout_stanza.lua in your
-- MagickaBBS/scripts directory.
-- You could also git pull as a cronjob to grab the latest ansis say
-- once a week.
-- Requirements:
-- You will need an uptodate git version of Magicka for it to work.
function scandir(directory)
local i, t, popen = 0, {}, io.popen
local pfile = popen('find "'..directory..'" -maxdepth 1 -type f')
for filename in pfile:lines() do
if string.lower(string.sub(filename, -4)) == ".ans" then
i = i + 1
t[i] = filename
end
end
pfile:close()
return t
end
function logout()
-- Change this to your adverts directory...
local t = scandir("/home/andrew/bbs-ansi-adverts/adverts");
local rand = math.random(#t);
bbs_write_string("\027[2J");
bbs_display_ansi(t[rand]);
bbs_write_string("\027[0mPress any key to continue...");
bbs_read_char();
bbs_write_string("\027[2J");
bbs_display_ansi("goodbye");
os.execute("sleep 1");
return 1;
end