Skip to content

Commit

Permalink
🔥 fix: lastIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Lain. committed Apr 22, 2024
1 parent fcf45e4 commit 043bca1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 252 deletions.
2 changes: 2 additions & 0 deletions lib/event/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Message extends Event {

/** 正则匹配 */
for (const v of app.rule) {
/** 这里的lastIndex是为了防止正则无法从头开始匹配 */
v.reg.lastIndex = 0
if (v.reg.test(e.msg)) {
/** 检查白名单插件 */
if (!other.white_list_app(e, app)) continue
Expand Down
238 changes: 0 additions & 238 deletions lib/event/type.d.ts

This file was deleted.

2 changes: 2 additions & 0 deletions lib/plugins/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Button {
const button = []
for (let app of this.Apps) {
for (let v of app.rule) {
/** 这里的lastIndex是为了防止正则无法从头开始匹配 */
v.reg.lastIndex = 0
if (v.reg.test(e.msg)) {
try {
const App = new app.App()
Expand Down
16 changes: 2 additions & 14 deletions lib/utils/YamlEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,8 @@ export default class YamlEditor {
* @returns {any}
*/
get (path) {
try {
const keys = path.split('.')
let current = this.document.contents
for (const key of keys) {
if (!current.has(key)) {
logger.info(`[YamlEditor] 未找到指定的路径:${path}`)
return undefined
}
current = current.get(key)
}
return current
} catch (error) {
logger.error(`[YamlEditor] 获取数据时出错:${error}`)
}
const current = this.navPath(path)
if (!current) return false
}

/**
Expand Down

0 comments on commit 043bca1

Please sign in to comment.