💡 尝试通过循环修复一言报错
This commit is contained in:
parent
e3e92ab69d
commit
06c726bc30
@ -157,7 +157,17 @@ async def feet2meter(context):
|
|||||||
description="发送一句一言")
|
description="发送一句一言")
|
||||||
async def hitokoto(context):
|
async def hitokoto(context):
|
||||||
""" Get hitokoto.cn """
|
""" Get hitokoto.cn """
|
||||||
hitokoto_json = json.loads(requests.get("https://v1.hitokoto.cn/?charset=utf-8").content.decode("utf-8"))
|
hitokoto_while = 1
|
||||||
|
try:
|
||||||
|
hitokoto_json = json.loads(requests.get("https://v1.hitokoto.cn/?charset=utf-8").content.decode("utf-8"))
|
||||||
|
except (ValueError):
|
||||||
|
while hitokoto_while < 10:
|
||||||
|
hitokoto_while += 1
|
||||||
|
try:
|
||||||
|
hitokoto_json = json.loads(requests.get("https://v1.hitokoto.cn/?charset=utf-8").content.decode("utf-8"))
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
if hitokoto_json['type'] == 'a':
|
if hitokoto_json['type'] == 'a':
|
||||||
hitokoto_type = '动画'
|
hitokoto_type = '动画'
|
||||||
elif hitokoto_json['type'] == 'b':
|
elif hitokoto_json['type'] == 'b':
|
||||||
@ -196,4 +206,4 @@ async def source(context):
|
|||||||
description="显示原始 PagerMaid 项目主页的URL。")
|
description="显示原始 PagerMaid 项目主页的URL。")
|
||||||
async def site(context):
|
async def site(context):
|
||||||
""" Outputs the site URL. """
|
""" Outputs the site URL. """
|
||||||
await context.edit("https://katonkeyboard.moe/pagermaid.html")
|
await context.edit("https://katonkeyboard.moe/pagermaid.html")
|
||||||
|
Loading…
Reference in New Issue
Block a user