diff --git a/base-config.yaml b/base-config.yaml index 709829a..cd228d3 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -3,17 +3,44 @@ admin_secret: mYsUp3rs3CretKEY12345 # versions of matrix-registration earlier than 0.9.0 used # a different api endpoint. if you are running a version # that is greater than or equal to 0.9.0, set this to false -legacy_mr: true +legacy_mr: false # how to get to the matrix-registration instance # note the lack of trailing slash! +# e.g. +# reg_url: http://localhost:5000 reg_url: 'https://www.yourwebsite.com' # the URI to use for registering tokens # leave this as the default value unless you are using # a custom registration page! +# you can also set this to a full URL if your registration +# page is accessible by a completely different host from +# your registration endpoint, just be sure to update your +# formatted message below to remove the reg_url value. +# e.g. +# reg_page: https://someotherwebsite.com/registration-page.html reg_page: '/register' +# the html-formatted text you would like the bot to respond with +# when a new token is generated. you may use the following variables: +# {token} for the registration token +# {reg_url} for the registration url set in this config +# {reg_page} for the registration uri set in this config +# {expiration} for the expiration value set in this config +# +# if unset, a default message will be used. +# +# example message: +# +message: | + Invitation token {token} created!
+
+ Your unique url for registering is:
+ {reg_url}{reg_page}?token={token}
+ This invite token will expire in {expiration} days.
+ If it expires before use, you must request a new token. + # the duration the invitation should be valid, in days, before expiring expiration: 3 diff --git a/invite.py b/invite.py index e8cf3df..b71ac5a 100644 --- a/invite.py +++ b/invite.py @@ -15,6 +15,7 @@ class Config(BaseProxyConfig): helper.copy("reg_page") helper.copy("admins") helper.copy("expiration") + helper.copy("message") class Invite(Plugin): async def start(self) -> None: @@ -79,17 +80,22 @@ class Invite(Plugin): {resp_json}") self.log.exception(e) return None - - await evt.respond('
'.join( + + msg = '
'.join( [ - f"Invitation token {token} created! You may share the following message with your invitee:", + f"Invitation token {token} created!", f"", f"Your unique url for registering is:", f"{self.config['reg_url']}{self.config['reg_page']}?token={token}", f"This invite token will expire in {self.config['expiration']} days.", f"If it expires before use, you must request a new token." - ] - ), allow_html=True) + ]) + + if self.config['message']: + msg = self.config["message"].format(token=token, reg_url=self.config['reg_url'], + reg_page=self.config['reg_page'], expiration=self.config['expiration']) + + await evt.respond(msg, allow_html=True) @invite.subcommand("status", help="Return the status of an invite token.") @command.argument("token", "Token", pass_raw=True, required=True) diff --git a/maubot.yaml b/maubot.yaml index 5e9fa40..5b3283c 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: org.jobmachine.invitebot -version: 0.2.1 +version: 0.3.0 license: MIT modules: - invite