mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-10-14 05:39:18 +00:00
Compare commits
2 Commits
b6c230cfe1
...
8d678c3980
Author | SHA1 | Date | |
---|---|---|---|
8d678c3980 | |||
600325771a |
@ -191,11 +191,11 @@ async function auth(e, group_id, user_id) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('[crystelf-plugin] 请求手性碳验证API失败..', err);
|
logger.error('[crystelf-plugin] 请求手性碳验证API失败..', err);
|
||||||
e.reply('手性碳api出现异常,已暂时切换至数字验证模式..');
|
e.reply('手性碳api出现异常,已暂时切换至数字验证模式..');
|
||||||
await numberAuth(e);
|
await numberAuth(e, key, groupCfg, user_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await tools.sleep(500);
|
await tools.sleep(500);
|
||||||
await numberAuth(e);
|
await numberAuth(e, key, groupCfg, user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupCfg.timeout > 60) {
|
if (groupCfg.timeout > 60) {
|
||||||
@ -221,9 +221,12 @@ async function auth(e, group_id, user_id) {
|
|||||||
/**
|
/**
|
||||||
* 数字验证逻辑
|
* 数字验证逻辑
|
||||||
* @param e
|
* @param e
|
||||||
|
* @param key
|
||||||
|
* @param groupCfg
|
||||||
|
* @param user_id
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function numberAuth(e) {
|
async function numberAuth(e, key, groupCfg, user_id) {
|
||||||
const a = Math.floor(Math.random() * 100);
|
const a = Math.floor(Math.random() * 100);
|
||||||
const b = Math.floor(Math.random() * 100);
|
const b = Math.floor(Math.random() * 100);
|
||||||
const op = Math.random() > 0.5 ? '+' : '-';
|
const op = Math.random() > 0.5 ? '+' : '-';
|
||||||
|
46
apps/face-reply.js
Normal file
46
apps/face-reply.js
Normal 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 || [];
|
||||||
|
}
|
@ -8,5 +8,6 @@
|
|||||||
"zwa": true,
|
"zwa": true,
|
||||||
"rss": true,
|
"rss": true,
|
||||||
"help": true,
|
"help": true,
|
||||||
"welcome": true
|
"welcome": true,
|
||||||
|
"faceReply": true
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,20 @@ const Message = {
|
|||||||
message_id: message_id,
|
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;
|
export default Message;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user