You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tgupdates.go
    path of file: ./repos/integram
    
    the code of the file until where you have to start completion: package integram

import (
	"errors"
	"fmt"
	"reflect"
	"regexp"
	"strconv"
	"strings"
	"sync"
	"time"

	tg "github.com/requilence/telegram-bot-api"
	log "github.com/sirupsen/logrus"
	mgo "gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

var updateMapMutex = &sync.RWMutex{}
var updateMutexPerBotPerChat = make(map[string]*sync.Mutex)

type msgInfo struct {
	TS       time.Time
	ID       int
	InlineID string
	BotID    int64
	ChatID   int64
}

func updateRoutine(b *Bot, u *tg.Update) {

	if !Config.Debug {
		defer func() {
			if r := recover(); r != nil {
				stack := stack(3)
				log.Errorf("Panic recovery at updateRoutin
    
func migrateToSuperGroup(db *mgo.Database, fromChatID int64, toChatID int64) {
	if fromChatID == toChatID {
		return
	}

	var chat chatData
	_, err := db.C("chats").FindId(fromChatID).Apply(mgo.Change{
		Update: bson.M{"$set": bson.M{"migratedtochatid": toChatID}, "$unset": bson.M{"hooks": "", "membersids": ""}},
	}, &chat)
	if err != nil {
		log.WithError(err).Error("migrateToSuperGroup remove")
	}

	if chat.ID != 0 {
		chat.ID = toChatID
		chat.Type = "supergroup"
		chat.MigratedFromChatID = toChatID

		_, err := db.C("chats").Upsert(bson.M{"_id": toChatID, "migratedfromchatid": bson.M{"$exists": false}}, chat)

		if err != nil {
			log.WithError(err).Error("migrateToSuperGroup ID insert error")
		}
	}

	err = db.C("users").Update(bson.M{"hooks.chats": fromChatID}, bson.M{"$addToSet": bson.M{"hooks.$.chats": toChatID}})
	if err != nil {
		log.WithError(err).Error("migrateToSuperGroup add new hook chats")
	}
	err = db.C("users").Update(bson.M{"hooks.chats": toChatID}, bson.M{"$pull": bson.M{"hooks.$.chats": fromChatID}})
	if err != nil {
		log.WithError(err).Error("migrateToSuperGroup remove outdated hook chats")
	}
}