(cls, app, src=None)
return rv
从src迁移菜单到app
从src迁移菜单到app
从src迁移菜单到app
def migrate(cls, app, src=None):
        """
        从src迁移菜单到app
        """
        resp = (src or app).client.menu.get_menu_info()
        try:
            data = resp["selfmenu_info"]["button"]
        except KeyError:
            data = []

        with transaction.atomic():
            # 旧menu
            app.menus.all().delete()
            # 移除同步菜单产生的message handler
            app.message_handlers.filter(
                src=MessageHandler.Source.MENU).delete()
            rv = [cls.json2menu(menu, app, src) for menu in data]
        app.ext_info["current_menus"] = cls.menus2json(app)
        app.save()
        return rv
def migrate ( cls , app , src = None ) : resp = ( src or app ) . client . menu . get_menu_info ( ) try : data = resp [ "selfmenu_info" ] [ "button" ] except KeyError : data = [ ] with transaction . atomic ( ) : # 旧menu app . menus . all ( ) . delete ( ) # 移除同步菜单产生的message handler app . message_handlers . filter ( src = MessageHandler . Source . MENU ) . delete ( ) rv = [ cls . json2menu ( menu , app , src ) for menu in data ] app . ext_info [ "current_menus" ] = cls . menus2json ( app ) app . save ( ) return rv