Fix passive command regex compiling and send m.notices by default

This commit is contained in:
Tulir Asokan 2018-09-21 16:09:26 +03:00
parent ba6bbead12
commit b805641ea4
4 changed files with 11 additions and 4 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ sed/
github/ github/
gitlab/ gitlab/
rss/ rss/
factorial/

View File

@ -83,7 +83,7 @@ func (pc *ParsedCommand) parseCommandSyntax(command maubot.Command) error {
func (pc *ParsedCommand) parsePassiveCommandSyntax(command maubot.PassiveCommand) error { func (pc *ParsedCommand) parsePassiveCommandSyntax(command maubot.PassiveCommand) error {
pc.MatchAgainst = command.MatchAgainst pc.MatchAgainst = command.MatchAgainst
var err error var err error
pc.Matches, err = regexp.Compile(fmt.Sprintf("(%s)", command.Matches)) pc.Matches, err = regexp.Compile(command.Matches)
pc.MatchesEvent = command.MatchEvent pc.MatchesEvent = command.MatchEvent
return err return err
} }

View File

@ -46,7 +46,9 @@ func (evt *EventFuncsImpl) MarkRead() error {
} }
func (evt *EventFuncsImpl) Reply(text string) (string, error) { func (evt *EventFuncsImpl) Reply(text string) (string, error) {
return evt.ReplyContent(format.RenderMarkdown(text)) content := format.RenderMarkdown(text)
content.MsgType = gomatrix.MsgNotice
return evt.ReplyContent(content)
} }
func (evt *EventFuncsImpl) ReplyContent(content gomatrix.Content) (string, error) { func (evt *EventFuncsImpl) ReplyContent(content gomatrix.Content) (string, error) {

View File

@ -143,11 +143,15 @@ func (client *Client) JoinRoom(roomID string) (resp *gomatrix.RespJoinRoom, err
} }
func (client *Client) SendMessage(roomID, text string) (string, error) { func (client *Client) SendMessage(roomID, text string) (string, error) {
return client.SendContent(roomID, format.RenderMarkdown(text)) content := format.RenderMarkdown(text)
content.MsgType = gomatrix.MsgNotice
return client.SendContent(roomID, content)
} }
func (client *Client) SendMessagef(roomID, text string, args ...interface{}) (string, error) { func (client *Client) SendMessagef(roomID, text string, args ...interface{}) (string, error) {
return client.SendContent(roomID, format.RenderMarkdown(fmt.Sprintf(text, args...))) content := format.RenderMarkdown(fmt.Sprintf(text, args...))
content.MsgType = gomatrix.MsgNotice
return client.SendContent(roomID, content)
} }
func (client *Client) SendContent(roomID string, content gomatrix.Content) (string, error) { func (client *Client) SendContent(roomID string, content gomatrix.Content) (string, error) {