dfghfhgfg commited on
Commit
3d7d4c6
·
verified ·
1 Parent(s): 5fa3fe0

Upload 75 files

Browse files
Yunzai/lib/bot.js CHANGED
@@ -430,7 +430,8 @@ export default class Yunzai extends EventEmitter {
430
  times = cfg.bot.file_to_url_times,
431
  } = opts
432
 
433
- file = await this.fileType({ file, name }, { http: true })
 
434
  if (!Buffer.isBuffer(file.buffer)) return file.buffer
435
  file.name = file.name ? encodeURIComponent(file.name) : ulid()
436
 
@@ -719,7 +720,7 @@ export default class Yunzai extends EventEmitter {
719
 
720
  async sendForwardMsg(send, msg) {
721
  const messages = []
722
- for (const { message } of msg)
723
  messages.push(await send(message))
724
  return messages
725
  }
 
430
  times = cfg.bot.file_to_url_times,
431
  } = opts
432
 
433
+ file = (typeof file === "object" && !Buffer.isBuffer(file) && { ...file }) ||
434
+ await this.fileType({ file, name }, { http: true })
435
  if (!Buffer.isBuffer(file.buffer)) return file.buffer
436
  file.name = file.name ? encodeURIComponent(file.name) : ulid()
437
 
 
720
 
721
  async sendForwardMsg(send, msg) {
722
  const messages = []
723
+ for (const { message } of Array.isArray(msg) ? msg : [msg])
724
  messages.push(await send(message))
725
  return messages
726
  }
