mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-10-14 13:49:18 +00:00
Compare commits
No commits in common. "8d678c3980896a5f39d613001d459dfc66242663" and "b6c230cfe1bd6adbc77977c2621ccd67b7656ffc" have entirely different histories.
8d678c3980
...
b6c230cfe1
@ -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, key, groupCfg, user_id);
|
||||
await numberAuth(e);
|
||||
}
|
||||
} else {
|
||||
await tools.sleep(500);
|
||||
await numberAuth(e, key, groupCfg, user_id);
|
||||
await numberAuth(e);
|
||||
}
|
||||
|
||||
if (groupCfg.timeout > 60) {
|
||||
@ -221,12 +221,9 @@ async function auth(e, group_id, user_id) {
|
||||
/**
|
||||
* 数字验证逻辑
|
||||
* @param e
|
||||
* @param key
|
||||
* @param groupCfg
|
||||
* @param user_id
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function numberAuth(e, key, groupCfg, user_id) {
|
||||
async function numberAuth(e) {
|
||||
const a = Math.floor(Math.random() * 100);
|
||||
const b = Math.floor(Math.random() * 100);
|
||||
const op = Math.random() > 0.5 ? '+' : '-';
|
||||
|
@ -1,46 +0,0 @@
|
||||
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 || [];
|
||||
}
|
@ -8,6 +8,5 @@
|
||||
"zwa": true,
|
||||
"rss": true,
|
||||
"help": true,
|
||||
"welcome": true,
|
||||
"faceReply": true
|
||||
"welcome": true
|
||||
}
|
||||
|
@ -10,20 +10,5 @@ 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user