refactor options to be more generic

This commit is contained in:
Aine
2022-08-23 21:58:05 +03:00
parent 9eec8738f9
commit e5e9be528b
8 changed files with 157 additions and 241 deletions

View File

@@ -61,10 +61,9 @@ func (b *Bot) Error(ctx context.Context, roomID id.RoomID, message string, args
// Notice sends a notice message to the matrix room
func (b *Bot) Notice(ctx context.Context, roomID id.RoomID, message string, args ...interface{}) {
_, err := b.lp.Send(roomID, &event.MessageEventContent{
MsgType: event.MsgNotice,
Body: fmt.Sprintf(message, args...),
})
content := format.RenderMarkdown(fmt.Sprintf(message, args...), true, true)
content.MsgType = event.MsgNotice
_, err := b.lp.Send(roomID, &content)
if err != nil {
if sentry.HasHubOnContext(ctx) {
sentry.GetHubFromContext(ctx).CaptureException(err)
@@ -102,7 +101,7 @@ func (b *Bot) Send(ctx context.Context, from, to, subject, plaintext, html strin
}
var text strings.Builder
if !settings.NoSender {
if !utils.Bool(settings.Get("nosender")) {
text.WriteString("From: ")
text.WriteString(from)
text.WriteString("\n\n")