feat : 接入了noname的插件到bot(多线程运行)
This commit is contained in:
@@ -6,7 +6,7 @@ import re
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from typing import Dict, Any, Optional, Set
|
||||
|
||||
import time
|
||||
import httpx
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
@@ -142,7 +142,7 @@ class MCWatcher:
|
||||
self.state.load()
|
||||
|
||||
self._stop = False
|
||||
self._task = asyncio.run(self._poll_loop())
|
||||
self._task = asyncio.run(self._poll_loop())
|
||||
# self._task = asyncio.create_task(self._poll_loop())
|
||||
|
||||
logger.info(
|
||||
@@ -154,7 +154,7 @@ class MCWatcher:
|
||||
if self._task:
|
||||
self._task.cancel()
|
||||
# try:
|
||||
# # await self._task
|
||||
# await self._task
|
||||
# except asyncio.CancelledError:
|
||||
# pass
|
||||
self.state.save()
|
||||
@@ -243,6 +243,9 @@ class MCWatcher:
|
||||
# ========== 轮询 ==========
|
||||
|
||||
async def _poll_loop(self):
|
||||
logger.info("等待bot完毕~")
|
||||
# 防止bot未初始化
|
||||
time.sleep(10)
|
||||
try:
|
||||
await self._check_once(force_push=False)
|
||||
except Exception as e:
|
||||
@@ -353,4 +356,4 @@ class MCWatcher:
|
||||
|
||||
# logger.info(f"{_ts()} MCWatcher 已推送 {ok}/{len(targets)} 个会话。")
|
||||
async def _broadcast(self, text: str, targets: Set[str]):
|
||||
self.hookfunction.__call__(text,targets)
|
||||
self.hookfunction(text)
|
||||
Reference in New Issue
Block a user