package telegram import ( log "github.com/sirupsen/logrus" "github.com/zelenin/go-tdlib/client" ) func uhOh() { log.Fatal("Update type mismatch") } func (c *Client) updateHandler() { listener := c.client.GetListener() defer listener.Close() for update := range listener.Updates { if update.GetClass() == client.ClassUpdate { switch update.GetType() { case client.TypeUpdateUser: typedUpdate, ok := update.(*client.UpdateUser) if !ok { uhOh() } c.updateUser(typedUpdate) default: // log only handled types continue } log.Debugf("%#v", update) } } } func (c *Client) updateUser(update *client.UpdateUser) { cache.users[update.User.Id] = update.User c.processStatusUpdate(update.User.Id, &update.User.Status) }