keep_online 保持 Telegram 账号一直在线

This commit is contained in:
xtaodada 2023-06-03 22:10:10 +08:00
parent 1abd1edb5c
commit 2a3d0c2039
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 18 additions and 0 deletions

3
keep_online/DES.md Normal file
View File

@ -0,0 +1,3 @@
保持 Telegram 账号一直在线
安装即可,无需配置

15
keep_online/main.py Normal file
View File

@ -0,0 +1,15 @@
import contextlib
from pyrogram.raw.functions.account import UpdateStatus
from pagermaid import log
from pagermaid.services import bot, scheduler
@scheduler.scheduled_job("interval", seconds=55, id="keep_online")
async def keep_online():
try:
await bot.invoke(UpdateStatus(offline=False))
except Exception as e:
with contextlib.suppress(Exception):
await log(f"Keep online failed: {e}")