fix telegram
This commit is contained in:
@ -51,11 +51,15 @@ class Telegram(metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
定义线程函数来运行 infinity_polling
|
定义线程函数来运行 infinity_polling
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
_bot.infinity_polling(long_polling_timeout=5)
|
_bot.infinity_polling(long_polling_timeout=5)
|
||||||
|
except Exception as err:
|
||||||
|
logger.error(f"Telegram消息接收服务异常:{err}")
|
||||||
|
|
||||||
# 启动线程来运行 infinity_polling
|
# 启动线程来运行 infinity_polling
|
||||||
self._polling_thread = threading.Thread(target=run_polling)
|
self._polling_thread = threading.Thread(target=run_polling)
|
||||||
self._polling_thread.start()
|
self._polling_thread.start()
|
||||||
|
logger.info("Telegram消息接收服务启动")
|
||||||
|
|
||||||
def send_msg(self, title: str, text: str = "", image: str = "", userid: str = "") -> Optional[bool]:
|
def send_msg(self, title: str, text: str = "", image: str = "", userid: str = "") -> Optional[bool]:
|
||||||
"""
|
"""
|
||||||
@ -214,3 +218,4 @@ class Telegram(metaclass=Singleton):
|
|||||||
if self._bot:
|
if self._bot:
|
||||||
self._bot.stop_polling()
|
self._bot.stop_polling()
|
||||||
self._polling_thread.join()
|
self._polling_thread.join()
|
||||||
|
logger.info("Telegram消息接收服务已停止")
|
||||||
|
Reference in New Issue
Block a user