diff --git a/admin/dashboard/templates/wx_logs.html b/admin/dashboard/templates/wx_logs.html index 0c0f718..ac06902 100644 --- a/admin/dashboard/templates/wx_logs.html +++ b/admin/dashboard/templates/wx_logs.html @@ -77,7 +77,7 @@ } .log-content { - max-height: 600px; + max-height: 700px; overflow-y: auto; background-color: #f5f5f5; padding: 10px; diff --git a/message_util.py b/message_util.py index 17e5142..c9ac776 100644 --- a/message_util.py +++ b/message_util.py @@ -60,6 +60,35 @@ class MessageUtil: self.LOG.info(f"Sending file to {receiver}: {file_path}") self.wcf.send_file(file_path, receiver) + def send_rich_text(self, name: str, account: str, title: str, digest: str, url: str, thumburl: str, receiver: str) -> int: + """ + 发送富文本消息 + + 卡片样式: + |-------------------------------------| + |title, 最长两行 | + |(长标题, 标题短的话这行没有) | + |digest, 最多三行,会占位 |--------| + |digest, 最多三行,会占位 |thumburl| + |digest, 最多三行,会占位 |--------| + |(account logo) name | + |-------------------------------------| + + :param name: 左下显示的名字 + :param account: 填公众号 id 可以显示对应的头像(gh_ 开头的) + :param title: 标题,最多两行 + :param digest: 摘要,三行 + :param url: 点击后跳转的链接 + :param thumburl: 缩略图的链接 + :param receiver: 接收人, wxid 或者 roomid + :return: 0 为成功,其他失败 + """ + # 风控处理,随机延迟发送,解决群消息高频发送导致的微信风险 + time.sleep(random.uniform(0.5, 1.5)) + + self.LOG.info(f"Sending rich text to {receiver}: {title}") + return self.wcf.send_rich_text(name, account, title, digest, url, thumburl, receiver) + def update_contacts(self, contacts: dict) -> None: """ 更新联系人字典 diff --git a/plugins/group_member_change/main.py b/plugins/group_member_change/main.py index f2bc826..a51fe0a 100644 --- a/plugins/group_member_change/main.py +++ b/plugins/group_member_change/main.py @@ -208,12 +208,15 @@ class GroupMemberChangePlugin(MessagePluginInterface): """发送成员入群通知""" now_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') - message = f"""【入群欢迎】 + message = f""" 欢迎新成员: {nickname} -入群时间: {now_time} +⌚️: {now_time} """ - # 使用message_util发送消息 - self.message_util.send_text_msg(message, group_id) + # 使用message_util发送消息 编写一个 send_rich_text 方法 + self.message_util.send_rich_text("bot", "gh_bot", f"欢迎 {nickname} 加入群聊", message, + "https://hot.imsyy.top/#/", + "https://github.com/bovine-liu/liu_icon/blob/main/icon/a-bot.jpg", + group_id) self.LOG.info(f"已发送入群通知: {nickname} 加入群 {group_id}") @property