registrar

Files related to my duties as Registrar of Agora Nomic
git clone git://juanmeleiro.mat.br/registrar
Log | Files | Refs | README

commit 823594ff3a8222335626be8f1a15f57e2998c4fd
parent 1b350e4017a6d79775fd7b53d4a100bd9f334250
Author: Juan F. Meleiro <juan@juanmeleiro.mat.br>
Date:   Thu, 14 Mar 2024 18:43:01 -0300

Add logic for sending writs

Diffstat:
Mlib/birthday.lua | 12------------
Mlib/utils.lua | 17++++++++++++++++-
Alib/writ.lua | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mregistrar | 9+++++++++
Atemplates/writ.m4 | 36++++++++++++++++++++++++++++++++++++
5 files changed, 122 insertions(+), 13 deletions(-)

diff --git a/lib/birthday.lua b/lib/birthday.lua @@ -5,18 +5,6 @@ local fns = { tmp = ".tmp" } -function ord(num) - if (num == 1) then - return "st" - elseif (num == 2) then - return "nd" - elseif (num == 3) then - return "rd" - else - return "th" - end -end - function announce(args, date, original) local time = { year = tonumber(string.sub(date, 1, 4)), diff --git a/lib/utils.lua b/lib/utils.lua @@ -101,7 +101,8 @@ function format_event(e) register = "Registered {who}", rename = "Changed {whither}'s name from '{who}'", weekly = "Weekly report", - activation = "Activated {who}" + activation = "Activated {who}", + writ = "Writ of FAGE for {who}" } die(not formats[e.what], string.format("No format for '%s'", e.what)) return string.format("* %s %s\n", @@ -109,3 +110,17 @@ function format_event(e) format(formats[e.what], e) ) end + +function ord(num) + if (num == 1) then + return "st" + elseif (num == 2) then + return "nd" + elseif (num == 3) then + return "rd" + else + return "th" + end +end + + diff --git a/lib/writ.lua b/lib/writ.lua @@ -0,0 +1,61 @@ +require "lib.utils" + +local fns = { + tmp = ".tmp" +} + +function cantus(args, players, log) + if not (players[args.who]) then + die("No such player.") + end + + h = table.query(p.history, function (c) return c.active end) + + if not h then + die(string.format("Player '%s' is not active.", args.name)) + end + + local monthname = os.date("%B", args.when) + local dayord = ord(tonumber(os.date("%d", args.when))) + local day = os.date("%d", args.when) + local datestring = string.format("The %s%s of %s of %d", day, dayord, monthname, os.date("%Y", args.when)) + local datepad = (string.rep(" ", (80 - string.len(datestring))//2)) + local namepad = (string.rep(" ", (80 - string.len(args.who))//2)) + + local defs = { + MAILDATE = os.date("%a, %d %b %Y %T %z"), + NAME = namepad .. args.who, + DATE = datepad .. datestring, + FILEPATH = args.cantus, + FULLTEXT = string.format("include(%s)", FILEPATH) + } + + os.execute(string.format("m4 %s templates/writ.m4 > %s", m4flags(defs), fns.tmp)) + + + if args.p then + os.execute(string.format("cat %s", fns.tmp)) + os.remove(fns.tmp) + io.write(string.format("Deregister player %s.\n", args.name)) + pprint.pprint(h) + io.write("active := nil\n") + io.write("latest := nil\n") + io.write(string.format("deregistration := %s\n", os.date("%Y-%m-%d"))) + io.write("reason := w\n") + else + os.execute(string.format("neomutt -H %s -E", fns.tmp)) + local archive_name = os.date("archive/%F-writ-") .. args.who .. ".txt" + if yn(string.format("Archive report to '%s'? [Yn] ", archive_name)) then + os.rename(fns.tmp, archive_name) + table.insert(log, {what = "writ", who = args.who, when = args.when, where = args.m}) + h.active = nil + h.deregistration = os.date("%Y-%m-%d") + h.reason = "w" + h.latest = nil + else + os.remove(fns.tmp) + end + end +end + +return cantus diff --git a/registrar b/registrar @@ -10,6 +10,7 @@ local registration = require "lib.registration" local report = require "lib.report" local birthday = require "lib.birthday" local activity = require "lib.activity" +local writ = require "lib.writ" local parser = argparse("registrar", "Manage Agora's registrar duties") parser:flag("-p", "Pretend: only show what would be done") @@ -59,6 +60,12 @@ cmd.readdress: argument ("whither", "New address") cmd.readdress: argument ("when", "When the message was received") :convert(tonumber) cmd.readdress: option ("-m", "Message ID of readdressing (without 'message://' prefix)") +cmd.writ = parser: command("writ", "Send a Writ of FAGE") +cmd.writ: argument("who", "Player that submited the Cantus Cygneus") +cmd.writ: argument("when", "Date of the message") :convert(tonumber) +cmd.writ: argument("cantus", "Path to file containing the Cantus Cygneus") +cmd.writ: option("-m", "Message ID of the cantus") + -- Deserialize local fns = { players = "players.json", @@ -89,6 +96,8 @@ elseif args.command == "rename" then registration.rename(args, players, log) elseif args.command == "readdress" then registration.readdress(args, players, log) +elseif args.command == "writ" then + writ(args, players, log) else io.write("Unknown command.\n") end diff --git a/templates/writ.m4 b/templates/writ.m4 @@ -0,0 +1,36 @@ +Date: MAILDATE +From: juan <juan@juanmeleiro.mat.br> +To: <agora-official@agoranomic.org> +Subject: [Registrar] Writ of FAGE +=============================================================================== +`Registrar: juan Writ of FAGE 'esyscmd(date +%Y-%m-%d | tr -d '\n') +=============================================================================== + + On the date of + +DATE + + the player known as + +NAME + + has submited to me, the Registrar, a + + CANTUS CYGNEUS + + reproduced in its entirety below. As required of me by Rule 1789, by the rules + in general, by Agora, and by the integrity of this office, I put forth this + + WRIT OF + FUNGIDAE AGORAE + GRANDISSIMA EXPROBRATIONE + + thusly commanding that e be deregistered. + +------------------------------------------------------------------------------- + The CANTUS CYGNEUS +------------------------------------------------------------------------------- + +include(FILEPATH) + +===============================================================================