mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-10 05:20:25 +00:00
Cleanup irc bridge debug/info messages
This commit is contained in:
parent
4737442185
commit
18504ec08d
@ -14,8 +14,7 @@ import (
|
|||||||
|
|
||||||
type Birc struct {
|
type Birc struct {
|
||||||
i *irc.Connection
|
i *irc.Connection
|
||||||
ircNick string
|
Nick string
|
||||||
name string
|
|
||||||
names map[string][]string
|
names map[string][]string
|
||||||
Config *config.Protocol
|
Config *config.Protocol
|
||||||
origin string
|
origin string
|
||||||
@ -33,11 +32,11 @@ func init() {
|
|||||||
func New(config config.Protocol, origin string, c chan config.Message) *Birc {
|
func New(config config.Protocol, origin string, c chan config.Message) *Birc {
|
||||||
b := &Birc{}
|
b := &Birc{}
|
||||||
b.Config = &config
|
b.Config = &config
|
||||||
|
b.Nick = b.Config.Nick
|
||||||
b.Remote = c
|
b.Remote = c
|
||||||
b.protocol = protocol
|
|
||||||
b.ircNick = b.Config.Nick
|
|
||||||
b.origin = origin
|
|
||||||
b.names = make(map[string][]string)
|
b.names = make(map[string][]string)
|
||||||
|
b.origin = origin
|
||||||
|
b.protocol = protocol
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ func (b *Birc) Command(msg *config.Message) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Birc) Connect() error {
|
func (b *Birc) Connect() error {
|
||||||
flog.Info("Trying IRC connection")
|
flog.Infof("Connecting %s", b.Config.Server)
|
||||||
i := irc.IRC(b.Config.Nick, b.Config.Nick)
|
i := irc.IRC(b.Config.Nick, b.Config.Nick)
|
||||||
i.UseTLS = b.Config.UseTLS
|
i.UseTLS = b.Config.UseTLS
|
||||||
i.UseSASL = b.Config.UseSASL
|
i.UseSASL = b.Config.UseSASL
|
||||||
@ -109,27 +108,27 @@ func (b *Birc) endNames(event *irc.Event) {
|
|||||||
maxNamesPerPost := (300 / b.nicksPerRow()) * b.nicksPerRow()
|
maxNamesPerPost := (300 / b.nicksPerRow()) * b.nicksPerRow()
|
||||||
continued := false
|
continued := false
|
||||||
for len(b.names[channel]) > maxNamesPerPost {
|
for len(b.names[channel]) > maxNamesPerPost {
|
||||||
b.Remote <- config.Message{Username: b.ircNick, Text: b.formatnicks(b.names[channel][0:maxNamesPerPost], continued),
|
b.Remote <- config.Message{Username: b.Nick, Text: b.formatnicks(b.names[channel][0:maxNamesPerPost], continued),
|
||||||
Channel: channel, Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
|
Channel: channel, Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
|
||||||
b.names[channel] = b.names[channel][maxNamesPerPost:]
|
b.names[channel] = b.names[channel][maxNamesPerPost:]
|
||||||
continued = true
|
continued = true
|
||||||
}
|
}
|
||||||
b.Remote <- config.Message{Username: b.ircNick, Text: b.formatnicks(b.names[channel], continued), Channel: channel,
|
b.Remote <- config.Message{Username: b.Nick, Text: b.formatnicks(b.names[channel], continued), Channel: channel,
|
||||||
Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
|
Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
|
||||||
b.names[channel] = nil
|
b.names[channel] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Birc) handleNewConnection(event *irc.Event) {
|
func (b *Birc) handleNewConnection(event *irc.Event) {
|
||||||
flog.Info("Registering callbacks")
|
flog.Debug("Registering callbacks")
|
||||||
i := b.i
|
i := b.i
|
||||||
b.ircNick = event.Arguments[0]
|
b.Nick = event.Arguments[0]
|
||||||
i.AddCallback("PRIVMSG", b.handlePrivMsg)
|
i.AddCallback("PRIVMSG", b.handlePrivMsg)
|
||||||
i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
|
i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
|
||||||
i.AddCallback(ircm.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
|
i.AddCallback(ircm.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
|
||||||
i.AddCallback(ircm.RPL_ENDOFNAMES, b.endNames)
|
i.AddCallback(ircm.RPL_ENDOFNAMES, b.endNames)
|
||||||
i.AddCallback(ircm.RPL_NAMREPLY, b.storeNames)
|
i.AddCallback(ircm.RPL_NAMREPLY, b.storeNames)
|
||||||
i.AddCallback(ircm.NOTICE, b.handleNotice)
|
i.AddCallback(ircm.NOTICE, b.handleNotice)
|
||||||
i.AddCallback(ircm.RPL_MYINFO, func(e *irc.Event) { flog.Infof("%s: %s", e.Code, strings.Join(e.Arguments[1:], " ")) })
|
//i.AddCallback(ircm.RPL_MYINFO, func(e *irc.Event) { flog.Infof("%s: %s", e.Code, strings.Join(e.Arguments[1:], " ")) })
|
||||||
i.AddCallback("PING", func(e *irc.Event) {
|
i.AddCallback("PING", func(e *irc.Event) {
|
||||||
i.SendRaw("PONG :" + e.Message())
|
i.SendRaw("PONG :" + e.Message())
|
||||||
flog.Debugf("PING/PONG")
|
flog.Debugf("PING/PONG")
|
||||||
@ -144,7 +143,11 @@ func (b *Birc) handleNotice(event *irc.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Birc) handleOther(event *irc.Event) {
|
func (b *Birc) handleOther(event *irc.Event) {
|
||||||
flog.Debugf("%#v", event)
|
switch event.Code {
|
||||||
|
case "372", "375", "376", "250", "251", "252", "253", "254", "255", "265", "266", "002", "003", "004", "005":
|
||||||
|
return
|
||||||
|
}
|
||||||
|
flog.Debugf("%#v", event.Raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Birc) handlePrivMsg(event *irc.Event) {
|
func (b *Birc) handlePrivMsg(event *irc.Event) {
|
||||||
@ -154,6 +157,7 @@ func (b *Birc) handlePrivMsg(event *irc.Event) {
|
|||||||
msg = event.Nick + " "
|
msg = event.Nick + " "
|
||||||
}
|
}
|
||||||
msg += event.Message()
|
msg += event.Message()
|
||||||
|
flog.Debugf("Sending message from %s on %s to gateway", event.Arguments[0], b.FullOrigin())
|
||||||
b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
|
b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +171,7 @@ func (b *Birc) handleTopicWhoTime(event *irc.Event) {
|
|||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
user += " [" + parts[1] + "]"
|
user += " [" + parts[1] + "]"
|
||||||
}
|
}
|
||||||
flog.Infof("%s: Topic set by %s [%s]", event.Code, user, time.Unix(t, 0))
|
flog.Debugf("%s: Topic set by %s [%s]", event.Code, user, time.Unix(t, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Birc) nicksPerRow() int {
|
func (b *Birc) nicksPerRow() int {
|
||||||
|
2
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
2
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
@ -427,7 +427,7 @@ func (irc *Connection) Connect(server string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
irc.stopped = false
|
irc.stopped = false
|
||||||
irc.Log.Printf("Connected to %s (%s)\n", irc.Server, irc.socket.RemoteAddr())
|
//irc.Log.Printf("Connected to %s (%s)\n", irc.Server, irc.socket.RemoteAddr())
|
||||||
|
|
||||||
irc.pwrite = make(chan string, 10)
|
irc.pwrite = make(chan string, 10)
|
||||||
irc.Error = make(chan error, 2)
|
irc.Error = make(chan error, 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user