1111
1212from .webchat_queue_mgr import webchat_queue_mgr
1313
14- imgs_dir = os .path .join (get_astrbot_data_path (), "webchat" , "imgs " )
14+ attachments_dir = os .path .join (get_astrbot_data_path (), "attachments " )
1515
1616
1717class WebChatMessageEvent (AstrMessageEvent ):
1818 def __init__ (self , message_str , message_obj , platform_meta , session_id ) -> None :
1919 super ().__init__ (message_str , message_obj , platform_meta , session_id )
20- os .makedirs (imgs_dir , exist_ok = True )
20+ os .makedirs (attachments_dir , exist_ok = True )
2121
2222 @staticmethod
2323 async def _send (
@@ -69,7 +69,7 @@ async def _send(
6969 elif isinstance (comp , Image ):
7070 # save image to local
7171 filename = f"{ str (uuid .uuid4 ())} .jpg"
72- path = os .path .join (imgs_dir , filename )
72+ path = os .path .join (attachments_dir , filename )
7373 image_base64 = await comp .convert_to_base64 ()
7474 with open (path , "wb" ) as f :
7575 f .write (base64 .b64decode (image_base64 ))
@@ -85,7 +85,7 @@ async def _send(
8585 elif isinstance (comp , Record ):
8686 # save record to local
8787 filename = f"{ str (uuid .uuid4 ())} .wav"
88- path = os .path .join (imgs_dir , filename )
88+ path = os .path .join (attachments_dir , filename )
8989 record_base64 = await comp .convert_to_base64 ()
9090 with open (path , "wb" ) as f :
9191 f .write (base64 .b64decode (record_base64 ))
@@ -104,7 +104,7 @@ async def _send(
104104 original_name = comp .name or os .path .basename (file_path )
105105 ext = os .path .splitext (original_name )[1 ] or ""
106106 filename = f"{ uuid .uuid4 ()!s} { ext } "
107- dest_path = os .path .join (imgs_dir , filename )
107+ dest_path = os .path .join (attachments_dir , filename )
108108 shutil .copy2 (file_path , dest_path )
109109 data = f"[FILE]{ filename } "
110110 await web_chat_back_queue .put (
0 commit comments