remove all printf's and update logging
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
@@ -109,7 +109,6 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge
|
|||||||
return client.onUpdateNewMessage(ctx, update)
|
return client.onUpdateNewMessage(ctx, update)
|
||||||
})
|
})
|
||||||
dispatcher.OnNewChannelMessage(func(ctx context.Context, e tg.Entities, update *tg.UpdateNewChannelMessage) error {
|
dispatcher.OnNewChannelMessage(func(ctx context.Context, e tg.Entities, update *tg.UpdateNewChannelMessage) error {
|
||||||
fmt.Printf("%+v\n", update)
|
|
||||||
return client.onUpdateNewMessage(ctx, update)
|
return client.onUpdateNewMessage(ctx, update)
|
||||||
})
|
})
|
||||||
dispatcher.OnUserName(client.onUserName)
|
dispatcher.OnUserName(client.onUserName)
|
||||||
@@ -200,7 +199,7 @@ func (t *TelegramClient) Disconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TelegramClient) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error) {
|
func (t *TelegramClient) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error) {
|
||||||
fmt.Printf("get chat info %+v\n", portal)
|
// fmt.Printf("get chat info %+v\n", portal)
|
||||||
peerType, id, err := ids.ParsePortalID(portal.ID)
|
peerType, id, err := ids.ParsePortalID(portal.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -256,7 +255,7 @@ func (t *TelegramClient) GetChatInfo(ctx context.Context, portal *bridgev2.Porta
|
|||||||
|
|
||||||
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
|
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("full chat is not %T", chatFull)
|
return nil, fmt.Errorf("full chat is %T not *tg.ChatFull", fullChat.FullChat)
|
||||||
}
|
}
|
||||||
|
|
||||||
if photo, ok := chatFull.GetChatPhoto(); ok {
|
if photo, ok := chatFull.GetChatPhoto(); ok {
|
||||||
@@ -303,7 +302,7 @@ func (t *TelegramClient) GetChatInfo(ctx context.Context, portal *bridgev2.Porta
|
|||||||
|
|
||||||
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
|
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("full chat is not %T", chatFull)
|
return nil, fmt.Errorf("full chat is %T *tg.ChatFull", fullChat.FullChat)
|
||||||
}
|
}
|
||||||
|
|
||||||
if photo, ok := chatFull.GetChatPhoto(); ok {
|
if photo, ok := chatFull.GetChatPhoto(); ok {
|
||||||
@@ -327,7 +326,7 @@ func (t *TelegramClient) GetChatInfo(ctx context.Context, portal *bridgev2.Porta
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Printf("%s %d\n", peerType, id)
|
// fmt.Printf("%s %d\n", peerType, id)
|
||||||
panic("unimplemented getchatinfo")
|
panic("unimplemented getchatinfo")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ func (t *TelegramClient) onUpdateNewMessage(ctx context.Context, update IGetMess
|
|||||||
Timestamp: time.Unix(int64(msg.Date), 0),
|
Timestamp: time.Unix(int64(msg.Date), 0),
|
||||||
})
|
})
|
||||||
case *tg.MessageService:
|
case *tg.MessageService:
|
||||||
fmt.Printf("message service\n")
|
// fmt.Printf("message service\n")
|
||||||
fmt.Printf("%v\n", msg)
|
// fmt.Printf("%v\n", msg)
|
||||||
|
|
||||||
// sender := t.getEventSender(msg)
|
// sender := t.getEventSender(msg)
|
||||||
// switch action := msg.Action.(type) {
|
// switch action := msg.Action.(type) {
|
||||||
@@ -136,8 +136,8 @@ func (t *TelegramClient) getEventSender(msg messageWithSender) (sender bridgev2.
|
|||||||
sender.SenderLogin = ids.MakeUserLoginID(from.UserID)
|
sender.SenderLogin = ids.MakeUserLoginID(from.UserID)
|
||||||
sender.Sender = ids.MakeUserID(from.UserID)
|
sender.Sender = ids.MakeUserID(from.UserID)
|
||||||
default:
|
default:
|
||||||
fmt.Printf("%+v\n", f)
|
// fmt.Printf("%+v\n", f)
|
||||||
fmt.Printf("%T\n", f)
|
// fmt.Printf("%T\n", f)
|
||||||
panic("unimplemented FromID")
|
panic("unimplemented FromID")
|
||||||
}
|
}
|
||||||
} else if peer, ok := msg.GetPeerID().(*tg.PeerUser); ok {
|
} else if peer, ok := msg.GetPeerID().(*tg.PeerUser); ok {
|
||||||
@@ -202,7 +202,7 @@ func (t *TelegramClient) onEntityUpdate(ctx context.Context, e tg.Entities) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TelegramClient) onMessageEdit(ctx context.Context, update IGetMessage) error {
|
func (t *TelegramClient) onMessageEdit(ctx context.Context, update IGetMessage) error {
|
||||||
fmt.Printf("message edit %+v\n", update)
|
// fmt.Printf("message edit %+v\n", update)
|
||||||
msg, ok := update.GetMessage().(*tg.Message)
|
msg, ok := update.GetMessage().(*tg.Message)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("edit message is not *tg.Message")
|
return fmt.Errorf("edit message is not *tg.Message")
|
||||||
@@ -228,6 +228,7 @@ func (t *TelegramClient) onMessageEdit(ctx context.Context, update IGetMessage)
|
|||||||
|
|
||||||
func (t *TelegramClient) handleTelegramReactions(ctx context.Context, msg *tg.Message) error {
|
func (t *TelegramClient) handleTelegramReactions(ctx context.Context, msg *tg.Message) error {
|
||||||
if _, set := msg.GetReactions(); !set {
|
if _, set := msg.GetReactions(); !set {
|
||||||
|
// fmt.Printf("no reactions\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var totalCount int
|
var totalCount int
|
||||||
@@ -238,6 +239,7 @@ func (t *TelegramClient) handleTelegramReactions(ctx context.Context, msg *tg.Me
|
|||||||
reactionsList := msg.Reactions.RecentReactions
|
reactionsList := msg.Reactions.RecentReactions
|
||||||
if totalCount > 0 && len(reactionsList) == 0 && !msg.Reactions.CanSeeList {
|
if totalCount > 0 && len(reactionsList) == 0 && !msg.Reactions.CanSeeList {
|
||||||
// We don't know who reacted in a channel, so we can't bridge it properly either
|
// We don't know who reacted in a channel, so we can't bridge it properly either
|
||||||
|
zerolog.Ctx(ctx).Warn().Int("message_id", msg.ID).Msg("Can't see reaction list in channel")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user