diff --git a/r0c/__main__.py b/r0c/__main__.py index fc95d83..42d5082 100644 --- a/r0c/__main__.py +++ b/r0c/__main__.py @@ -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") diff --git a/r0c/user.py b/r0c/user.py index d9a2553..7b7dd2e 100644 --- a/r0c/user.py +++ b/r0c/user.py @@ -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