Skip to content

Commit

Permalink
Fix logging error messages in updates.go
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarnathCJD committed Apr 15, 2024
1 parent 48b97bb commit 110a93b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
22 changes: 13 additions & 9 deletions telegram/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (c *Client) handleAlbum(message MessageObj) {
func (c *Client) handleMessageUpdateW(_ Message, pts int32) {
updatedMessage, err := c.GetDifference(pts, 1)
if err != nil {
c.Log.Error("updates.Dispatcher.GetDifference -", err)
c.Log.Error("updates.Dispatcher.getDifference -", err)
}
if updatedMessage != nil {
c.handleMessageUpdate(updatedMessage)
Expand All @@ -231,7 +231,7 @@ func (c *Client) handleEditUpdate(update Message) {
go func(h messageEditHandle) {
defer c.NewRecovery()()
if err := h.Handler(packMessage(c, msg)); err != nil {
c.Log.Error("updates.dispatcher.EditMessage -", err)
c.Log.Error("updates.dispatcher.editMessage -", err)
}
}(handle)
}
Expand All @@ -245,7 +245,7 @@ func (c *Client) handleCallbackUpdate(update *UpdateBotCallbackQuery) {
go func(h callbackHandle) {
defer c.NewRecovery()()
if err := h.Handler(packCallbackQuery(c, update)); err != nil {
c.Log.Error("updates.dispatcher.CallbackQuery -", err)
c.Log.Error("updates.dispatcher.callbackQuery -", err)
}
}(handle)
}
Expand All @@ -258,7 +258,7 @@ func (c *Client) handleInlineCallbackUpdate(update *UpdateInlineBotCallbackQuery
go func(h inlineCallbackHandle) {
defer c.NewRecovery()()
if err := h.Handler(packInlineCallbackQuery(c, update)); err != nil {
c.Log.Error("updates.dispatcher.InlineCallbackQuery -", err)
c.Log.Error("updates.dispatcher.inlineCallbackQuery -", err)
}
}(handle)
}
Expand All @@ -270,7 +270,7 @@ func (c *Client) handleParticipantUpdate(update *UpdateChannelParticipant) {
go func(h participantHandle) {
defer c.NewRecovery()()
if err := h.Handler(packChannelParticipant(c, update)); err != nil {
c.Log.Error("updates.dispatcher.ParticipantUpdate -", err)
c.Log.Error("updates.dispatcher.participantUpdate -", err)
}
}(handle)
}
Expand All @@ -282,7 +282,7 @@ func (c *Client) handleInlineUpdate(update *UpdateBotInlineQuery) {
go func(h inlineHandle) {
defer c.NewRecovery()()
if err := h.Handler(packInlineQuery(c, update)); err != nil {
c.Log.Error("updates.dispatcher.InlineQuery -", err)
c.Log.Error("updates.dispatcher.inlineQuery -", err)
}
}(handle)
}
Expand All @@ -294,7 +294,7 @@ func (c *Client) handleDeleteUpdate(update Update) {
go func(h messageDeleteHandle) {
defer c.NewRecovery()()
if err := h.Handler(packDeleteMessage(c, update)); err != nil {
c.Log.Error("updates.dispatcher.DeleteUpdate -", err)
c.Log.Error("updates.dispatcher.deleteUpdate -", err)
}
}(handle)
}
Expand All @@ -306,7 +306,7 @@ func (c *Client) handleRawUpdate(update Update) {
go func(h rawHandle) {
defer c.NewRecovery()()
if err := h.Handler(update, c); err != nil {
c.Log.Error("updates.dispatcher.RawUpdate -", err)
c.Log.Error("updates.dispatcher.rawUpdate -", err)
}
}(handle)
}
Expand Down Expand Up @@ -632,8 +632,10 @@ UpdateTypeSwitching:

goto UpdateTypeSwitching
case *UpdatesTooLong:
c.Log.Debug("update gap is too long, requesting getState")
c.UpdatesGetState()
default:
c.Log.Warn("ignoring unknown update type: ", c.JSON(u))
c.Log.Warn("skipping unhanded update (", reflect.TypeOf(u), "): ", c.JSON(u))
}
return true
}
Expand Down Expand Up @@ -663,9 +665,11 @@ func (c *Client) GetDifference(Pts, Limit int32) (Message, error) {
return update, nil
}
}

case *UpdatesDifferenceSlice:
c.Cache.UpdatePeersToCache(u.Users, u.Chats)
return u.NewMessages[0], nil

default:
return nil, nil
}
Expand Down

0 comments on commit 110a93b

Please sign in to comment.