细节优化
This commit is contained in:
		
							parent
							
								
									d085cb4d10
								
							
						
					
					
						commit
						e1027169ba
					
				| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
import fs from "node:fs"
 | 
					import fs from "node:fs"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const segment = new class segment {
 | 
					function toSegment(type, data) {
 | 
				
			||||||
  custom(type, data) {
 | 
					 | 
				
			||||||
  for (const i in data) {
 | 
					  for (const i in data) {
 | 
				
			||||||
    switch (typeof data[i]) {
 | 
					    switch (typeof data[i]) {
 | 
				
			||||||
      case "string":
 | 
					      case "string":
 | 
				
			||||||
| 
						 | 
					@ -14,42 +13,47 @@ const segment = new class segment {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return { type, ...data }
 | 
					  return { type, ...data }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const segment = new class segment {
 | 
				
			||||||
 | 
					  custom(type, data) {
 | 
				
			||||||
 | 
					    return toSegment(type, data)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  image(file) {
 | 
					  image(file) {
 | 
				
			||||||
    return this.custom("image", { file })
 | 
					    return toSegment("image", { file })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  at(qq, name) {
 | 
					  at(qq, name) {
 | 
				
			||||||
    return this.custom("at", { qq, name })
 | 
					    return toSegment("at", { qq, name })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  record(file) {
 | 
					  record(file) {
 | 
				
			||||||
    return this.custom("record", { file })
 | 
					    return toSegment("record", { file })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  video(file) {
 | 
					  video(file) {
 | 
				
			||||||
    return this.custom("video", { file })
 | 
					    return toSegment("video", { file })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  reply(id, text, qq, time, seq) {
 | 
					  reply(id, text, qq, time, seq) {
 | 
				
			||||||
    return this.custom("reply", { id, text, qq, time, seq })
 | 
					    return toSegment("reply", { id, text, qq, time, seq })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  face(id) {
 | 
					  face(id) {
 | 
				
			||||||
    return this.custom("face", { id })
 | 
					    return toSegment("face", { id })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  share(url, title, content, image) {
 | 
					  share(url, title, content, image) {
 | 
				
			||||||
    return this.custom("share", { url, title, content, image })
 | 
					    return toSegment("share", { url, title, content, image })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  music(type, id, url, audio, title) {
 | 
					  music(type, id, url, audio, title) {
 | 
				
			||||||
    return this.custom("music", { type, id, url, audio, title })
 | 
					    return toSegment("music", { type, id, url, audio, title })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  poke(qq) {
 | 
					  poke(qq) {
 | 
				
			||||||
    return this.custom("poke", { qq })
 | 
					    return toSegment("poke", { qq })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  gift(qq, id) {
 | 
					  gift(qq, id) {
 | 
				
			||||||
    return this.custom("gift", { qq, id })
 | 
					    return toSegment("gift", { qq, id })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  cardimage(file, minwidth, minheight, maxwidth, maxheight, source, icon) {
 | 
					  cardimage(file, minwidth, minheight, maxwidth, maxheight, source, icon) {
 | 
				
			||||||
    return this.custom("cardimage", { file, minwidth, minheight, maxwidth, maxheight, source, icon })
 | 
					    return toSegment("cardimage", { file, minwidth, minheight, maxwidth, maxheight, source, icon })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  tts(text) {
 | 
					  tts(text) {
 | 
				
			||||||
    return this.custom("tts", { text })
 | 
					    return toSegment("tts", { text })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,7 @@
 | 
				
			||||||
    "chokidar": "^3.5.3",
 | 
					    "chokidar": "^3.5.3",
 | 
				
			||||||
    "express": "^4.18.2",
 | 
					    "express": "^4.18.2",
 | 
				
			||||||
    "file-type": "^18.5.0",
 | 
					    "file-type": "^18.5.0",
 | 
				
			||||||
    "https-proxy-agent": "7.0.0",
 | 
					    "https-proxy-agent": "7.0.1",
 | 
				
			||||||
    "image-size": "^1.0.2",
 | 
					    "image-size": "^1.0.2",
 | 
				
			||||||
    "lodash": "^4.17.21",
 | 
					    "lodash": "^4.17.21",
 | 
				
			||||||
    "log4js": "^6.9.1",
 | 
					    "log4js": "^6.9.1",
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@
 | 
				
			||||||
    "node-xlsx": "^0.23.0",
 | 
					    "node-xlsx": "^0.23.0",
 | 
				
			||||||
    "oicq": "link:lib/modules/oicq",
 | 
					    "oicq": "link:lib/modules/oicq",
 | 
				
			||||||
    "pm2": "^5.3.0",
 | 
					    "pm2": "^5.3.0",
 | 
				
			||||||
    "puppeteer": "^20.8.0",
 | 
					    "puppeteer": "^20.8.2",
 | 
				
			||||||
    "redis": "^4.6.7",
 | 
					    "redis": "^4.6.7",
 | 
				
			||||||
    "sequelize": "^6.32.1",
 | 
					    "sequelize": "^6.32.1",
 | 
				
			||||||
    "sqlite3": "^5.1.6",
 | 
					    "sqlite3": "^5.1.6",
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,7 @@
 | 
				
			||||||
    "yaml": "^2.3.1"
 | 
					    "yaml": "^2.3.1"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "eslint": "^8.44.0",
 | 
					    "eslint": "^8.45.0",
 | 
				
			||||||
    "eslint-config-standard": "^17.1.0",
 | 
					    "eslint-config-standard": "^17.1.0",
 | 
				
			||||||
    "eslint-plugin-import": "^2.27.5",
 | 
					    "eslint-plugin-import": "^2.27.5",
 | 
				
			||||||
    "eslint-plugin-n": "^16.0.1",
 | 
					    "eslint-plugin-n": "^16.0.1",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue