commit d8c0a953b3987034069591d3f095ec5b967fe922
parent dcad6d593a969edc1243a1668801f8d0f020b9ab
Author: Juan F. Meleiro <juan@juanmeleiro.mat.br>
Date: Mon, 12 Jun 2023 10:54:31 -0300
Restructure scripts
Diffstat:
10 files changed, 173 insertions(+), 232 deletions(-)
diff --git a/.weekly.tmp b/.weekly.tmp
@@ -1,122 +0,0 @@
-Date: Mon, 3 Apr 2023 15:26:09 -0300
-From: juan <juan@juanmeleiro.mat.br>
-To: agora-official@agoranomic.org
-Subject: [Registrar] Weekly report
-MIME-Version: 1.0
-Content-Type: text/plain; charset=us-ascii
-Content-Disposition: inline
-X-Mutt-Resume-Draft: 1
-
-===============================================================================
-Registrar: juan The Agoran Directory 2023-03-27
-===============================================================================
-
--------------------------------------------------------------------------------
-NEWS
-
-No news.
-
--------------------------------------------------------------------------------
-PLAYERS
-
-Active players: 17/18
-
-a Player Registered Last change Contact
-- ------ ---------- ----------- -------
-+ 4st 2023-01-27 " notorious4st at gmail dot com
-+ Aced7 2022-10-19 " cadenomic at gmail dot com
-+ ais523 2021-06-08 " callforjudgement at yahoo.co dot uk
-+ Aspen 2022-11-04 " thoughtsoflifeandlight17 at gmail dot com
-+ G. 2017-08-25 2021-02-03 kerim at uw dot edu
-+ Gaelan 2017-05-15 2021-02-03 gbs at canishe dot com
-+ Janet 2019-06-02 2021-02-03 agora at randomcat dot org
-+ juan 2022-03-14 " juan at juanmeleiro.mat dot br
-+ Marb 2022-11-27 " marb at shabu dot town
-+ Murphy 2017-12-17 2021-02-03 murphy.agora at gmail dot com
-+ nix 2022-10-09 " agora at nullarch dot com
-+ Shy Owl 2022-10-07 " iamashyown at proton dot me
-+ snail 2022-01-29 " secretsnail9 at gmail dot com
-+ cuddlybanana 2021-03-16 2023-01-16 rose.strong42 at gmail dot com
-+ tb148 2023-02-06 " tb148 at proton dot me
-+ R. Lee 2023-01-31 " sarahestrange0 at gmail dot com
-+ Yachay Wayllukuq 2023-03-16 " yachaywayllukuq at gmail.com
-- omd 2011-02-03 2022-03-23 comexk at gmail dot com
-
-Convetions:
-* Player: Latest player name.
-* Registered: Date of latest registration.
-* Last change: Date of latest change in Activity.
-* Contact: URI for eir prefered contact method
-
-Legend for symbols:
-a Activity
-+ Active
-- Inactive
-" Same value as cell to the left
-
-
--------------------------------------------------------------------------------
-FORA
-
-Publicity Location or description Typical use
---------- ----------------------- -----------
-Public agora-official at agoranomic.org official reports
-Public agoranomic at groups.io * backup
-Public agora-business at agoranomic.org other business
-Public agora at listserver.tue.nl backup
-Foreign irc://irc.libera.chat:6667/##nomic discussion
-Discussion https://discord.gg/JCC6YGc discussion
-Discussion agora-discussion at agoranomic.org discussion
-
-* The forum is specifically just that email list.
-
-Subscribe or unsubscribe from main lists:
-
- http://www.agoranomic.org/cgi-bin/mailman/listinfo
-
-Subscribe or unsubscribe from tue.nl backup list:
-
- http://listserver.tue.nl/mailman/listinfo/agora
-
-The IRC channel does not require subscription; set your IRC client to
-server irc.libera.chat, port 6667, channel ##nomic.
-
-You can subscribe to GIO by messaging the following email
-
- main+subscribe at agoranomic.groups.io
-
--------------------------------------------------------------------------------
-BANNED PEOPLE
-
--------------------
-Person Date of ban
------- -----------
-Madrid 2022-09-11
--------------------
-
--------------------------------------------------------------------------------
-INTERNAL
-
-Regarding what information is included in the report and why.
-
-- List of players (R2139)
-- List of players' contact information (R2139)
-- Date of latest registration (R2139)
-- Fora (R2139)
-- Date of latest activation (convenience for deregistrations as per R2646)
-- Number of players (petition by nix on 2023-02-23)
-- Banned people (R2679)
-
--------------------------------------------------------------------------------
-EDITORIAL
-
-For any corrections,
-For any suggestions or complaints of form,
-Please contact the Registrar.
-
-
-===============================================================================
-
---
-juan
-Registrar
diff --git a/birthday.fish b/birthday.fish
@@ -1,58 +0,0 @@
-#!/usr/bin/fish
-
-set WIDTH 80
-
-function ord -a num
- switch "$num"
- case 1 01
- echo st
- case 2 02
- echo nd
- case 3 03
- echo rd
- case '*'
- echo th
- end
-end
-
-fzf < birthdays/list |
-read date name
-
-echo $date | read -d '-' birthyear month day
-
-set currentyear (date +%Y)
-set currentstamp (date +%S)
-set birthstamp (date +%S -d $date)
-
-if test (date +%S -d "$currentyear-$month-$day") -gt $currentstamp
- # Most recent birthday was last year
- set year (math $currentyear - 1)
-else
- # Most recent birthday was this year
- set year $currentyear
-end
-
-set MONTH (env LANG=en date +"%B" -d "$year-$month-$day")
-set DATEORD (ord $day)
-set COUNT (math "$year - $birthyear")
-set COUNTORD (ord "$COUNT")
-set DAY (string trim -l -c '0' $day)
-
-set DATE "The $DAY$DATEORD of $MONTH of $year"
-set DATELEN (string length "$DATE")
-set DATEPAD (repeat (math "floor(($WIDTH - $DATELEN)/2)") " ")
-
-set tmp (mktemp)
-begin
-echo 'Date: '(date -R)
-echo 'From: juan <juan@juanmeleiro.mat.br>'
-echo 'To: <agora-official@agoranomic.org>'
-echo 'Subject: [Registrar] Birthday Announcement'
-m4 --define=DATE="$DATEPAD$DATE" \
- --define=PLAYER="$name" \
- --define=COUNT="$COUNT$COUNTORD" \
- template
-end > $tmp
-neomutt -E -H $tmp
-rm $tmp
-
diff --git a/log.txt b/log.txt
@@ -45,4 +45,6 @@
[2023-05-22] Janet Cobb changed eir email to <janet.agora@unspecified.systems>
[2023-05-23] Anneke-Constantine <agora.quarentine@gmail.com> registers.
[2023-05-31] Yachay Wayllukuq deactivates emself.
+[2023-06-01] Published monthly report.
+[2023-06-05] Published weekly report.
[2023-06-07] Fixed entries for dahuman, 4st, Anti-Cleisthenes and nix
diff --git a/monthly.fish b/monthly.fish
@@ -1,13 +0,0 @@
-#!/usr/bin/fish
-
-set tmp (mktemp)
-
-begin
-echo 'Date: '(date -R)
-echo 'From: juan <juan@juanmeleiro.mat.br>'
-echo 'To: <agora-official@agoranomic.org>'
-echo 'Subject: [Registrar] Monthly report: Arrivals and Departures'
-m4 monthly/monthly.m4
-end > $tmp
-neomutt -E -H $tmp
-rm $tmp
diff --git a/registrar.fish b/registrar.fish
@@ -0,0 +1,53 @@
+#!/usr/bin/fish
+
+argparse 'h/help' -- $argv
+
+function usage
+ echo 'usage: ./registrar.fish COMMAND'
+ echo 'commands:'
+ echo ' weekly'
+ echo ' monthly'
+ echo ' birthday'
+end
+
+function guessmonthly
+ # No monthly published this month
+ set cur_month (date +%Y-%m)
+ grep -q "\[$cur_month-..\] Published monthly report." log.txt
+ or echo monthly
+end
+
+function guessweekly
+ test (date +%u) = 1
+ and set reference (date -d '00:00' +%s)
+ or set reference (date -d 'last monday' +%s)
+ grep "\[....-..-..\] Published weekly report." log.txt |
+ grep -o "\[....-..-..\]" |
+ grep -o "....-..-.." |
+ while read d
+ set candidate (date -d $d +%s)
+ test $candidate -ge $reference
+ and return
+ end
+ echo weekly
+end
+
+function guess
+ guessmonthly
+ guessweekly
+ # guessbirthday
+end
+
+test "$argv[1]" = guess -o -z "$argv[1]"
+and set argv (guess)
+
+for c in $argv
+ switch $c
+ case weekly
+ source 'scripts/weekly.fish'
+ case monthly
+ source 'scripts/monthly.fish'
+ case birthday
+ source 'scripts/birthday.fish'
+ end
+end
diff --git a/scripts/birthday.fish b/scripts/birthday.fish
@@ -0,0 +1,58 @@
+#!/usr/bin/fish
+
+set WIDTH 80
+
+function ord -a num
+ switch "$num"
+ case 1 01
+ echo st
+ case 2 02
+ echo nd
+ case 3 03
+ echo rd
+ case '*'
+ echo th
+ end
+end
+
+fzf < birthdays/list |
+read date name
+
+echo $date | read -d '-' birthyear month day
+
+set currentyear (date +%Y)
+set currentstamp (date +%S)
+set birthstamp (date +%S -d $date)
+
+if test (date +%S -d "$currentyear-$month-$day") -gt $currentstamp
+ # Most recent birthday was last year
+ set year (math $currentyear - 1)
+else
+ # Most recent birthday was this year
+ set year $currentyear
+end
+
+set MONTH (env LANG=en date +"%B" -d "$year-$month-$day")
+set DATEORD (ord $day)
+set COUNT (math "$year - $birthyear")
+set COUNTORD (ord "$COUNT")
+set DAY (string trim -l -c '0' $day)
+
+set DATE "The $DAY$DATEORD of $MONTH of $year"
+set DATELEN (string length "$DATE")
+set DATEPAD (repeat (math "floor(($WIDTH - $DATELEN)/2)") " ")
+
+set tmp (mktemp)
+begin
+echo 'Date: '(date -R)
+echo 'From: juan <juan@juanmeleiro.mat.br>'
+echo 'To: <agora-official@agoranomic.org>'
+echo 'Subject: [Registrar] Birthday Announcement'
+m4 --define=DATE="$DATEPAD$DATE" \
+ --define=PLAYER="$name" \
+ --define=COUNT="$COUNT$COUNTORD" \
+ birthdays/template
+end > $tmp
+neomutt -E -H $tmp
+rm $tmp
+
diff --git a/deregistrations.jq b/scripts/deregistrations.jq
diff --git a/scripts/monthly.fish b/scripts/monthly.fish
@@ -0,0 +1,13 @@
+#!/usr/bin/fish
+
+set tmp (mktemp)
+
+begin
+echo 'Date: '(date -R)
+echo 'From: juan <juan@juanmeleiro.mat.br>'
+echo 'To: <agora-official@agoranomic.org>'
+echo 'Subject: [Registrar] Monthly report: Arrivals and Departures'
+m4 monthly/monthly.m4
+end > $tmp
+neomutt -E -H $tmp
+mv $tmp archive/(date --iso-8601=date)-monthly.txt
diff --git a/scripts/weekly.fish b/scripts/weekly.fish
@@ -0,0 +1,47 @@
+#!/usr/bin/fish
+
+set tmp (mktemp)
+
+begin
+echo 'Date: '(date -R)
+echo 'From: juan <juan@juanmeleiro.mat.br>'
+echo 'To: <agora-official@agoranomic.org>'
+echo 'Subject: [Registrar] Weekly report'
+m4 weekly/weekly.m4
+end > $tmp
+neomutt -E -H $tmp
+set today (date --iso-8601=date)
+read -n 1 -P 'Archive? [Yn] ' ans
+contains "$ans" n N no No NO
+or begin
+ mv $tmp archive/$today-weekly.txt
+ echo "[$today] Published weekly report." >> log.txt
+end
+
+if jq -e '[.[][] | select(has("active") and (.active | not))] | length > 0' players.json > /dev/null
+ jq -r '.[][] | select(has("active") and (.active | not)) | .name' players.json
+ read -P 'This players are to be deregistered. Do it? [Yn]' -n 1 ans
+ if contains "$ans" n N no No NO
+ exit 0
+ end
+else
+ exit 0
+end
+
+set tmp (mktemp)
+
+begin
+echo 'Date: '(date -R)
+echo 'From: juan <juan@juanmeleiro.mat.br>'
+echo 'To: <agora-official@agoranomic.org>'
+echo 'Subject: [Registrar] Deregistration intents'
+jq -rf scripts/deregistrations.jq players.json
+end > $tmp
+neomutt -E -H $tmp
+rm $tmp
+mv $tmp archive/(date --iso-8601=date)-deregistration.txt
+
+begin
+echo 'TODO Deregister players in Agora'
+date -d 'now + 4 days' +'SCHEDULED: <%Y-%m-%d %a>'
+end | capture -i
diff --git a/weekly.fish b/weekly.fish
@@ -1,39 +0,0 @@
-#!/usr/bin/fish
-
-set tmp (mktemp)
-
-begin
-echo 'Date: '(date -R)
-echo 'From: juan <juan@juanmeleiro.mat.br>'
-echo 'To: <agora-official@agoranomic.org>'
-echo 'Subject: [Registrar] Weekly report'
-m4 weekly/weekly.m4
-end > $tmp
-neomutt -E -H $tmp
-rm $tmp
-
-if jq -e '[.[][] | select(has("active") and (.active | not))] | length > 0' players.json > /dev/null
- read -P 'There are players to be deregistered. Do it? [Yn]' -n 1 ans
- if contains "$ans" n N no No NO
- exit 0
- end
-else
- exit 0
-end
-
-set tmp (mktemp)
-
-begin
-echo 'Date: '(date -R)
-echo 'From: juan <juan@juanmeleiro.mat.br>'
-echo 'To: <agora-official@agoranomic.org>'
-echo 'Subject: [Registrar] Deregistration intents'
-jq -rf deregistrations.jq players.json
-end > $tmp
-neomutt -E -H $tmp
-rm $tmp
-
-begin
-echo 'TODO Deregister players in Agora'
-date -d 'now + 4 days' +'SCHEDULED: <%Y-%m-%d %a>'
-end | capture -i