|
35 | 35 | from .MsgDeco import qutoed_text |
36 | 36 | from .MsgProcess import MsgProcess, MsgWrapper |
37 | 37 | from .Utils import download_file , load_config , load_temp_file_to_local , WC_EMOTICON_CONVERSION |
38 | | -from .Constant import QUOTE_MESSAGE, QUOTE_GROUP_MESSAGE |
| 38 | +from .Constant import QUOTE_MESSAGE |
39 | 39 |
|
40 | 40 | from rich.console import Console |
41 | 41 | from rich import print as rprint |
@@ -501,7 +501,7 @@ def handle_msg(self , msg : Dict[str, Any] , author : 'ChatMember' , chat : 'Cha |
501 | 501 | self.file_msg[msg["filepath"]] = ( msg , author , chat ) |
502 | 502 | return |
503 | 503 |
|
504 | | - self.send_efb_msgs(MsgWrapper(msg["message"], MsgProcess(msg, chat)), author=author, chat=chat, uid=MessageID(str(msg['msgid']))) |
| 504 | + self.send_efb_msgs(MsgWrapper(msg, MsgProcess(msg, chat)), author=author, chat=chat, uid=MessageID(str(msg['msgid']))) |
505 | 505 |
|
506 | 506 | def handle_file_msg(self): |
507 | 507 | while True: |
@@ -533,7 +533,7 @@ def handle_file_msg(self): |
533 | 533 |
|
534 | 534 | if flag: |
535 | 535 | del self.file_msg[path] |
536 | | - self.send_efb_msgs(MsgWrapper(msg["message"], MsgProcess(msg, chat)), author=author, chat=chat, uid=MessageID(str(msg['msgid']))) |
| 536 | + self.send_efb_msgs(MsgWrapper(msg, MsgProcess(msg, chat)), author=author, chat=chat, uid=MessageID(str(msg['msgid']))) |
537 | 537 |
|
538 | 538 | if len(self.delete_file): |
539 | 539 | for k in list(self.delete_file.keys()): |
@@ -795,15 +795,35 @@ def send_text(self, wxid: ChatID, msg: Message) -> 'Message': |
795 | 795 | msgid = msg.target.uid |
796 | 796 | sender = msg.target.author.uid |
797 | 797 | displayname = msg.target.author.name |
798 | | - content = escape(msg.target.vendor_specific.get("wx_xml", "")) |
| 798 | + content = escape(msg.target.vendor_specific.get("wx_xml", ""), { |
| 799 | + "\n": "
", |
| 800 | + "\t": "	", |
| 801 | + '"': """, |
| 802 | + }) or msg.target.text |
| 803 | + comwechat_info = msg.target.vendor_specific.get("comwechat_info", {}) |
| 804 | + if comwechat_info.get("type", None) == "animatedsticker": |
| 805 | + refer_type = 47 |
| 806 | + elif msg.target.type == MsgType.Image: |
| 807 | + refer_type = 3 |
| 808 | + elif msg.target.type == MsgType.Voice: |
| 809 | + refer_type = 34 |
| 810 | + elif msg.target.type == MsgType.Video: |
| 811 | + refer_type = 43 |
| 812 | + elif msg.target.type == MsgType.Sticker: |
| 813 | + refer_type = 47 |
| 814 | + elif msg.target.type == MsgType.Location: |
| 815 | + refer_type = 48 |
| 816 | + elif msg.target.type == MsgType.File: |
| 817 | + refer_type = 49 |
| 818 | + elif comwechat_info.get("type", None) == "share": |
| 819 | + refer_type = 49 |
| 820 | + else: |
| 821 | + refer_type = 1 |
799 | 822 | if content: |
800 | 823 | content = "<content>%s</content>" % content |
801 | 824 | else: |
802 | 825 | content = "<content />" |
803 | | - if "@chatroom" in msg.author.chat.uid: |
804 | | - xml = QUOTE_GROUP_MESSAGE % (self.wxid, text, msgid, sender, sender, displayname, content) |
805 | | - else: |
806 | | - xml = QUOTE_MESSAGE % (self.wxid, text, msgid, sender, sender, displayname, content) |
| 826 | + xml = QUOTE_MESSAGE % (self.wxid, text_to_send, refer_type, msgid, sender, sender, displayname, content) |
807 | 827 | return self.bot.SendXml(wxid = wxid , xml = xml, img_path = "") |
808 | 828 | return self.bot.SendText(wxid = wxid , msg = text) |
809 | 829 |
|
|
0 commit comments