summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-02-22 18:56:21 +0100
committerWim <wim@42.be>2018-02-22 18:56:21 +0100
commitf8714d81f504b5223c1bd762619c0e7b3bf32a52 (patch)
tree5b8fcb5bcee7abe70180d36c7c8a24c9c8d806f7
parent8622656005b667280515ec2b1514eba325573622 (diff)
downloadmatterbridge-msglm-f8714d81f504b5223c1bd762619c0e7b3bf32a52.tar.gz
matterbridge-msglm-f8714d81f504b5223c1bd762619c0e7b3bf32a52.tar.bz2
matterbridge-msglm-f8714d81f504b5223c1bd762619c0e7b3bf32a52.zip
Add DebugLevel option (irc)
-rw-r--r--bridge/config/config.go1
-rw-r--r--bridge/irc/irc.go13
2 files changed, 12 insertions, 2 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 09338f14..72ac4bb4 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -60,6 +60,7 @@ type Protocol struct {
Buffer int // api
Charset string // irc
Debug bool // general
+ DebugLevel int // only for irc now
EditSuffix string // mattermost, slack, discord, telegram, gitter
EditDisable bool // mattermost, slack, discord, telegram, gitter
IconURL string // mattermost, slack
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 027aa844..14ac9525 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -108,7 +108,7 @@ func (b *Birc) Connect() error {
i.Handlers.Add(girc.RPL_WELCOME, b.handleNewConnection)
i.Handlers.Add(girc.RPL_ENDOFMOTD, b.handleOtherAuth)
- i.Handlers.Add("*", b.handleOther)
+ i.Handlers.Add(girc.ALL_EVENTS, b.handleOther)
go func() {
for {
if err := i.Connect(); err != nil {
@@ -134,7 +134,9 @@ func (b *Birc) Connect() error {
return fmt.Errorf("connection timed out")
}
//i.Debug = false
- i.Handlers.Clear("*")
+ if b.Config.DebugLevel == 0 {
+ i.Handlers.Clear(girc.ALL_EVENTS)
+ }
go b.doSend()
return nil
}
@@ -307,6 +309,13 @@ func (b *Birc) handleNotice(client *girc.Client, event girc.Event) {
}
func (b *Birc) handleOther(client *girc.Client, event girc.Event) {
+ if b.Config.DebugLevel == 1 {
+ if event.Command != "CLIENT_STATE_UPDATED" &&
+ event.Command != "CLIENT_GENERAL_UPDATED" {
+ flog.Debugf("%#v", event.String())
+ }
+ return
+ }
switch event.Command {
case "372", "375", "376", "250", "251", "252", "253", "254", "255", "265", "266", "002", "003", "004", "005":
return