diff --git a/apps/face-reply.js b/apps/face-reply.js index 793aa7c..31e3187 100644 --- a/apps/face-reply.js +++ b/apps/face-reply.js @@ -1,5 +1,6 @@ import ConfigControl from '../lib/config/configControl.js'; import Message from '../lib/yunzai/message.js'; +import YunzaiUtils from '../lib/yunzai/utils.js'; export class FaceReply extends plugin { constructor() { @@ -28,9 +29,10 @@ export class FaceReply extends plugin { } } }); + const adapter = await YunzaiUtils.getAdapter(e); if (face.length) { for (const f of face) { - await Message.emojiLike(e, e.message_id, String(f.id)); + await Message.emojiLike(e, e.message_id, String(f.id), e.group_id, adapter); } } } diff --git a/lib/yunzai/message.js b/lib/yunzai/message.js index 5b11352..dabbc4e 100644 --- a/lib/yunzai/message.js +++ b/lib/yunzai/message.js @@ -16,14 +16,25 @@ const Message = { * @param e * @param message_id 消息id * @param emoji_id 表情id + * @param group_id 群号 + * @param adapter nc/lgr * @returns {Promise<*>} */ - async emojiLike(e, message_id, emoji_id) { - return await e.bot.sendApi('set_msg_emoji_like', { - message_id: message_id, - emoji_id: emoji_id, - set: true, - }); + async emojiLike(e, message_id, emoji_id, group_id, adapter) { + if (adapter === 'nc') { + return await e.bot.sendApi('set_msg_emoji_like', { + message_id: message_id, + emoji_id: emoji_id, + set: true, + }); + } else if (adapter === 'lgr') { + return await e.bot.sendApi('set_group_reaction', { + group_id: group_id, + message_id: message_id, + code: emoji_id, + is_add: true, + }); + } }, }; export default Message; diff --git a/lib/yunzai/utils.js b/lib/yunzai/utils.js index 04b6e37..bc751e7 100644 --- a/lib/yunzai/utils.js +++ b/lib/yunzai/utils.js @@ -32,4 +32,18 @@ export default class YunzaiUtils { if (!imgUrls.length) imgUrls = [me]; return imgUrls.slice(0, limit); } + + /** + * 看看使用的是哪个适配器 + * @param e + * @returns {Promise<*>} + */ + static async getAdapter(e) { + const adapter = e.bot.sendApi('get_version_info', {})?.data?.app_name; + if (adapter === 'NapCat.Onebot') { + return 'nc'; + } else if (adapter === 'Lagrange.Onebot') { + return 'lgr'; + } else return 'nc'; + } }