KimigaiiWuyi / GenshinUID

支持OneBot(QQ)、OneBotV12、QQ频道、微信、KOOK(开黑啦)、Telegram(电报)、FeiShu(飞书)、DoDo、Villa(米游社大别野)、Discord的全功能HoshinoBot/NoneBot2/Koishi/yunzai/ZeroBot原神机器人插件
https://docs.sayu-bot.com
GNU General Public License v3.0
745 stars 101 forks source link

【bug】gspush的model中少了sr_uid字段导致sr的push报错 #640

Closed mengluo04 closed 1 month ago

mengluo04 commented 2 months ago

get_gameid_name方法里面写了 image 但是GsPush的midel中没有定义 image sr推送 GsPush.select_data_by_uid(user.sr_uid, 'sr') 报错 AttributeError: sr_uid

KimigaiiWuyi commented 2 months ago

理论上SR应该自己单开一个推送表的

mengluo04 commented 2 months ago

理论上SR应该自己单开一个推送表的

有道理()

Jerry-FaGe commented 2 months ago

gsuid_core/utils/database/dal.py

async def update_push_data(
        self, uid: str, bot_id: str, data: dict
    ) -> bool:
        retcode = -1
        if await GsPush.data_exist(uid=uid):
            retcode = await GsPush.update_data_by_uid(
                # uid, self.bot_id, 'sr' if self.is_sr else None, **data
                uid, self.bot_id, None, **data
            )
        else:
            retcode = await GsPush.full_insert_data(
                uid=uid, bot_id=bot_id, **data
            )
        status = True if retcode == 0 else False
        return status
mengluo04 commented 2 months ago

gsuid_core/utils/database/dal.py

async def update_push_data(
        self, uid: str, bot_id: str, data: dict
    ) -> bool:
        retcode = -1
        if await GsPush.data_exist(uid=uid):
            retcode = await GsPush.update_data_by_uid(
                # uid, self.bot_id, 'sr' if self.is_sr else None, **data
                uid, self.bot_id, None, **data
            )
        else:
            retcode = await GsPush.full_insert_data(
                uid=uid, bot_id=bot_id, **data
            )
        status = True if retcode == 0 else False
        return status

尝试过问题不在这里,在上一步就报错了。我应该把问题tidaocore那边,调用的是core的方法

mengluo04 commented 2 months ago

理论上SR应该自己单开一个推送表的

感觉这东西应该和core解耦,开关和阈值什么的在插件里面配置

KimigaiiWuyi commented 2 months ago

理论上SR应该自己单开一个推送表的

感觉这东西应该和core解耦,开关和阈值什么的在插件里面配置

是的 SR那边可以通过继承模型的方式去处理, 我这周和sr的作者处理一下

mengluo04 commented 2 months ago

理论上SR应该自己单开一个推送表的

感觉这东西应该和core解耦,开关和阈值什么的在插件里面配置

是的 SR那边可以通过继承模型的方式去处理, 我这周和sr的作者处理一下

膜拜大佬🫡🫡🫡🫡🫡

Jerry-FaGe commented 2 months ago

gsuid_core/utils/database/dal.py

async def update_push_data(
        self, uid: str, bot_id: str, data: dict
    ) -> bool:
        retcode = -1
        if await GsPush.data_exist(uid=uid):
            retcode = await GsPush.update_data_by_uid(
                # uid, self.bot_id, 'sr' if self.is_sr else None, **data
                uid, self.bot_id, None, **data
            )
        else:
            retcode = await GsPush.full_insert_data(
                uid=uid, bot_id=bot_id, **data
            )
        status = True if retcode == 0 else False
        return status

尝试过问题不在这里,在上一步就报错了。我应该把问题tidaocore那边,调用的是core的方法

我是要告诉你既然没有 sr 标识就不要管那个字段,把 sr 当 gs 用,这是我用了半年多的临时解决方案,sr 还没换库的时候我就在研究这东西了

StarRailUID/starrailuid_stamina/notice.py

async def get_notice_list() -> Dict[str, Dict[str, Dict]]:
    msg_dict: Dict[str, Dict[str, Dict]] = {}
    for _ in gss.active_bot:
        user_list = await GsUser.get_all_push_user_list()
        for user in user_list:
            if user.sr_uid is not None:
                raw_data = await mys_api.get_daily_data(user.sr_uid)
                if isinstance(raw_data, int):
                    logger.error(f'[sr推送提醒]获取{user.sr_uid}的数据失败!')
                    continue
                # push_data = await GsPush.select_data_by_uid(user.sr_uid, 'sr')
                push_data = await GsPush.select_data_by_uid(user.sr_uid, None)
                msg_dict = await all_check(
                    user.bot_id,
                    raw_data,
                    push_data.__dict__,
                    msg_dict,
                    user.user_id,
                    user.sr_uid,
                )
    return msg_dict

image