helper.js 933 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. function default_1(message) {
  4. var _a, _b;
  5. message = message.trim();
  6. message = message.replace('\\\\', '\\0x5c');
  7. message = message.replace('\\\"', '\\0x22');
  8. message = message.replace('\\\'', '\\0x27');
  9. const strs = message.match(/'[\s\S]*?'|"[\s\S]*?"|\S*\[CQ:[\s\S]*?\]\S*|\S+/mg);
  10. const cmd = ((_a = strs) === null || _a === void 0 ? void 0 : _a.length) ? strs[0].length ? strs[0].substring(0, 1) === '/' ? strs[0].substring(1) : '' : '' : '';
  11. const args = (_b = strs) === null || _b === void 0 ? void 0 : _b.slice(1).map(arg => {
  12. arg = arg.replace(/^["']+|["']+$/g, '');
  13. arg = arg.replace('\\0x27', '\\\'');
  14. arg = arg.replace('\\0x22', '\\\"');
  15. arg = arg.replace('\\0x5c', '\\\\');
  16. return arg;
  17. });
  18. return {
  19. cmd,
  20. args,
  21. };
  22. }
  23. exports.default = default_1;