回复、发送图片/表情包操作短暂计时

pull/634/head
Bakadax 2025-04-02 11:10:08 +08:00
parent adc94900d8
commit b499847ef2
1 changed files with 6 additions and 4 deletions

View File

@ -360,9 +360,12 @@ def calculate_typing_time(input_string: str, chinese_time: float = 0.2, english_
- 如果只有一个中文字符将使用3倍的中文输入时间
- 在所有输入结束后额外加上回车时间0.3
"""
# 回复、发送图片/表情包操作不计时
# 回复、发送图片/表情包操作短暂计时
total_time = 0.0
pattern = re.compile(r'\[[回复 ,表情包:,图片:][\s\S]*?\]')
input_string = re.sub(pattern, '', input_string)
if re.match(pattern, input_string):
input_string = re.sub(pattern, '', input_string)
total_time += random.randrange(1, 3, 0.1)
mood_manager = MoodManager.get_instance()
# 将0-1的唤醒度映射到-1到1
@ -379,9 +382,8 @@ def calculate_typing_time(input_string: str, chinese_time: float = 0.2, english_
return chinese_time * 3 + 0.3 # 加上回车时间
# 正常计算所有字符的输入时间
total_time = 0.0
for char in input_string:
if "\u4e00" <= char <= "\u9fff": # 判断是否为中文字符
if not is_western_char(char): # 判断是否为中文字符
total_time += chinese_time
else: # 其他字符(如英文)
total_time += english_time