This commit is contained in:
mol
2023-07-31 14:04:50 +08:00
parent 9b8dafefb1
commit 7f1fa85dbb
4 changed files with 28 additions and 23 deletions

View File

@ -23,8 +23,8 @@ module.exports = function sendForwardMessage(bot, data) {
if (imgUrls) {
Array.isArray(imgUrls)
? imgUrls
.slice(0, process.env.IMG_NUMBER_IN_ONE_MESSAGE || 1)
.forEach((url) => msgContent.addImageUrl(url))
.slice(0, process.env.IMG_NUMBER_IN_ONE_MESSAGE || 1)
.forEach((url) => msgContent.addImageUrl(url))
: msgContent.addImageUrl(imgUrls);
}
// 添加来源地址
@ -34,7 +34,7 @@ module.exports = function sendForwardMessage(bot, data) {
forwardMsgContent.addForwardNode({
senderId: process.env.QQ,
time: 0,
senderName: process.env.FORWARD_SENDER_NAME || '莉娜·模儿',
senderName: from || process.env.FORWARD_SENDER_NAME || '莉娜·模儿',
messageChain: msgContent,
});
}
@ -42,23 +42,23 @@ module.exports = function sendForwardMessage(bot, data) {
Array.isArray(groups) &&
groups.forEach((groupId) => {
// 添加消息来源
if (from) {
bot.sendMessageToGroup(
groupId,
new Message().addText(`${from}更新啦!快来看吧。`),
);
}
// if (from) {
// bot.sendMessageToGroup(
// groupId,
// new Message().addText(`${from}更新啦!快来看吧。`),
// );
// }
bot.sendMessageToGroup(groupId, forwardMsgContent);
});
Array.isArray(users) &&
users.forEach((qq) => {
// 添加消息来源
if (from) {
bot.sendMessageToFriend(
qq,
new Message().addText(`${from}更新啦!快来看吧。`),
);
}
// if (from) {
// bot.sendMessageToFriend(
// qq,
// new Message().addText(`${from}更新啦!快来看吧。`),
// );
// }
bot.sendMessageToFriend(qq, forwardMsgContent);
});
};

View File

@ -5,7 +5,7 @@ module.exports = function sendMessage2(bot, data) {
logger('开始执行handler: sendMessage2');
const { from, messages, imgUrls, subs, originUrl, at } = data;
const subscriptions = subs || defaultSubs;
const { groups, users } = subscriptions;
let { groups, users } = subscriptions;
const msgContent = new Message();
// 添加@信息
if (at) {
@ -29,8 +29,8 @@ module.exports = function sendMessage2(bot, data) {
if (imgUrls) {
Array.isArray(imgUrls)
? imgUrls
.slice(0, process.env.IMG_NUMBER_IN_ONE_MESSAGE || 1)
.forEach((url) => msgContent.addImageUrl(url))
.slice(0, process.env.IMG_NUMBER_IN_ONE_MESSAGE || 1)
.forEach((url) => msgContent.addImageUrl(url))
: msgContent.addImageUrl(imgUrls);
}
// 添加来源地址
@ -38,10 +38,15 @@ module.exports = function sendMessage2(bot, data) {
msgContent.addText(`点击查看详情:${originUrl}`);
}
groups = groups ? groups.split(',') : []
logger(groups)
Array.isArray(groups) &&
groups.forEach((groupId) => {
bot.sendMessageToGroup(groupId, msgContent);
});
users = users ? users.split(',') : []
logger(users)
Array.isArray(users) &&
users.forEach((qq) => {
bot.sendMessageToFriend(qq, msgContent);