matrix+irc: improve support for IRC NOTICE/[matrix] m.notice
Fixes: #1393.
This commit is contained in:
@@ -27,7 +27,7 @@ const (
|
||||
EventAPIConnected = "api_connected"
|
||||
EventUserTyping = "user_typing"
|
||||
EventGetChannelMembers = "get_channel_members"
|
||||
EventNoticeIRC = "notice_irc"
|
||||
EventNotice = "notice"
|
||||
)
|
||||
|
||||
const ParentIDNotFound = "msg-parent-not-found"
|
||||
|
||||
@@ -201,7 +201,7 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
|
||||
|
||||
// set NOTICE event
|
||||
if event.Command == "NOTICE" {
|
||||
rmsg.Event = config.EventNoticeIRC
|
||||
rmsg.Event = config.EventNotice
|
||||
}
|
||||
|
||||
// strip action, we made an event if it was an action
|
||||
|
||||
@@ -255,7 +255,7 @@ func (b *Birc) doSend() {
|
||||
switch msg.Event {
|
||||
case config.EventUserAction:
|
||||
b.i.Cmd.Action(msg.Channel, username+msg.Text)
|
||||
case config.EventNoticeIRC:
|
||||
case config.EventNotice:
|
||||
b.Log.Debugf("Sending notice to channel %s", msg.Channel)
|
||||
b.i.Cmd.Notice(msg.Channel, username+msg.Text)
|
||||
default:
|
||||
|
||||
@@ -150,6 +150,7 @@ func (b *Bmatrix) handleMemberChange(ev *event.Event) {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint: funlen
|
||||
func (b *Bmatrix) handleMessage(rmsg config.Message, ev *event.Event) {
|
||||
msg := ev.Content.AsMessage()
|
||||
if msg == nil {
|
||||
@@ -169,10 +170,10 @@ func (b *Bmatrix) handleMessage(rmsg config.Message, ev *event.Event) {
|
||||
rmsg.Avatar = avatarURL
|
||||
}
|
||||
|
||||
// Do we have a /me action
|
||||
//nolint: exhaustive
|
||||
switch msg.MsgType {
|
||||
case event.MsgEmote:
|
||||
// Do we have a /me action
|
||||
rmsg.Event = config.EventUserAction
|
||||
case event.MsgImage, event.MsgVideo, event.MsgFile:
|
||||
// Do we have attachments? (we only allow images, videos or files msgtypes)
|
||||
@@ -180,6 +181,9 @@ func (b *Bmatrix) handleMessage(rmsg config.Message, ev *event.Event) {
|
||||
if err != nil {
|
||||
b.Log.Errorf("download failed: %#v", err)
|
||||
}
|
||||
case event.MsgNotice:
|
||||
// Support for IRC NOTICE commands/[matrix] m.notice
|
||||
rmsg.Event = config.EventNotice
|
||||
default:
|
||||
if msg.RelatesTo == nil {
|
||||
break
|
||||
|
||||
@@ -195,6 +195,7 @@ func (b *Bmatrix) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//nolint: funlen,gocognit,gocyclo
|
||||
func (b *Bmatrix) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("=> Sending %#v", msg)
|
||||
|
||||
@@ -305,7 +306,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
|
||||
}
|
||||
|
||||
// Use notices to send join/leave events
|
||||
if msg.Event == config.EventJoinLeave {
|
||||
if msg.Event == config.EventJoinLeave || msg.Event == config.EventNotice {
|
||||
m.MsgType = event.MsgNotice
|
||||
} else {
|
||||
m.MsgType = event.MsgText
|
||||
|
||||
Reference in New Issue
Block a user