helper.js 911 B

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