12345678910111213141516171819202122232425262728293031323334353637383940 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.view = exports.parseCmd = void 0;
- const koishi_1 = require("./koishi");
- function parseCmd(message) {
- message = message.trim();
- message = message.replace('\\\\', '\\0x5c');
- message = message.replace('\\\"', '\\0x22');
- message = message.replace('\\\'', '\\0x27');
- const strs = message.match(/'[\s\S]*?'|(?:\S+=)?"[\s\S]*?"|\S+/mg);
- const cmd = (strs === null || strs === void 0 ? void 0 : strs.length) ? strs[0].length ? strs[0].substring(0, 1) === '/' ? strs[0].substring(1) : '' : '' : '';
- const args = (strs !== null && strs !== void 0 ? strs : []).slice(1).map(arg => {
- arg = arg.replace(/^(\S+=)?["']+(?!.*=)|["']+$/g, '$1');
- arg = arg.replace('\\0x27', '\\\'');
- arg = arg.replace('\\0x22', '\\\"');
- arg = arg.replace('\\0x5c', '\\\\');
- return arg;
- });
- return {
- cmd,
- args,
- };
- }
- exports.parseCmd = parseCmd;
- function view(chat, args, reply) {
- if (args.length === 0) {
- return reply('找不到要查看的回数。');
- }
- const match = Number(args[0]);
- if (match < 1 || match > 999) {
- return reply('链接格式有误。');
- }
- try {
- reply(koishi_1.Message.Image(`https://d2n19nac4w0gh6.cloudfront.net/resource/images/webview/comic/story/comic_${String(match).padStart(3, '0')}.jpg`));
- }
- catch (e) {
- reply('机器人尚未加载完毕,请稍后重试。');
- }
- }
- exports.view = view;
|