Commit Graph

123 Commits

Author SHA1 Message Date
Slavi Pantaleev
10f44e621d Format option value as code 2022-08-26 07:46:50 +03:00
Aine
0a5bc5d989 refactor rooms/roomsmu to sync.Map 2022-08-25 22:38:45 +03:00
Aine
b0c274491f refactor to context, remove sentry spans 2022-08-25 22:31:12 +03:00
Slavi Pantaleev
8e1aa5b11c [WIP] Send introduction text and help after the bot joins a room
This appears to work, except that the join event is triggered twice,
and we send the (introduction + help) twice.
2022-08-25 11:58:18 +03:00
Slavi Pantaleev
1babbb7169 Make Notice() not do string formatting anymore
In various places, we build messages using `Sprintf` before passing them
to `Notice()`.

If we let `Notice()` do string formatting, we run the chance of having
it try to format our already-preformatted text. If our text includes
format references (e.g. `%s`), it would cause a problem (`%s(MISSING)`).

One way to trigger it is to change the bot prefix from `!pm` to `%pm`.
Doing so, `sendHelp()` would create some help message which contains
`%pm` references. `Notice()` would then try to process them as well,
leading to a bunch of `%!p(MISSING)m` in the final text.
2022-08-25 10:55:15 +03:00
Slavi Pantaleev
e7610a34a3 Decrease number of WriteString() calls in sendHelp() 2022-08-25 09:03:22 +03:00
Slavi Pantaleev
cda8ee0a25 Improve sendHelp() to show full commands
It previously said "the following commands" were supported
and it was only listing subcommands (help, stop, ..)
without any indication of how the user should construct the full command
(`PREFIX SUB_COMMAND`).

For perfect clarity, we now list full commands in the help message. Example:

> The following commands are supported:
>
> - !pm help - Show this help message
> - !pm stop - Disable bridge for the room and clear all configuration
> - !pm mailbox - Get or set mailbox of the room
> - !pm owner - Get or set owner of the room
> - !pm nosender - Get or set nosender of the room (true - hide email sender; false - show email sender)
> - !pm nosubject - Get or set nosubject of the room (true - hide email subject; false - show email subject)

The new help message is prefix-aware, instead of hardcodign `!pm`.
If the bot is running with a custom prefix (not `!pm`), this is even
more helpful, as it lets people know what the prefix is. Reading
documentation elsewhere and seeing `!pm STUFF` will no longer confuse
anyone.

With this change, we also make use of the existing `Notice()` function,
so we don't need to duplicate some code related to sending notices.
2022-08-25 08:33:28 +03:00
Aine
d021e6715e Revert "visual fixes"
This reverts commit 34735b2614.
2022-08-24 12:09:23 +03:00
Aine
34735b2614 visual fixes 2022-08-24 12:02:41 +03:00
Slavi Pantaleev
afe24beb4d Use a command list (not a map) to have a consistent manually-defined commands order 2022-08-24 11:39:24 +03:00
Slavi Pantaleev
26edcdadbc Use string constants for options, not magic strings
This also adds `Mailbox()` and `Owner()` getters for completeness.

Wording has been changed a bit to avoid saying "that room". It sounds
better if it's "this room" or just "the room".
2022-08-24 10:56:47 +03:00
Aine
d361e31a60 adjust stop's help message 2022-08-24 09:57:22 +03:00
Aine
82b84e3c35 Merge branch 'stop' into 'main'
add '!pm stop'

See merge request etke.cc/postmoogle!7
2022-08-24 06:41:15 +00:00
Aine
76457f8e3c add '!pm stop' 2022-08-24 09:38:13 +03:00
Slavi Pantaleev
e4acbb31f0 Add nosubject option 2022-08-24 07:37:34 +03:00
Aine
85fc06cfce lint; rearrange code 2022-08-23 22:12:11 +03:00
Aine
e5e9be528b refactor options to be more generic 2022-08-23 21:58:05 +03:00
Aine
81abe8c785 unoptimal refactoring 2022-08-23 19:23:15 +03:00
Slavi Pantaleev
9f3aa3dd68 Add ability to hide sender's email address (hide-sender-address setting)
The configuration setting is called `Hide*` instead of `Show*`, because
it's backward compatible with existing configuration settings.

This is useful for when you setup an email forwarding inbox and you're
always sending to it through the same email address. In that case, you
don't need to see the email address in each Matrix message.

In the future, another similar `bool` setting (`hide-subject`) will land,
which controls whether the email's subject is shown in the final message
or not. That setting can make use of most of the same setup (all of
`handleBooleanConfigurationKey`).
2022-08-23 18:21:23 +03:00
Aine
0decd4fad6 add noowner and federation 2022-08-22 22:08:32 +03:00
Aine
564cd82c6b fix prefix; test attachments; add maxsize 2022-08-22 20:21:22 +03:00
Aine
e6d5e81efe bugfixes; email parsing; send emails into matrix rooms; e2e tests 2022-08-22 12:28:29 +03:00
Aine
c4b7a16e21 wip 2022-08-21 18:41:35 +03:00