mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-12-24 03:25:40 +00:00
Improve debug messages
This commit is contained in:
parent
20dbd71306
commit
594d2155e3
@ -96,7 +96,7 @@ func (b *Bdiscord) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
|
||||
func (b *Bdiscord) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
channelID := b.getChannelID(msg.Channel)
|
||||
if channelID == "" {
|
||||
@ -180,8 +180,8 @@ func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelet
|
||||
if b.UseChannelID {
|
||||
rmsg.Channel = "ID:" + m.ChannelID
|
||||
}
|
||||
b.Log.Debugf("Sending message from %s to gateway", b.Account)
|
||||
b.Log.Debugf("Message is %#v", rmsg)
|
||||
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
|
||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
||||
rmsg := config.Message{Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg", UserID: m.Author.ID, ID: m.ID}
|
||||
|
||||
if m.Content != "" {
|
||||
b.Log.Debugf("Receiving message %#v", m.Message)
|
||||
b.Log.Debugf("== Receiving event %#v", m.Message)
|
||||
m.Message.Content = b.stripCustomoji(m.Message.Content)
|
||||
m.Message.Content = b.replaceChannelMentions(m.Message.Content)
|
||||
rmsg.Text, err = m.ContentWithMoreMentionsReplaced(b.c)
|
||||
@ -261,8 +261,8 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
||||
rmsg.Event = config.EVENT_USER_ACTION
|
||||
}
|
||||
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", m.Author.Username, b.Account)
|
||||
b.Log.Debugf("Message is %#v", rmsg)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
|
||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ func (b *Bgitter) JoinChannel(channel config.ChannelInfo) error {
|
||||
case *gitter.MessageReceived:
|
||||
// ignore message sent from ourselves
|
||||
if ev.Message.From.ID != b.User.ID {
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", ev.Message.From.Username, b.Account)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", ev.Message.From.Username, b.Account)
|
||||
rmsg := config.Message{Username: ev.Message.From.Username, Text: ev.Message.Text, Channel: room,
|
||||
Account: b.Account, Avatar: b.getAvatar(ev.Message.From.Username), UserID: ev.Message.From.ID,
|
||||
ID: ev.Message.ID}
|
||||
@ -79,7 +79,7 @@ func (b *Bgitter) JoinChannel(channel config.ChannelInfo) error {
|
||||
rmsg.Event = config.EVENT_USER_ACTION
|
||||
rmsg.Text = strings.Replace(rmsg.Text, "@"+ev.Message.From.Username+" ", "", -1)
|
||||
}
|
||||
b.Log.Debugf("Message is %#v", rmsg)
|
||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
case *gitter.GitterConnectionClosed:
|
||||
@ -91,7 +91,7 @@ func (b *Bgitter) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
|
||||
func (b *Bgitter) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
roomID := b.getRoomID(msg.Channel)
|
||||
if roomID == "" {
|
||||
b.Log.Errorf("Could not find roomID for %v", msg.Channel)
|
||||
|
@ -156,7 +156,7 @@ func (b *Birc) Send(msg config.Message) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
// Execute a command
|
||||
if strings.HasPrefix(msg.Text, "!") {
|
||||
@ -289,9 +289,9 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
|
||||
}
|
||||
}
|
||||
if event.Source.Name != b.Nick {
|
||||
b.Log.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account)
|
||||
b.Log.Debugf("<= Sending JOIN_LEAVE event from %s to gateway", b.Account)
|
||||
msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}
|
||||
b.Log.Debugf("Message is %#v", msg)
|
||||
b.Log.Debugf("<= Message is %#v", msg)
|
||||
b.Remote <- msg
|
||||
return
|
||||
}
|
||||
@ -352,7 +352,7 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.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}
|
||||
b.Log.Debugf("Receiving PRIVMSG: %s %s %#v", event.Source.Name, event.Trailing, event)
|
||||
b.Log.Debugf("== Receiving PRIVMSG: %s %s %#v", event.Source.Name, event.Trailing, event)
|
||||
|
||||
// set action event
|
||||
if event.IsAction() {
|
||||
@ -393,7 +393,7 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
|
||||
output, _ := ioutil.ReadAll(r)
|
||||
rmsg.Text = string(output)
|
||||
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", event.Params[0], b.Account)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", event.Params[0], b.Account)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (b *Bmatrix) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
|
||||
func (b *Bmatrix) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
channel := b.getRoomID(msg.Channel)
|
||||
b.Log.Debugf("Channel %s maps to channel id %s", msg.Channel, channel)
|
||||
@ -140,7 +140,7 @@ func (b *Bmatrix) handlematrix() error {
|
||||
}
|
||||
|
||||
func (b *Bmatrix) handleEvent(ev *matrix.Event) {
|
||||
b.Log.Debugf("Received: %#v", ev)
|
||||
b.Log.Debugf("== Receiving event: %#v", ev)
|
||||
if ev.Sender != b.UserID {
|
||||
b.RLock()
|
||||
channel, ok := b.RoomMap[ev.RoomID]
|
||||
@ -189,7 +189,7 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
|
||||
}
|
||||
}
|
||||
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", ev.Sender, b.Account)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", ev.Sender, b.Account)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func (b *Bmattermost) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
|
||||
func (b *Bmattermost) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
// Make a action /me of the message
|
||||
if msg.Event == config.EVENT_USER_ACTION {
|
||||
@ -185,8 +185,8 @@ func (b *Bmattermost) handleMatter() {
|
||||
if ok {
|
||||
message.Event = config.EVENT_USER_ACTION
|
||||
}
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
|
||||
b.Log.Debugf("Message is %#v", message)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.Username, b.Account)
|
||||
b.Log.Debugf("<= Message is %#v", message)
|
||||
b.Remote <- *message
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
|
||||
b.handleDownloadAvatar(message.UserID, message.Channel)
|
||||
}
|
||||
|
||||
b.Log.Debugf("Receiving from matterclient %#v", message)
|
||||
b.Log.Debugf("== Receiving event %#v", message)
|
||||
|
||||
rmsg := &config.Message{Username: message.Username, UserID: message.UserID, Channel: message.Channel, Text: message.Text, ID: message.Post.Id, Extra: make(map[string][]interface{})}
|
||||
|
||||
|
@ -50,7 +50,7 @@ func (b *Brocketchat) Send(msg config.Message) (string, error) {
|
||||
if msg.Event == config.EVENT_MSG_DELETE {
|
||||
return "", nil
|
||||
}
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
if msg.Extra != nil {
|
||||
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
|
||||
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: rmsg.Channel, UserName: rmsg.Username,
|
||||
@ -88,7 +88,7 @@ func (b *Brocketchat) handleRocketHook() {
|
||||
if message.UserName == b.Config.Nick {
|
||||
continue
|
||||
}
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", message.UserName, b.Account)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.UserName, b.Account)
|
||||
b.Remote <- config.Message{Text: message.Text, Username: message.UserName, Channel: message.ChannelName, Account: b.Account, UserID: message.UserID}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func (b *Bslack) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
|
||||
func (b *Bslack) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
// Make a action /me of the message
|
||||
if msg.Event == config.EVENT_USER_ACTION {
|
||||
@ -190,7 +190,6 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
|
||||
}
|
||||
|
||||
// Post normal message
|
||||
b.Log.Debugf("NP IS %#v", np)
|
||||
_, id, err := b.sc.PostMessage(schannel.ID, msg.Text, np)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -246,7 +245,7 @@ func (b *Bslack) handleSlack() {
|
||||
time.Sleep(time.Second)
|
||||
b.Log.Debug("Start listening for Slack messages")
|
||||
for message := range messages {
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.Username, b.Account)
|
||||
|
||||
// cleanup the message
|
||||
message.Text = b.replaceURL(message.Text)
|
||||
@ -258,7 +257,7 @@ func (b *Bslack) handleSlack() {
|
||||
// Add the avatar
|
||||
message.Avatar = b.getAvatar(message.Username)
|
||||
|
||||
b.Log.Debugf("Message is %#v", message)
|
||||
b.Log.Debugf("<= Message is %#v", message)
|
||||
b.Remote <- *message
|
||||
}
|
||||
}
|
||||
@ -266,7 +265,7 @@ func (b *Bslack) handleSlack() {
|
||||
func (b *Bslack) handleSlackClient(messages chan *config.Message) {
|
||||
for msg := range b.rtm.IncomingEvents {
|
||||
if msg.Type != "user_typing" && msg.Type != "latency_report" {
|
||||
b.Log.Debugf("Receiving from slackclient %#v", msg.Data)
|
||||
b.Log.Debugf("== Receiving event %#v", msg.Data)
|
||||
}
|
||||
switch ev := msg.Data.(type) {
|
||||
case *slack.MessageEvent:
|
||||
|
@ -55,7 +55,7 @@ func (b *Bsshchat) Send(msg config.Message) (string, error) {
|
||||
if msg.Event == config.EVENT_MSG_DELETE {
|
||||
return "", nil
|
||||
}
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
if msg.Extra != nil {
|
||||
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
|
||||
b.w.Write([]byte(rmsg.Username + rmsg.Text + "\r\n"))
|
||||
@ -124,7 +124,7 @@ func (b *Bsshchat) handleSshChat() error {
|
||||
continue
|
||||
}
|
||||
if !wait {
|
||||
b.Log.Debugf("message %#v", res)
|
||||
b.Log.Debugf("<= Message %#v", res)
|
||||
rmsg := config.Message{Username: res[0], Text: strings.Join(res[1:], ":"), Channel: "sshchat", Account: b.Account, UserID: "nick"}
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ func (b *Bsteam) handleEvents() {
|
||||
switch e := event.(type) {
|
||||
case *steam.ChatMsgEvent:
|
||||
b.Log.Debugf("Receiving ChatMsgEvent: %#v", e)
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", b.getNick(e.ChatterId), b.Account)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", b.getNick(e.ChatterId), b.Account)
|
||||
var channel int64
|
||||
if e.ChatRoomId == 0 {
|
||||
channel = int64(e.ChatterId)
|
||||
|
@ -50,7 +50,7 @@ func (b *Btelegram) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
|
||||
func (b *Btelegram) Send(msg config.Message) (string, error) {
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
// get the chatid
|
||||
chatid, err := strconv.ParseInt(msg.Channel, 10, 64)
|
||||
@ -119,7 +119,7 @@ func (b *Btelegram) Send(msg config.Message) (string, error) {
|
||||
|
||||
func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
|
||||
for update := range updates {
|
||||
b.Log.Debugf("Receiving from telegram: %#v", update.Message)
|
||||
b.Log.Debugf("== Receiving event: %#v", update.Message)
|
||||
|
||||
if update.Message == nil && update.ChannelPost == nil {
|
||||
b.Log.Error("Getting nil messages, this shouldn't happen.")
|
||||
@ -226,8 +226,8 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
|
||||
if rmsg.Text != "" || len(rmsg.Extra) > 0 {
|
||||
rmsg.Avatar = helper.GetAvatar(b.avatarMap, strconv.Itoa(message.From.ID), b.General)
|
||||
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", rmsg.Username, b.Account)
|
||||
b.Log.Debugf("Message is %#v", rmsg)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
|
||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
|
||||
if msg.Event == config.EVENT_MSG_DELETE {
|
||||
return "", nil
|
||||
}
|
||||
b.Log.Debugf("Receiving %#v", msg)
|
||||
b.Log.Debugf("=> Receiving %#v", msg)
|
||||
|
||||
// Upload a file (in xmpp case send the upload URL because xmpp has no native upload support)
|
||||
if msg.Extra != nil {
|
||||
@ -161,8 +161,8 @@ func (b *Bxmpp) handleXMPP() error {
|
||||
if ok {
|
||||
rmsg.Event = config.EVENT_USER_ACTION
|
||||
}
|
||||
b.Log.Debugf("Sending message from %s on %s to gateway", rmsg.Username, b.Account)
|
||||
b.Log.Debugf("Message is %#v", rmsg)
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
|
||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
case xmpp.Presence:
|
||||
|
@ -256,7 +256,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
|
||||
continue
|
||||
}
|
||||
}
|
||||
flog.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
|
||||
flog.Debugf("=> Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
|
||||
msg.Channel = channel.Name
|
||||
msg.Avatar = gw.modifyAvatar(origmsg, dest)
|
||||
msg.Username = gw.modifyUsername(origmsg, dest)
|
||||
@ -281,6 +281,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
|
||||
}
|
||||
// append the message ID (mID) from this bridge (dest) to our brMsgIDs slice
|
||||
if mID != "" {
|
||||
flog.Debugf("mID %s: %s", dest.Account, mID)
|
||||
brMsgIDs = append(brMsgIDs, &BrMsgID{dest, mID, channel.ID})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user