mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-14 03:50:26 +00:00
parent
64b899ac89
commit
b24e1bafa1
@ -26,6 +26,7 @@ const (
|
|||||||
EventAPIConnected = "api_connected"
|
EventAPIConnected = "api_connected"
|
||||||
EventUserTyping = "user_typing"
|
EventUserTyping = "user_typing"
|
||||||
EventGetChannelMembers = "get_channel_members"
|
EventGetChannelMembers = "get_channel_members"
|
||||||
|
EventNoticeIRC = "notice_irc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
|
@ -170,7 +170,14 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
|
|||||||
if b.skipPrivMsg(event) {
|
if b.skipPrivMsg(event) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rmsg := config.Message{Username: event.Source.Name, Channel: strings.ToLower(event.Params[0]), Account: b.Account, UserID: event.Source.Ident + "@" + event.Source.Host}
|
|
||||||
|
rmsg := config.Message{
|
||||||
|
Username: event.Source.Name,
|
||||||
|
Channel: strings.ToLower(event.Params[0]),
|
||||||
|
Account: b.Account,
|
||||||
|
UserID: event.Source.Ident + "@" + event.Source.Host,
|
||||||
|
}
|
||||||
|
|
||||||
b.Log.Debugf("== Receiving PRIVMSG: %s %s %#v", event.Source.Name, event.Last(), event)
|
b.Log.Debugf("== Receiving PRIVMSG: %s %s %#v", event.Source.Name, event.Last(), event)
|
||||||
|
|
||||||
// set action event
|
// set action event
|
||||||
@ -178,6 +185,11 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
|
|||||||
rmsg.Event = config.EventUserAction
|
rmsg.Event = config.EventUserAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set NOTICE event
|
||||||
|
if event.Command == "NOTICE" {
|
||||||
|
rmsg.Event = config.EventNoticeIRC
|
||||||
|
}
|
||||||
|
|
||||||
// strip action, we made an event if it was an action
|
// strip action, we made an event if it was an action
|
||||||
rmsg.Text += event.StripAction()
|
rmsg.Text += event.StripAction()
|
||||||
|
|
||||||
|
@ -212,9 +212,14 @@ func (b *Birc) doSend() {
|
|||||||
colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes
|
colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes
|
||||||
username = fmt.Sprintf("\x03%02d%s\x0F", colorCode, msg.Username)
|
username = fmt.Sprintf("\x03%02d%s\x0F", colorCode, msg.Username)
|
||||||
}
|
}
|
||||||
if msg.Event == config.EventUserAction {
|
|
||||||
|
switch msg.Event {
|
||||||
|
case config.EventUserAction:
|
||||||
b.i.Cmd.Action(msg.Channel, username+msg.Text)
|
b.i.Cmd.Action(msg.Channel, username+msg.Text)
|
||||||
} else {
|
case config.EventNoticeIRC:
|
||||||
|
b.Log.Debugf("Sending notice to channel %s", msg.Channel)
|
||||||
|
b.i.Cmd.Notice(msg.Channel, username+msg.Text)
|
||||||
|
default:
|
||||||
b.Log.Debugf("Sending to channel %s", msg.Channel)
|
b.Log.Debugf("Sending to channel %s", msg.Channel)
|
||||||
b.i.Cmd.Message(msg.Channel, username+msg.Text)
|
b.i.Cmd.Message(msg.Channel, username+msg.Text)
|
||||||
}
|
}
|
||||||
@ -291,7 +296,7 @@ func (b *Birc) skipPrivMsg(event girc.Event) bool {
|
|||||||
b.Nick = b.i.GetNick()
|
b.Nick = b.i.GetNick()
|
||||||
|
|
||||||
// freenode doesn't send 001 as first reply
|
// freenode doesn't send 001 as first reply
|
||||||
if event.Command == "NOTICE" {
|
if event.Command == "NOTICE" && len(event.Params) != 2 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// don't forward queries to the bot
|
// don't forward queries to the bot
|
||||||
|
@ -430,6 +430,11 @@ func (gw *Gateway) SendMessage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only send irc notices to irc
|
||||||
|
if msg.Event == config.EventNoticeIRC && dest.Protocol != "irc" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
// Too noisy to log like other events
|
// Too noisy to log like other events
|
||||||
debugSendMessage := ""
|
debugSendMessage := ""
|
||||||
if msg.Event != config.EventUserTyping {
|
if msg.Event != config.EventUserTyping {
|
||||||
|
Loading…
Reference in New Issue
Block a user