diff --git a/apps/poke.js b/apps/poke.js index bd832e1..cd57a79 100644 --- a/apps/poke.js +++ b/apps/poke.js @@ -3,10 +3,7 @@ import tool from '../components/tool.js'; import axios from 'axios'; import configControl from '../lib/config/configControl.js'; -const replyText = configControl.get('poke')?.replyText; -const replyVoice = configControl.get('poke')?.replyVoice; -const mutePick = configControl.get('poke')?.mutePick; -const muteTime = configControl.get('poke')?.muteTime; +const replyPoke = configControl.get('poke')?.replyPoke; export default class ChuochuoPlugin extends plugin { constructor() { @@ -61,113 +58,24 @@ async function masterPoke(e) { } async function handleBotPoke(e) { - const randomNum = Math.random(); - - if (randomNum < replyText) { - try { - const coreUrl = configControl.get(`coreConfig`)?.coreUrl; - const targetUrl = `${coreUrl}/api/words/getText`; - const res = await axios.post(targetUrl, { - type: 'poke', - id: 'poke', - }); - if (res.data.success) { - return await e.reply(res.data.data); - } else { - return await e.reply(`戳一戳出错了!${configControl.get('nickName')}不知道该说啥好了..`); - } - } catch (err) { - logger.error('戳一戳请求失败', err); - return await e.reply(`戳一戳出错了!${configControl.get('nickName')}不知道该说啥好了..`); - } - } - - if (randomNum < replyText + replyVoice) { - try { - const coreUrl = configControl.get(`coreConfig`)?.coreUrl; - const targetUrl = `${coreUrl}/api/words/getText`; - const res = await axios.post(targetUrl, { - type: 'poke', - id: 'poke', - }); - if (res.data.success) { - const message = res.data.data.toString(); - //let message = cleanText(res.data.data.toString()); - //logger.info(message); - return await e.bot.sendApi('get_ai_record', { - group_id: e.group_id, - character: 'lucy-voice-hoige', - text: message, - }); - } - } catch (err) { - logger.error('语音生成失败', err); - return await e.reply(`戳一戳出错了!${configControl.get('nickName')}不知道该说啥好了..`); - } - } - - if (randomNum < replyText + replyVoice + mutePick) { - let mutetype = Math.ceil(Math.random() * 4); - - const botInfo = await Bot.pickMember(e.group_id, e.bot.uin).getInfo(); - const isAdmin = botInfo.role === 'admin' || botInfo.role === 'owner'; - if (!isAdmin) mutetype = 5; - - switch (mutetype) { - case 1: - await e.reply('我生气了!砸挖撸多!木大!木大木大!'); - await tool.sleep(1000); - return await tryMute(e, 60 * muteTime); - case 2: - await e.reply('不!!'); - await tool.sleep(1000); - await e.reply('准!!'); - await tool.sleep(1000); - await e.reply('戳!!'); - await tool.sleep(1000); - await tryMute(e, 60 * muteTime); - await tool.sleep(1000); - return await e.reply('!!'); - case 3: - await e.reply('吃我10068拳!'); - await tool.sleep(1000); - await e.bot.sendApi('group_poke', { group_id: e.group_id, user_id: e.operator_id }); - await tryMute(e, 60 * muteTime); - return; - case 4: - await e.reply('哼,我可是会还手的哦——'); - await tool.sleep(1000); - await e.bot.sendApi('group_poke', { group_id: e.group_id, user_id: e.operator_id }); - return await tryMute(e, 60 * muteTime); - case 5: - await e.reply('哼,唔啊啊啊啊啊啊!'); - await tool.sleep(1000); - return await e.bot.sendApi('group_poke', { group_id: e.group_id, user_id: e.operator_id }); - } - } - - const returnType = Math.round(Math.random() * 3); - const replies = [ - '吃我一拳喵!', - '你刚刚是不是戳我了,你是坏蛋!我要戳回去,哼!!!', - '是不是要本萝莉揍你一顿才开心啊!!!', - ]; - if (replies[returnType]) { - await e.reply(replies[returnType]); - await tool.sleep(1000); - return await e.bot.sendApi('group_poke', { group_id: e.group_id, user_id: e.operator_id }); - } -} - -function cleanText(inputText) { - return inputText.replace(/[^\w\s,.!?]/g, ''); -} - -async function tryMute(e, duration) { try { - await e.group.muteMember(e.operator_id, duration); + const coreUrl = configControl.get(`coreConfig`)?.coreUrl; + const targetUrl = `${coreUrl}/api/words/getText`; + const res = await axios.post(targetUrl, { + type: 'poke', + id: 'poke', + }); + if (res.data.success) { + await e.reply(res.data.data); + if (Math.random() < replyPoke) { + await tool.sleep(1000); + await e.bot.sendApi('group_poke', { group_id: e.group_id, user_id: e.operator_id }); + } + } else { + await e.reply(`戳一戳出错了!${configControl.get('nickName')}不知道该说啥好了..`); + } } catch (err) { - logger.warn(`禁言失败: ${err}`); - await e.reply('气死我了!禁言不了你'); + logger.error('戳一戳请求失败', err); + await e.reply(`戳一戳出错了!${configControl.get('nickName')}不知道该说啥好了..`); } } diff --git a/apps/zwa.js b/apps/zwa.js index 2a90b1c..ca1d028 100644 --- a/apps/zwa.js +++ b/apps/zwa.js @@ -39,18 +39,10 @@ export class ZWA extends plugin { reg: '^(#|/)?早$|^(#|/)?早安$|^(#|/)?起床(了)$|^(#|/)?早上好$|^(#|/)?早上好!$|^(#|/)?早!$|^(#|/)?早啊$', fnc: 'zzz', }, - { - reg: '^ccc$', - fnc: 'test', - }, ], }); } - async test(e) { - logger.info(configControl.get()); - } - async www(e) { const currentHour = getCurrentHour(); if (currentHour >= 20 && currentHour <= 23) { diff --git a/config/poke.json b/config/poke.json index 26839d7..0cdbafc 100644 --- a/config/poke.json +++ b/config/poke.json @@ -1,6 +1,3 @@ { - "replyText": 0.4, - "replyVoice": 0.2, - "mutePick": 0.1, - "muteTime": 2 + "replyPoke": 0.4 } diff --git a/index.js b/index.js index 96eeb06..bf5cf4b 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ import { crystelfInit } from './lib/system/init.js'; import updater from './lib/system/updater.js'; logger.info( - chalk.rgb(134, 142, 204)(`crystelf-plugin ${Version.ver} 初始化 ~ by ${Version.author}`) + chalk.rgb(134, 142, 204)(`crystelf-plugin ${Version.ver} 初始化~ by ${Version.author}`) ); updater.checkAndUpdate().catch((err) => {