koishi-plugin-teach
Advanced tools
Comparing version 1.0.0-alpha.53 to 1.0.0-alpha.54
@@ -104,9 +104,9 @@ "use strict"; | ||
特殊语法: | ||
$$:一个普通的 $ 字符 | ||
$0:收到的原文本 | ||
$n:分条发送 | ||
$a:@说话人 | ||
$m:@四季酱 | ||
$s:说话人的名字 | ||
\${}: 指令插值`; | ||
%%:一个普通的 % 字符 | ||
%0:收到的原文本 | ||
%n:分条发送 | ||
%a:@说话人 | ||
%m:@四季酱 | ||
%s:说话人的名字 | ||
%{}: 指令插值`; | ||
exports.name = 'teach'; | ||
@@ -113,0 +113,0 @@ function apply(ctx, config = {}) { |
@@ -13,7 +13,7 @@ "use strict"; | ||
function escapeAnswer(message) { | ||
return message.replace(/&/g, '@@__PLACEHOLDER__@@'); | ||
return message.replace(/%/g, '@@__PLACEHOLDER__@@'); | ||
} | ||
exports.escapeAnswer = escapeAnswer; | ||
function unescapeAnswer(message) { | ||
return message.replace(/@@__PLACEHOLDER__@@/g, '&'); | ||
return message.replace(/@@__PLACEHOLDER__@@/g, '%'); | ||
} | ||
@@ -73,8 +73,8 @@ exports.unescapeAnswer = unescapeAnswer; | ||
state.answer = dialogue.answer | ||
.replace(/&&/g, '@@__PLACEHOLDER__@@') | ||
.replace(/&A/g, koishi_utils_1.CQCode.stringify('at', { qq: 'all' })) | ||
.replace(/&a/g, koishi_utils_1.CQCode.stringify('at', { qq: meta.userId })) | ||
.replace(/&m/g, koishi_utils_1.CQCode.stringify('at', { qq: meta.selfId })) | ||
.replace(/&s/g, escapeAnswer(meta.$username)) | ||
.replace(/&0/g, escapeAnswer(meta.message)); | ||
.replace(/%%/g, '@@__PLACEHOLDER__@@') | ||
.replace(/%A/g, koishi_utils_1.CQCode.stringify('at', { qq: 'all' })) | ||
.replace(/%a/g, koishi_utils_1.CQCode.stringify('at', { qq: meta.userId })) | ||
.replace(/%m/g, koishi_utils_1.CQCode.stringify('at', { qq: meta.selfId })) | ||
.replace(/%s/g, escapeAnswer(meta.$username)) | ||
.replace(/%0/g, escapeAnswer(meta.message)); | ||
if (await ctx.app.serialize(meta, 'dialogue/before-send', state)) | ||
@@ -114,3 +114,3 @@ return; | ||
let index; | ||
while ((index = state.answer.indexOf('&')) >= 0) { | ||
while ((index = state.answer.indexOf('%')) >= 0) { | ||
const char = state.answer[index + 1]; | ||
@@ -182,3 +182,3 @@ if (!'n{123456789'.includes(char)) { | ||
for (const data of dialogues) { | ||
const capture = data.answer.match(/&\{.+?\}/g); | ||
const capture = data.answer.match(/%\{.+?\}/g); | ||
for (const message of capture || []) { | ||
@@ -188,3 +188,3 @@ const argv = ctx.parse(message.slice(2, -1), meta); | ||
} | ||
if (capture || data.answer.includes('&n')) { | ||
if (capture || data.answer.includes('%n')) { | ||
userFields.add('timers'); | ||
@@ -191,0 +191,0 @@ } |
{ | ||
"name": "koishi-plugin-teach", | ||
"description": "Teach plugin for Koishi", | ||
"version": "1.0.0-alpha.53", | ||
"version": "1.0.0-alpha.54", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "typings": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
210945