fix message
This commit is contained in:
@ -437,12 +437,13 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
:param medias: 媒体列表
|
:param medias: 媒体列表
|
||||||
:return: 成功或失败
|
:return: 成功或失败
|
||||||
"""
|
"""
|
||||||
self.messagehelper.put(message, role="user")
|
note_list = [media.to_dict() for media in medias]
|
||||||
|
self.messagehelper.put(message, role="user", note=note_list)
|
||||||
self.messageoper.add(channel=message.channel, mtype=message.mtype,
|
self.messageoper.add(channel=message.channel, mtype=message.mtype,
|
||||||
title=message.title, text=message.text,
|
title=message.title, text=message.text,
|
||||||
image=message.image, link=message.link,
|
image=message.image, link=message.link,
|
||||||
userid=message.userid, action=1,
|
userid=message.userid, action=1,
|
||||||
note=[media.to_dict() for media in medias])
|
note=note_list)
|
||||||
return self.run_module("post_medias_message", message=message, medias=medias)
|
return self.run_module("post_medias_message", message=message, medias=medias)
|
||||||
|
|
||||||
def post_torrents_message(self, message: Notification, torrents: List[Context]) -> Optional[bool]:
|
def post_torrents_message(self, message: Notification, torrents: List[Context]) -> Optional[bool]:
|
||||||
@ -452,12 +453,13 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
:param torrents: 种子列表
|
:param torrents: 种子列表
|
||||||
:return: 成功或失败
|
:return: 成功或失败
|
||||||
"""
|
"""
|
||||||
self.messagehelper.put(message, role="user")
|
note_list = [torrent.torrent_info.to_dict() for torrent in torrents]
|
||||||
|
self.messagehelper.put(message, role="user", note=note_list)
|
||||||
self.messageoper.add(channel=message.channel, mtype=message.mtype,
|
self.messageoper.add(channel=message.channel, mtype=message.mtype,
|
||||||
title=message.title, text=message.text,
|
title=message.title, text=message.text,
|
||||||
image=message.image, link=message.link,
|
image=message.image, link=message.link,
|
||||||
userid=message.userid, action=1,
|
userid=message.userid, action=1,
|
||||||
note=[torrent.to_dict() for torrent in torrents])
|
note=note_list)
|
||||||
return self.run_module("post_torrents_message", message=message, torrents=torrents)
|
return self.run_module("post_torrents_message", message=message, torrents=torrents)
|
||||||
|
|
||||||
def scrape_metadata(self, path: Path, mediainfo: MediaInfo, transfer_type: str,
|
def scrape_metadata(self, path: Path, mediainfo: MediaInfo, transfer_type: str,
|
||||||
|
@ -615,6 +615,7 @@ class MediaInfo:
|
|||||||
"""
|
"""
|
||||||
返回字典
|
返回字典
|
||||||
"""
|
"""
|
||||||
|
self.clear()
|
||||||
dicts = asdict(self)
|
dicts = asdict(self)
|
||||||
dicts["type"] = self.type.value if self.type else None
|
dicts["type"] = self.type.value if self.type else None
|
||||||
dicts["detail_link"] = self.detail_link
|
dicts["detail_link"] = self.detail_link
|
||||||
|
@ -50,7 +50,7 @@ class MessageOper(DbOper):
|
|||||||
"userid": userid,
|
"userid": userid,
|
||||||
"action": action,
|
"action": action,
|
||||||
"reg_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
|
"reg_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
|
||||||
"note": json.dumps(note or {})
|
"note": json.dumps(note) if note else ''
|
||||||
})
|
})
|
||||||
Message(**kwargs).create(self._db)
|
Message(**kwargs).create(self._db)
|
||||||
|
|
||||||
|
@ -14,11 +14,12 @@ class MessageHelper(metaclass=Singleton):
|
|||||||
self.sys_queue = queue.Queue()
|
self.sys_queue = queue.Queue()
|
||||||
self.user_queue = queue.Queue()
|
self.user_queue = queue.Queue()
|
||||||
|
|
||||||
def put(self, message: Any, role: str = "sys"):
|
def put(self, message: Any, role: str = "sys", note: dict = None):
|
||||||
"""
|
"""
|
||||||
存消息
|
存消息
|
||||||
:param message: 消息
|
:param message: 消息
|
||||||
:param role: 消息通道 sys/user
|
:param role: 消息通道 sys/user
|
||||||
|
:param note: 附件json
|
||||||
"""
|
"""
|
||||||
if role == "sys":
|
if role == "sys":
|
||||||
self.sys_queue.put(message)
|
self.sys_queue.put(message)
|
||||||
@ -28,6 +29,7 @@ class MessageHelper(metaclass=Singleton):
|
|||||||
elif hasattr(message, "to_dict"):
|
elif hasattr(message, "to_dict"):
|
||||||
content = message.to_dict()
|
content = message.to_dict()
|
||||||
content['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
content['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||||
|
content['note'] = json.dumps(note) if note else None
|
||||||
self.user_queue.put(json.dumps(content))
|
self.user_queue.put(json.dumps(content))
|
||||||
|
|
||||||
def get(self, role: str = "sys") -> Optional[str]:
|
def get(self, role: str = "sys") -> Optional[str]:
|
||||||
|
Reference in New Issue
Block a user