Rinfair / SuzunoBot-AGLAS

Multifunctional bot recreation based on Nonebot 2 & Kiba 基于Nonebot 2 和 Kiba 二创的多功能音游bot,可用于maimaiDX&Arcaea
MIT License
14 stars 4 forks source link

今日性癖功能报错 #9

Closed xpf580 closed 1 year ago

xpf580 commented 1 year ago

在用户输入'jrxp'时报错
File "B:\PythonProject\SuzunoBot-AGLAS.\src\libraries\tool.py", line 6, in hash return (days * qq) >> 8, str(days) TypeError: unsupported operand type(s) for >>: 'str' and 'int' 初步解决方案:可以使用今日性癖功能,但是无法再随机一个今日性癖 在 maimaidx.py 文件中直接调用 hash() 函数,将返回的整数用作参数无需进行解包。具体的实现方案: @jrxp.handle() async def (event: Event, message: Message = CommandArg()): check_date() today = get_today() qq = int(event.get_user_id()) h = hash(qq) random.seed(h) r = random.random() rp = hash(int(r) + h) % 100

if (qq, today) in random_numbers:
    rp = random_numbers[(qq, today)]

nickname = event.sender.nickname
random_numbers[(qq, today)] = rp
save_random_numbers(random_numbers)
xp = random.randint(0, 32)
s = f"▾ [Sender: {nickname}]\n  今日性癖\n{nickname}今天的性癖是{xp_list[xp]},人品值是{rp}%.\n不满意的话再随一个吧!"
await jrxp.finish(Message([
    MessageSegment("text", {"text": s})
]))

tool.py 中的 hash() 函数,仅返回整数部分,而不再返回字符串 def hash(qq: int): days = int(time.strftime("%d", time.localtime(time.time()))) + 31 int( time.strftime("%m", time.localtime(time.time()))) + 77 return (days qq) >> 8

xpf580 commented 1 year ago

jrrp功能也是同样的方法解决的,目前没有问题了