summaryrefslogtreecommitdiffstats
path: root/bridge/irc
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-11-22 22:21:02 +0100
committerGitHub <noreply@github.com>2020-11-22 22:21:02 +0100
commitb24e1bafa180870646bec6b42450d3077b3facd2 (patch)
tree0c66487e72b85c12dfa59e3feaa6edac62fe7739 /bridge/irc
parent64b899ac8944f5bd94dfddcefeac8c0f4141be62 (diff)
downloadmatterbridge-msglm-b24e1bafa180870646bec6b42450d3077b3facd2.tar.gz
matterbridge-msglm-b24e1bafa180870646bec6b42450d3077b3facd2.tar.bz2
matterbridge-msglm-b24e1bafa180870646bec6b42450d3077b3facd2.zip
Add support for irc to irc notice (irc). Fixes #754 (#1305)
Diffstat (limited to 'bridge/irc')
-rw-r--r--bridge/irc/handlers.go14
-rw-r--r--bridge/irc/irc.go11
2 files changed, 21 insertions, 4 deletions
diff --git a/bridge/irc/handlers.go b/bridge/irc/handlers.go
index 9089c9a9..aaaf42fb 100644
--- a/bridge/irc/handlers.go
+++ b/bridge/irc/handlers.go
@@ -170,7 +170,14 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
if b.skipPrivMsg(event) {
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)
// set action event
@@ -178,6 +185,11 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
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
rmsg.Text += event.StripAction()
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 4be15b51..8470a1c3 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -212,9 +212,14 @@ func (b *Birc) doSend() {
colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes
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)
- } 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.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()
// freenode doesn't send 001 as first reply
- if event.Command == "NOTICE" {
+ if event.Command == "NOTICE" && len(event.Params) != 2 {
return true
}
// don't forward queries to the bot