🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-05-01 12:57:37 +00:00
parent 9888d879bb
commit aace21983e

View File

@@ -147,7 +147,6 @@ class ObservationInfo:
chat_observer: Optional[ChatObserver] chat_observer: Optional[ChatObserver]
handler: Optional[ObservationInfoHandler] handler: Optional[ObservationInfoHandler]
def __init__(self, private_name: str): def __init__(self, private_name: str):
""" """
手动初始化 ObservationInfo 的所有实例变量。 手动初始化 ObservationInfo 的所有实例变量。
@@ -197,9 +196,9 @@ class ObservationInfo:
self.chat_observer = chat_observer self.chat_observer = chat_observer
try: try:
if not self.handler: # 确保 handler 已经被创建 if not self.handler: # 确保 handler 已经被创建
logger.error(f"[私聊][{self.private_name}] 尝试绑定时 handler 未初始化!") logger.error(f"[私聊][{self.private_name}] 尝试绑定时 handler 未初始化!")
self.chat_observer = None # 重置,防止后续错误 self.chat_observer = None # 重置,防止后续错误
return return
# 注册关心的通知类型 # 注册关心的通知类型
@@ -220,7 +219,9 @@ class ObservationInfo:
def unbind_from_chat_observer(self): def unbind_from_chat_observer(self):
"""解除与chat_observer的绑定""" """解除与chat_observer的绑定"""
if self.chat_observer and hasattr(self.chat_observer, "notification_manager") and self.handler: # 增加 handler 检查 if (
self.chat_observer and hasattr(self.chat_observer, "notification_manager") and self.handler
): # 增加 handler 检查
try: try:
self.chat_observer.notification_manager.unregister_handler( self.chat_observer.notification_manager.unregister_handler(
target="observation_info", notification_type=NotificationType.NEW_MESSAGE, handler=self.handler target="observation_info", notification_type=NotificationType.NEW_MESSAGE, handler=self.handler