aboutsummaryrefslogtreecommitdiff
path: root/telem.lua
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2018-12-08 17:34:00 +0000
committerSolderpunk <solderpunk@sdf.org>2018-12-08 17:34:00 +0000
commita37a28d1b705a3ddee1878dc6406fb27b8eafea8 (patch)
tree0bde354a6d14544c48f2942ffc8a03ebc4c9a06d /telem.lua
parentCheck lengths of various string inputs and act accordingly in extreme cases. (diff)
Store boards not just as strings, but as tables with the topic as a member.
Diffstat (limited to 'telem.lua')
-rwxr-xr-xtelem.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/telem.lua b/telem.lua
index 9612a4b..bef5569 100755
--- a/telem.lua
+++ b/telem.lua
@@ -56,13 +56,17 @@ end
-- Internals
function update_boards()
- for board in lfs.dir(path.join(_BBS_ROOT, "boards")) do
- if string.sub(board, 1, 1) ~= "." and not board_names[board] then
- board_names[board] = true
+ for boarddir in lfs.dir(path.join(_BBS_ROOT, "boards")) do
+ if string.sub(boarddir, 1, 1) ~= "." and not board_names[boarddir] then
+ local board = {}
+ board.name = boarddir
+ board.directory = path.join(_BBS_ROOT, "boards", boarddir)
+ board.topic = file.read(path.join(board.directory, "topic"))
+ board_names[board.name] = true
table.insert(boards, board)
end
end
- table.sort(boards)
+ table.sort(boards, function(x,y) return x.name > y.name end)
end
function check_at_board()
@@ -147,9 +151,7 @@ function do_board()
local topic_file = path.join(board_dir, "topic")
file.write(topic_file, desc)
-- Update representation of BBS
- board_names[board] = true
- table.insert(boards, board)
- table.sort(boards)
+ update_boards()
-- Done!
print("Board created.")
end