Yunzai/lib/common/common.js CHANGED
@@ -49,7 +49,7 @@ function makeForwardMsg(e, msg = [], dec) {
49
  const forwardMsg = []
50
  if (dec)
51
  forwardMsg.push({ message: dec })
52
- for (const message of msg)
53
  forwardMsg.push({ message })
54
 
55
  if (e?.group?.makeForwardMsg)
 
49
  const forwardMsg = []
50
  if (dec)
51
  forwardMsg.push({ message: dec })
52
+ for (const message of Array.isArray(msg) ? msg : [msg])
53
  forwardMsg.push({ message })
54
 
55
  if (e?.group?.makeForwardMsg)
Yunzai/lib/plugins/loader.js CHANGED
@@ -40,6 +40,8 @@ class PluginsLoader {
40
 
41
  /** 星铁命令前缀 */
42
  srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
 
 
43
 
44
  async getPlugins() {
45
  const files = await fs.readdir(this.dir, { withFileTypes: true })
@@ -222,6 +224,9 @@ class PluginsLoader {
222
  if (this.srReg.test(e.msg)) {
223
  e.game = "sr"
224
  e.msg = e.msg.replace(this.srReg, "#星铁")
 
 
 
225
  }
226
 
227
  /** 优先执行 accept */
 
40
 
41
  /** 星铁命令前缀 */
42
  srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
43
+ /** 绝区零前缀 */
44
+ zzzReg = /^#?(%|%|绝区零|绝区)+/
45
 
46
  async getPlugins() {
47
  const files = await fs.readdir(this.dir, { withFileTypes: true })
 
224
  if (this.srReg.test(e.msg)) {
225
  e.game = "sr"
226
  e.msg = e.msg.replace(this.srReg, "#星铁")
227
+ } else if (this.zzzReg.test(e.msg)) {
228
+ e.game = "zzz"
229
+ e.msg = e.msg.replace(this.zzzReg, "#绝区零")
230
  }
231
 
232
  /** 优先执行 accept */
Yunzai/lib/plugins/stdin.js CHANGED
@@ -28,24 +28,28 @@ Bot.adapter.push(new class stdinAdapter {
28
  if (Buffer.isBuffer(file.buffer)) {
29
  file.path = `${this.path}${file.name}`
30
  await fs.writeFile(file.path, file.buffer)
 
31
  }
32
  }
33
 
34
  switch (i.type) {
35
  case "text":
36
  if (i.text.match("\n"))
37
- i.text = `发送文本:\n${i.text}`
38
  Bot.makeLog("info", i.text, this.id)
39
  break
40
  case "image":
41
  await this.catimg(file.path)
42
- Bot.makeLog("info", `发送图片:${file.url}\n文件已保存到:${logger.cyan(file.path)}`, this.id)
43
  break
44
  case "record":
45
- Bot.makeLog("info", `发送音频:${file.url}\n文件已保存到:${logger.cyan(file.path)}`, this.id)
46
  break
47
  case "video":
48
- Bot.makeLog("info", `发送视频:${file.url}\n文件已保存到:${logger.cyan(file.path)}`, this.id)
 
 
 
49
  break
50
  case "reply":
51
  break
@@ -62,19 +66,11 @@ Bot.adapter.push(new class stdinAdapter {
62
  }
63
 
64
  recallMsg(message_id) {
65
- Bot.makeLog("info", `撤回消息:${message_id}`, this.id)
66
  }
67
 
68
  async sendFile(file, name = path.basename(file)) {
69
- const buffer = await Bot.Buffer(file)
70
- if (!Buffer.isBuffer(buffer)) {
71
- Bot.makeLog("error", `发送文件错误:找不到文件 ${logger.red(file)}`, this.id)
72
- return false
73
- }
74
-
75
- const files = `${this.path}${Date.now().toString(36)}-${name}`
76
- Bot.makeLog("info", `发送文件:${file}\n文件已保存到:${logger.cyan(files)}`, this.id)
77
- return fs.writeFile(files, buffer)
78
  }
79
 
80
  pickFriend() {
@@ -98,7 +94,7 @@ Bot.adapter.push(new class stdinAdapter {
98
  message: [{ type: "text", text: msg }],
99
  raw_message: msg,
100
  }
101
- Bot.makeLog("info", `系统消息:${data.raw_message}`, this.id)
102
  Bot.em(`${data.post_type}.${data.message_type}`, data)
103
  }
104
 
 
28
  if (Buffer.isBuffer(file.buffer)) {
29
  file.path = `${this.path}${file.name}`
30
  await fs.writeFile(file.path, file.buffer)
31
+ file.url = `${file.url}\n路径: ${logger.cyan(file.path)}\n网址: ${logger.green(await Bot.fileToUrl(file))}`
32
  }
33
  }
34
 
35
  switch (i.type) {
36
  case "text":
37
  if (i.text.match("\n"))
38
+ i.text = `发送文本: \n${i.text}`
39
  Bot.makeLog("info", i.text, this.id)
40
  break
41
  case "image":
42
  await this.catimg(file.path)
43
+ Bot.makeLog("info", `发送图片: ${file.url}`, this.id)
44
  break
45
  case "record":
46
+ Bot.makeLog("info", `发送音频: ${file.url}`, this.id)
47
  break
48
  case "video":
49
+ Bot.makeLog("info", `发送视频: ${file.url}`, this.id)
50
+ break
51
+ case "file":
52
+ Bot.makeLog("info", `发送文件: ${file.url}`, this.id)
53
  break
54
  case "reply":
55
  break
 
66
  }
67
 
68
  recallMsg(message_id) {
69
+ Bot.makeLog("info", `撤回消息: ${message_id}`, this.id)
70
  }
71
 
72
  async sendFile(file, name = path.basename(file)) {
73
+ return this.sendMsg(segment.file(file, name))
 
 
 
 
 
 
 
 
74
  }
75
 
76
  pickFriend() {
 
94
  message: [{ type: "text", text: msg }],
95
  raw_message: msg,
96
  }
97
+ Bot.makeLog("info", `系统消息: ${data.raw_message}`, this.id)
98
  Bot.em(`${data.post_type}.${data.message_type}`, data)
99
  }
100
 
Yunzai/package.json CHANGED
@@ -19,7 +19,7 @@
19
  "chalk": "^5.3.0",
20
  "chokidar": "^3.6.0",
21
  "express": "^4.19.2",
22
- "file-type": "^19.0.0",
23
  "https-proxy-agent": "7.0.5",
24
  "image-size": "^1.1.1",
25
  "level": "^8.0.1",
@@ -30,14 +30,14 @@
30
  "node-fetch": "link:lib/modules/node-fetch",
31
  "node-schedule": "^2.1.1",
32
  "oicq": "link:lib/modules/oicq",
33
- "pm2": "^5.4.1",
34
  "puppeteer": "*",
35
- "redis": "^4.6.14",
36
  "sequelize": "^6.37.3",
37
  "sqlite3": "5.1.6",
38
  "strip-ansi": "^7.1.0",
39
  "ulid": "^2.3.0",
40
- "ws": "^8.17.1",
41
  "yaml": "^2.4.5"
42
  },
43
  "devDependencies": {
 
19
  "chalk": "^5.3.0",
20
  "chokidar": "^3.6.0",
21
  "express": "^4.19.2",
22
+ "file-type": "^19.1.1",
23
  "https-proxy-agent": "7.0.5",
24
  "image-size": "^1.1.1",
25
  "level": "^8.0.1",
 
30
  "node-fetch": "link:lib/modules/node-fetch",
31
  "node-schedule": "^2.1.1",
32
  "oicq": "link:lib/modules/oicq",
33
+ "pm2": "^5.4.2",
34
  "puppeteer": "*",
35
+ "redis": "^4.6.15",
36
  "sequelize": "^6.37.3",
37
  "sqlite3": "5.1.6",
38
  "strip-ansi": "^7.1.0",
39
  "ulid": "^2.3.0",
40
+ "ws": "^8.18.0",
41
  "yaml": "^2.4.5"
42
  },
43
  "devDependencies": {
Yunzai/plugins/system/status.js CHANGED
@@ -30,7 +30,7 @@ export class status extends plugin {
30
  `系统版本:${process.platform} ${process.arch} ${process.version}`+
31
  this.botTime() + await this.count()
32
 
33
- return this.reply(msg)
34
  }
35
 
36
  botTime() {
 
30
  `系统版本:${process.platform} ${process.arch} ${process.version}`+
31
  this.botTime() + await this.count()
32
 
33
+ return this.reply(Bot.makeForwardArray(msg))
34
  }
35
 
36
  botTime() {