message,你等着我口牙
123
This commit is contained in:
@@ -100,3 +100,7 @@
|
|||||||
感谢各位大佬!
|
感谢各位大佬!
|
||||||
|
|
||||||
[](https://github.com/SengokuCola/MaiMBot/graphs/contributors)
|
[](https://github.com/SengokuCola/MaiMBot/graphs/contributors)
|
||||||
|
|
||||||
|
|
||||||
|
## Stargazers over time
|
||||||
|
[](https://starchart.cc/SengokuCola/MaiMBot)
|
||||||
@@ -171,7 +171,6 @@ class ChatBot:
|
|||||||
group_id=event.group_id,
|
group_id=event.group_id,
|
||||||
user_id=global_config.BOT_QQ,
|
user_id=global_config.BOT_QQ,
|
||||||
message_id=think_id,
|
message_id=think_id,
|
||||||
message_based_id=event.message_id,
|
|
||||||
raw_message=msg,
|
raw_message=msg,
|
||||||
plain_text=msg,
|
plain_text=msg,
|
||||||
processed_plain_text=msg,
|
processed_plain_text=msg,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from ...common.database import Database
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
from .config import global_config
|
from .config import global_config
|
||||||
import urllib3
|
import urllib3
|
||||||
from .utils_user import get_user_nickname,get_user_cardname
|
from .utils_user import get_user_nickname,get_user_cardname,get_groupname
|
||||||
from .utils_cq import parse_cq_code
|
from .utils_cq import parse_cq_code
|
||||||
from .cq_code import cq_code_tool,CQCode
|
from .cq_code import cq_code_tool,CQCode
|
||||||
|
|
||||||
@@ -21,50 +21,47 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|||||||
#它还定义了两个辅助属性:keywords用于提取消息的关键词,is_plain_text用于判断消息是否为纯文本。
|
#它还定义了两个辅助属性:keywords用于提取消息的关键词,is_plain_text用于判断消息是否为纯文本。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Message:
|
class Message:
|
||||||
"""消息数据类"""
|
"""消息数据类"""
|
||||||
|
message_id: int = None
|
||||||
|
time: float = None
|
||||||
|
|
||||||
group_id: int = None
|
group_id: int = None
|
||||||
|
group_name: str = None # 群名称
|
||||||
|
|
||||||
user_id: int = None
|
user_id: int = None
|
||||||
user_nickname: str = None # 用户昵称
|
user_nickname: str = None # 用户昵称
|
||||||
user_cardname: str=None # 用户群昵称
|
user_cardname: str=None # 用户群昵称
|
||||||
group_name: str = None # 群名称
|
|
||||||
|
|
||||||
message_id: int = None
|
raw_message: str = None # 原始消息,包含未解析的cq码
|
||||||
raw_message: str = None
|
plain_text: str = None # 纯文本
|
||||||
plain_text: str = None
|
|
||||||
|
|
||||||
message_based_id: int = None
|
|
||||||
reply_message: Dict = None # 存储回复消息
|
|
||||||
|
|
||||||
message_segments: List[Dict] = None # 存储解析后的消息片段
|
message_segments: List[Dict] = None # 存储解析后的消息片段
|
||||||
processed_plain_text: str = None # 用于存储处理后的plain_text
|
processed_plain_text: str = None # 用于存储处理后的plain_text
|
||||||
detailed_plain_text: str = None # 用于存储详细可读文本
|
detailed_plain_text: str = None # 用于存储详细可读文本
|
||||||
|
|
||||||
time: float = None
|
reply_message: Dict = None # 存储 回复的 源消息
|
||||||
|
|
||||||
is_emoji: bool = False # 是否是表情包
|
is_emoji: bool = False # 是否是表情包
|
||||||
has_emoji: bool = False # 是否包含表情包
|
has_emoji: bool = False # 是否包含表情包
|
||||||
|
|
||||||
translate_cq: bool = True # 是否翻译cq码
|
translate_cq: bool = True # 是否翻译cq码
|
||||||
|
|
||||||
|
|
||||||
reply_benefits: float = 0.0
|
|
||||||
|
|
||||||
type: str = 'received' # 消息类型,可以是received或者send
|
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if self.time is None:
|
if self.time is None:
|
||||||
self.time = int(time.time())
|
self.time = int(time.time())
|
||||||
|
|
||||||
|
if not self.group_name:
|
||||||
|
self.group_name = get_groupname(self.group_id)
|
||||||
|
|
||||||
if not self.user_nickname:
|
if not self.user_nickname:
|
||||||
self.user_nickname = get_user_nickname(self.user_id)
|
self.user_nickname = get_user_nickname(self.user_id)
|
||||||
|
|
||||||
if not self.user_cardname:
|
if not self.user_cardname:
|
||||||
self.user_cardname=get_user_cardname(self.user_id)
|
self.user_cardname=get_user_cardname(self.user_id)
|
||||||
|
|
||||||
if not self.group_name:
|
|
||||||
self.group_name = self.get_groupname(self.group_id)
|
|
||||||
|
|
||||||
if not self.processed_plain_text:
|
if not self.processed_plain_text:
|
||||||
if self.raw_message:
|
if self.raw_message:
|
||||||
self.message_segments = self.parse_message_segments(str(self.raw_message))
|
self.message_segments = self.parse_message_segments(str(self.raw_message))
|
||||||
@@ -244,6 +241,38 @@ class MessageSet:
|
|||||||
return len(self.messages)
|
return len(self.messages)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Message_Sending(Message):
|
||||||
|
"""发送消息数据类,继承自Message类"""
|
||||||
|
|
||||||
|
priority: int = 0 # 发送优先级,数字越大优先级越高
|
||||||
|
wait_until: float = None # 等待发送的时间戳
|
||||||
|
continue_thinking: bool = False # 是否继续思考
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
super().__post_init__()
|
||||||
|
if self.wait_until is None:
|
||||||
|
self.wait_until = self.time
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_send(self) -> bool:
|
||||||
|
"""检查是否可以发送消息"""
|
||||||
|
return time.time() >= self.wait_until
|
||||||
|
|
||||||
|
def set_wait_time(self, seconds: float) -> None:
|
||||||
|
"""设置等待发送时间"""
|
||||||
|
self.wait_until = time.time() + seconds
|
||||||
|
|
||||||
|
def set_priority(self, priority: int) -> None:
|
||||||
|
"""设置发送优先级"""
|
||||||
|
self.priority = priority
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
"""重写小于比较,用于优先级排序"""
|
||||||
|
if not isinstance(other, Message_Sending):
|
||||||
|
return NotImplemented
|
||||||
|
return (self.priority, -self.wait_until) < (other.priority, -other.wait_until)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class MessageSendControl:
|
|||||||
print(f"- 群组: {group_id} - 内容: {message.processed_plain_text}")
|
print(f"- 群组: {group_id} - 内容: {message.processed_plain_text}")
|
||||||
cost_time = round(time.time(), 2) - message.time
|
cost_time = round(time.time(), 2) - message.time
|
||||||
if cost_time > 40:
|
if cost_time > 40:
|
||||||
message.processed_plain_text = cq_code_tool.create_reply_cq(message.message_based_id) + message.processed_plain_text
|
message.processed_plain_text = cq_code_tool.create_reply_cq(message.message_id) + message.processed_plain_text
|
||||||
cur_time = time.time()
|
cur_time = time.time()
|
||||||
await self._current_bot.send_group_msg(
|
await self._current_bot.send_group_msg(
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
|
|||||||
0
src/plugins/chat/message_sender.py
Normal file
0
src/plugins/chat/message_sender.py
Normal file
14
src/plugins/chat/thinking_idea.py
Normal file
14
src/plugins/chat/thinking_idea.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#Broca's Area
|
||||||
|
# 功能:语言产生、语法处理和言语运动控制。
|
||||||
|
# 损伤后果:布洛卡失语症(表达困难,但理解保留)。
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
class Thinking_Idea:
|
||||||
|
def __init__(self, message_id: str):
|
||||||
|
self.messages = [] # 消息列表集合
|
||||||
|
self.current_thoughts = [] # 当前思考内容列表
|
||||||
|
self.time = time.time() # 创建时间
|
||||||
|
self.id = str(int(time.time() * 1000)) # 使用时间戳生成唯一标识ID
|
||||||
|
|
||||||
@@ -6,8 +6,12 @@ def get_user_nickname(user_id: int) -> str:
|
|||||||
return global_config.BOT_NICKNAME
|
return global_config.BOT_NICKNAME
|
||||||
# print(user_id)
|
# print(user_id)
|
||||||
return relationship_manager.get_name(user_id)
|
return relationship_manager.get_name(user_id)
|
||||||
|
|
||||||
def get_user_cardname(user_id: int) -> str:
|
def get_user_cardname(user_id: int) -> str:
|
||||||
if int(user_id) == int(global_config.BOT_QQ):
|
if int(user_id) == int(global_config.BOT_QQ):
|
||||||
return global_config.BOT_NICKNAME
|
return global_config.BOT_NICKNAME
|
||||||
# print(user_id)
|
# print(user_id)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def get_groupname(group_id: int) -> str:
|
||||||
|
return f"群{group_id}"
|
||||||
Reference in New Issue
Block a user