mirror of
https://github.com/Xtao-Labs/misskey2telegram.git
synced 2024-11-22 13:55:53 +00:00
feat: auto fix
This commit is contained in:
parent
3a98112eda
commit
0115063152
@ -158,14 +158,3 @@ class UserAction:
|
|||||||
user.push_chat_id = push_chat_id
|
user.push_chat_id = push_chat_id
|
||||||
await UserAction.update_user(user)
|
await UserAction.update_user(user)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
async def change_user_fcm_token(user_id: int, fcm_token: str) -> bool:
|
|
||||||
user = await UserAction.get_user_by_id(user_id)
|
|
||||||
if not user:
|
|
||||||
return False
|
|
||||||
if user.fcm_token == fcm_token:
|
|
||||||
return False
|
|
||||||
user.fcm_token = fcm_token
|
|
||||||
await UserAction.update_user(user)
|
|
||||||
return True
|
|
||||||
|
43
modules/fix.py
Normal file
43
modules/fix.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
from pyrogram import Client, filters
|
||||||
|
from pyrogram.types import Message
|
||||||
|
|
||||||
|
from misskey_init import get_misskey_bot, rerun_misskey_bot, test_token
|
||||||
|
from models.services.user import UserAction
|
||||||
|
|
||||||
|
no_account = (
|
||||||
|
"你还没有绑定账号哦,请使用 `/start https://[misskey_domain]` 设置账号所在 Misskey 实例地址(仅支持 https 链接)。"
|
||||||
|
)
|
||||||
|
no_timeline = "你还没有绑定时间线话题哦,在论坛群组中使用 /bind_timeline 绑定 Timeline 话题,接收时间线更新。"
|
||||||
|
no_notice = "你还没有绑定通知话题哦,在论坛群组中使用 /bind_notice 绑定 Notice 话题,接收通知。"
|
||||||
|
token_expired = "Token 已过期,请重新绑定账号。"
|
||||||
|
success = "bot 运行正常,无需修复!"
|
||||||
|
no_bot = "bot 似乎离线,已尝试重启..."
|
||||||
|
cannot_fix = "无法自助修复,请联系实例管理员!"
|
||||||
|
|
||||||
|
|
||||||
|
@Client.on_message(filters.incoming & filters.private & filters.command(["fix"]))
|
||||||
|
async def fix_command(_: Client, message: Message):
|
||||||
|
if get_misskey_bot(message.from_user.id):
|
||||||
|
await message.reply(success, quote=True)
|
||||||
|
return
|
||||||
|
user = await UserAction.get_user_by_id(message.from_user.id)
|
||||||
|
if not user:
|
||||||
|
await message.reply(no_account, quote=True)
|
||||||
|
return
|
||||||
|
if not user.token:
|
||||||
|
await message.reply(no_account, quote=True)
|
||||||
|
return
|
||||||
|
if not (await test_token(user.host, user.token)):
|
||||||
|
await message.reply(token_expired, quote=True)
|
||||||
|
return
|
||||||
|
if not user.push_chat_id:
|
||||||
|
if not user.timeline_topic:
|
||||||
|
await message.reply(no_timeline, quote=True)
|
||||||
|
return
|
||||||
|
if not user.notice_topic:
|
||||||
|
await message.reply(no_notice, quote=True)
|
||||||
|
return
|
||||||
|
if await rerun_misskey_bot(message.from_user.id):
|
||||||
|
await message.reply(no_bot, quote=True)
|
||||||
|
return
|
||||||
|
await message.reply(cannot_fix, quote=True)
|
@ -21,6 +21,8 @@ des = f"""欢迎使用 {bot.me.first_name},这是一个用于在 Telegram 上
|
|||||||
|
|
||||||
6. [可选] 在私聊中使用 `/config` 设置敏感媒体是否自动设置 Spoiler
|
6. [可选] 在私聊中使用 `/config` 设置敏感媒体是否自动设置 Spoiler
|
||||||
|
|
||||||
|
7. 使用 `/fix` 可尝试自助修复机器人运行问题,若无法修复请联系实例管理员
|
||||||
|
|
||||||
至此,你便可以在 Telegram 接收 Misskey 消息,同时你可以私聊我使用 /status 查看 Bot 运行状态
|
至此,你便可以在 Telegram 接收 Misskey 消息,同时你可以私聊我使用 /status 查看 Bot 运行状态
|
||||||
|
|
||||||
此 Bot 仅支持 Misskey V13 实例的账号!"""
|
此 Bot 仅支持 Misskey V13 实例的账号!"""
|
||||||
|
Loading…
Reference in New Issue
Block a user