add `--motd` (customizable welcome-text)

This commit is contained in:
ed 2024-04-01 20:15:44 +00:00
parent ff55d39baf
commit f6d4c51840
2 changed files with 9 additions and 0 deletions

View File

@ -68,6 +68,7 @@ def optgen(ap, pwd):
ac = ap.add_argument_group("ux")
ac.add_argument("--no-all", action="store_true", help="default-disable @all / @everyone")
ac.add_argument("--motd", metavar="PATH", type=u, default="", help="file to include at the end of the welcome-text (can be edited at runtime)")
ac = ap.add_argument_group("perf")
ac.add_argument("--hist-rd", metavar="N", type=int, default=65535, help="max num msgs to load from disk when joining a channel")

View File

@ -172,6 +172,14 @@ class User(object):
)
text += HELP_INTRO
if self.ar.motd:
try:
with open(self.ar.motd, "rb") as f:
text += f.read().replace(b"\r", b"").decode("utf-8", "replace")[:-1]
except Exception as ex:
t = "WARNING: could not read motd-file [%s]: %s"
print(t % (self.ar.motd, ex))
# x = u"`1;30m░▒▓█▀▀▀▀`37m█▀`46m▓`0;1;30m▀▀▀▀█▓▒░`0;36m┌ "
# text += x.replace(u"`", u"\033[") * 66