️ 修复翻译错误、增加每日一言指令

This commit is contained in:
xtaodada 2020-04-01 19:04:56 +08:00
parent 68e6385bc8
commit 26800f7810
No known key found for this signature in database
GPG Key ID: 39EFACA711DF5D8C

View File

@ -1,5 +1,7 @@
""" Message related utilities. """
import requests
import json
from telethon.tl.functions.messages import DeleteChatUserRequest
from telethon.tl.functions.channels import LeaveChannelRequest
from telethon.errors.rpcerrorlist import ChatIdInvalidError
@ -84,7 +86,7 @@ async def log(context):
@listener(outgoing=True, command="re",
description="在当前会话复读这条消息。")
description="在当前会话复读回复的消息。")
async def re(context):
""" Forwards a message into log group """
if context.reply_to_msg_id:
@ -140,6 +142,38 @@ async def feet2meter(context):
await context.edit(f"{str(feet)} 英尺转换为了 {str(meter)} 米。")
@listener(outgoing=True, command="hitokoto",
description="发送一句一言")
async def hitokoto(context):
""" Get hitokoto.cn """
hitokoto_json = json.loads(requests.get("https://v1.hitokoto.cn/?charset=utf-8").content.decode("utf-8"))
if hitokoto_json['type'] == 'a':
hitokoto_type = '动画'
elif hitokoto_json['type'] == 'b':
hitokoto_type = '漫画'
elif hitokoto_json['type'] == 'c':
hitokoto_type = '游戏'
elif hitokoto_json['type'] == 'd':
hitokoto_type = '文学'
elif hitokoto_json['type'] == 'e':
hitokoto_type = '原创'
elif hitokoto_json['type'] == 'f':
hitokoto_type = '来自网络'
elif hitokoto_json['type'] == 'g':
hitokoto_type = '其他'
elif hitokoto_json['type'] == 'h':
hitokoto_type = '影视'
elif hitokoto_json['type'] == 'i':
hitokoto_type = '诗词'
elif hitokoto_json['type'] == 'j':
hitokoto_type = '网易云'
elif hitokoto_json['type'] == 'k':
hitokoto_type = '哲学'
elif hitokoto_json['type'] == 'l':
hitokoto_type = '抖机灵'
await context.edit(f"{hitokoto_json['hitokoto']} - {hitokoto_json['from']} ({str(hitokoto_type)})")
@listener(outgoing=True, command="source",
description="显示原始 PagerMaid git 存储库的URL。")
async def source(context):