Add toggles for disabling markdown and HTML
This commit is contained in:
parent
0a493d643c
commit
842aab1324
@ -45,6 +45,8 @@ type UserPreferences struct {
|
||||
DisableImages bool `yaml:"disable_images"`
|
||||
DisableTypingNotifs bool `yaml:"disable_typing_notifs"`
|
||||
DisableEmojis bool `yaml:"disable_emojis"`
|
||||
DisableMarkdown bool `yaml:"disable_markdown"`
|
||||
DisableHTML bool `yaml:"disable_html"`
|
||||
}
|
||||
|
||||
// Config contains the main config of gomuks.
|
||||
|
2
go.mod
2
go.mod
@ -21,7 +21,7 @@ require (
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
|
||||
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320135656-32dd5f172592
|
||||
maunium.net/go/mautrix v0.1.0-beta.2.0.20200403220206-c81fdd9fe68f
|
||||
maunium.net/go/mauview v0.1.0-beta.1
|
||||
maunium.net/go/tcell v0.1.0
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -77,6 +77,8 @@ maunium.net/go/mautrix v0.1.0-beta.1.0.20200320123139-8ba1d97ed86b h1:sQ7w1dOTvT
|
||||
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320123139-8ba1d97ed86b/go.mod h1:YFMU9DBeXH7cqx7sJLg0DkVxwNPbih8QbpUTYf/IjMM=
|
||||
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320135656-32dd5f172592 h1:WybA4BBUyod/qN6/yChfh2Q0CAqoZjtWnpUBwmfbfFU=
|
||||
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320135656-32dd5f172592/go.mod h1:YFMU9DBeXH7cqx7sJLg0DkVxwNPbih8QbpUTYf/IjMM=
|
||||
maunium.net/go/mautrix v0.1.0-beta.2.0.20200403220206-c81fdd9fe68f h1:Fg7t2i+AtUX4NDN5Ue9HsHO/Vog0JN9CZsOH3u+hDOc=
|
||||
maunium.net/go/mautrix v0.1.0-beta.2.0.20200403220206-c81fdd9fe68f/go.mod h1:YFMU9DBeXH7cqx7sJLg0DkVxwNPbih8QbpUTYf/IjMM=
|
||||
maunium.net/go/mauview v0.1.0-beta.1 h1:hRprD6NTi5Mw7i97DKmgs/TzFQeNpGPytPoswNlU/Ww=
|
||||
maunium.net/go/mauview v0.1.0-beta.1/go.mod h1:og9WbzmWe9SNYNyOFlCv8qa9zMcOvG2nzRJ5vYyud9U=
|
||||
maunium.net/go/tcell v0.1.0 h1:XzsEoGCvOw5nac+tlkSLzQcliLYTN4PrtA7ar2ptjSM=
|
||||
|
@ -392,7 +392,7 @@ func (c *Container) HandlePreferences(source EventSource, evt *mautrix.Event) {
|
||||
func (c *Container) SendPreferencesToMatrix() {
|
||||
defer debug.Recover()
|
||||
debug.Print("Sending updated preferences:", c.config.Preferences)
|
||||
u := c.client.BuildURL("user", c.config.UserID, "account_data", "net.maunium.gomuks.preferences")
|
||||
u := c.client.BuildURL("user", c.config.UserID, "account_data", AccountDataGomuksPreferences.Type)
|
||||
_, err := c.client.MakeRequest("PUT", u, &c.config.Preferences, nil)
|
||||
if err != nil {
|
||||
debug.Print("Failed to update preferences:", err)
|
||||
@ -739,7 +739,7 @@ func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.Messag
|
||||
MsgType: msgtype,
|
||||
}
|
||||
} else {
|
||||
content = format.RenderMarkdown(text)
|
||||
content = format.RenderMarkdown(text, !c.config.Preferences.DisableMarkdown, !c.config.Preferences.DisableHTML)
|
||||
content.MsgType = msgtype
|
||||
}
|
||||
|
||||
|
@ -556,6 +556,20 @@ func cmdToggle(cmd *Command) {
|
||||
cmd.Config.Preferences.DisableTypingNotifs = !cmd.Config.Preferences.DisableTypingNotifs
|
||||
case "emojis":
|
||||
cmd.Config.Preferences.DisableEmojis = !cmd.Config.Preferences.DisableEmojis
|
||||
case "html":
|
||||
cmd.Config.Preferences.DisableHTML = !cmd.Config.Preferences.DisableHTML
|
||||
if cmd.Config.Preferences.DisableHTML {
|
||||
cmd.Reply("Disabled HTML input")
|
||||
} else {
|
||||
cmd.Reply("Enabled HTML input")
|
||||
}
|
||||
case "markdown":
|
||||
cmd.Config.Preferences.DisableMarkdown = !cmd.Config.Preferences.DisableMarkdown
|
||||
if cmd.Config.Preferences.DisableMarkdown {
|
||||
cmd.Reply("Disabled Markdown input")
|
||||
} else {
|
||||
cmd.Reply("Enabled Markdown input")
|
||||
}
|
||||
default:
|
||||
cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif/emojis>")
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user