Compare commits

..

2 Commits

Author SHA1 Message Date
8d678c3980 fix:修复形参缺少问题 2025-10-06 18:51:46 +08:00
600325771a fix:添加表情回应功能 2025-10-06 18:10:51 +08:00
4 changed files with 69 additions and 4 deletions

View File

@ -191,11 +191,11 @@ async function auth(e, group_id, user_id) {
} catch (err) {
logger.error('[crystelf-plugin] 请求手性碳验证API失败..', err);
e.reply('手性碳api出现异常,已暂时切换至数字验证模式..');
await numberAuth(e);
await numberAuth(e, key, groupCfg, user_id);
}
} else {
await tools.sleep(500);
await numberAuth(e);
await numberAuth(e, key, groupCfg, user_id);
}
if (groupCfg.timeout > 60) {
@ -221,9 +221,12 @@ async function auth(e, group_id, user_id) {
/**
* 数字验证逻辑
* @param e
* @param key
* @param groupCfg
* @param user_id
* @returns {Promise<void>}
*/
async function numberAuth(e) {
async function numberAuth(e, key, groupCfg, user_id) {
const a = Math.floor(Math.random() * 100);
const b = Math.floor(Math.random() * 100);
const op = Math.random() > 0.5 ? '+' : '-';

46
apps/face-reply.js Normal file
View File

@ -0,0 +1,46 @@
import ConfigControl from '../lib/config/configControl.js';
import Message from '../lib/yunzai/message.js';
export class FaceReply extends plugin {
constructor() {
super({
name: 'face-reply',
dsc: '给消息中的表情贴上回应',
event: 'message.group',
priority: -114,
});
}
async accept(e) {
if (!ConfigControl.get('config')?.faceReply) return;
if (!e.message_id || e.message.length === 0) return;
let face = [];
e.message.forEach((m) => {
if (m.type === 'face') {
face.push({ id: m.id });
} else if (m.type === 'text') {
let emojiList = exEmojis(m.text);
if (emojiList.length) {
for (const emoji of emojiList) {
const id = emoji.codePointAt(0);
face.push({ id: id });
}
}
}
});
if (face.length) {
for (const f of face) {
await Message.emojiLike(e, e.message_id, String(f.id));
}
}
}
}
//从消息中提取emoji
function exEmojis(text) {
//没错,爆红了
const emojiRegex =
/(?:\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?)*|\p{Emoji_Presentation}|\p{Emoji}\uFE0F)/gu;
const emojis = text.match(emojiRegex);
return emojis || [];
}

View File

@ -8,5 +8,6 @@
"zwa": true,
"rss": true,
"help": true,
"welcome": true
"welcome": true,
"faceReply": true
}

View File

@ -10,5 +10,20 @@ const Message = {
message_id: message_id,
});
},
/**
* 群表情回应
* @param e
* @param message_id 消息id
* @param emoji_id 表情id
* @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,
});
},
};
export default Message;