chore: 显式返回None
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
import urllib3
|
||||
|
||||
from .utils_image import image_manager
|
||||
|
||||
from ..message.message_base import Seg, UserInfo, BaseMessageInfo, MessageBase
|
||||
from .chat_stream import ChatStream
|
||||
from src.common.logger import get_module_logger
|
||||
from .chat_stream import ChatStream
|
||||
from .utils_image import image_manager
|
||||
from ..message.message_base import Seg, UserInfo, BaseMessageInfo, MessageBase
|
||||
|
||||
logger = get_module_logger("chat_message")
|
||||
|
||||
@@ -207,7 +206,7 @@ class MessageProcessBase(Message):
|
||||
# 处理单个消息段
|
||||
return await self._process_single_segment(segment)
|
||||
|
||||
async def _process_single_segment(self, seg: Seg) -> str:
|
||||
async def _process_single_segment(self, seg: Seg) -> Union[str, None]:
|
||||
"""处理单个消息段
|
||||
|
||||
Args:
|
||||
@@ -233,6 +232,7 @@ class MessageProcessBase(Message):
|
||||
elif seg.type == "reply":
|
||||
if self.reply and hasattr(self.reply, "processed_plain_text"):
|
||||
return f"[回复:{self.reply.processed_plain_text}]"
|
||||
return None
|
||||
else:
|
||||
return f"[{seg.type}:{str(seg.data)}]"
|
||||
except Exception as e:
|
||||
|
||||
@@ -2,7 +2,7 @@ import random
|
||||
import time
|
||||
import re
|
||||
from collections import Counter
|
||||
from typing import Dict, List
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import jieba
|
||||
import numpy as np
|
||||
@@ -688,7 +688,7 @@ def count_messages_between(start_time: float, end_time: float, stream_id: str) -
|
||||
return 0, 0
|
||||
|
||||
|
||||
def translate_timestamp_to_human_readable(timestamp: float, mode: str = "normal") -> str:
|
||||
def translate_timestamp_to_human_readable(timestamp: float, mode: str = "normal") -> Optional[str]:
|
||||
"""将时间戳转换为人类可读的时间格式
|
||||
|
||||
Args:
|
||||
@@ -716,6 +716,7 @@ def translate_timestamp_to_human_readable(timestamp: float, mode: str = "normal"
|
||||
return f"{int(diff / 86400)}天前:\n"
|
||||
else:
|
||||
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(timestamp)) + ":\n"
|
||||
return None
|
||||
|
||||
|
||||
def parse_text_timestamps(text: str, mode: str = "normal") -> str:
|
||||
|
||||
Reference in New Issue
Block a user