修复传参错误 (#16)
This commit is contained in:
parent
74f5d7a861
commit
f3d6950b51
|
@ -2,8 +2,9 @@
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
# redis端口
|
# redis端口
|
||||||
port: 6379
|
port: 6379
|
||||||
|
# redis用户名,可以为空
|
||||||
|
username:
|
||||||
# redis密码,没有密码可以为空
|
# redis密码,没有密码可以为空
|
||||||
password:
|
password:
|
||||||
# redis数据库
|
# redis数据库
|
||||||
db: 0
|
db: 0
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import cfg from './config/config.js'
|
||||||
|
|
||||||
export default class Yunzai extends Client {
|
export default class Yunzai extends Client {
|
||||||
// eslint-disable-next-line no-useless-constructor
|
// eslint-disable-next-line no-useless-constructor
|
||||||
constructor (uin, conf) {
|
constructor (conf) {
|
||||||
super(uin, conf)
|
super(conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 登录机器人 */
|
/** 登录机器人 */
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Cfg {
|
||||||
bot = { ...defbot, ...bot }
|
bot = { ...defbot, ...bot }
|
||||||
bot.platform = this.getConfig('qq').platform
|
bot.platform = this.getConfig('qq').platform
|
||||||
/** 设置data目录,防止pm2运行时目录不对 */
|
/** 设置data目录,防止pm2运行时目录不对 */
|
||||||
bot.data_dir = process.cwd() + '/data'
|
bot.data_dir = process.cwd() + '/data/icqq/' + this.qq || ''
|
||||||
|
|
||||||
if (!bot.ffmpeg_path) delete bot.ffmpeg_path
|
if (!bot.ffmpeg_path) delete bot.ffmpeg_path
|
||||||
if (!bot.ffprobe_path) delete bot.ffprobe_path
|
if (!bot.ffprobe_path) delete bot.ffprobe_path
|
||||||
|
@ -54,6 +54,10 @@ class Cfg {
|
||||||
return this.getConfig('other')
|
return this.getConfig('other')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get redis () {
|
||||||
|
return this.getConfig('redis')
|
||||||
|
}
|
||||||
|
|
||||||
/** 主人qq */
|
/** 主人qq */
|
||||||
get masterQQ () {
|
get masterQQ () {
|
||||||
let masterQQ = this.getConfig('other').masterQQ || []
|
let masterQQ = this.getConfig('other').masterQQ || []
|
||||||
|
@ -144,7 +148,7 @@ class Cfg {
|
||||||
|
|
||||||
change_qq () {
|
change_qq () {
|
||||||
if (process.argv.includes('login') || !this.qq) return
|
if (process.argv.includes('login') || !this.qq) return
|
||||||
logger.info('修改qq或密码,请手动重启')
|
logger.info('修改机器人QQ或密码,请手动重启')
|
||||||
}
|
}
|
||||||
|
|
||||||
async change_bot () {
|
async change_bot () {
|
||||||
|
|
|
@ -2,36 +2,9 @@ import createQQ from './qq.js'
|
||||||
import setLog from './log.js'
|
import setLog from './log.js'
|
||||||
import redisInit from './redis.js'
|
import redisInit from './redis.js'
|
||||||
import { checkRun } from './check.js'
|
import { checkRun } from './check.js'
|
||||||
import fs from 'fs'
|
import fs from 'node:fs'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
|
|
||||||
let path = './config/config/qq.yaml'
|
|
||||||
|
|
||||||
// 异步函数来读取 yaml 文件
|
|
||||||
/*
|
|
||||||
async function getQQ () {
|
|
||||||
function getQQPromise () {
|
|
||||||
// eslint-disable-next-line no-async-promise-executor
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
const file = await fs.promises.readFile(path, 'utf8')
|
|
||||||
const config = yaml.parse(file)
|
|
||||||
resolve(config)
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
reject(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return getQQPromise().then((config) => {
|
|
||||||
return config
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 添加一些多余的标题内容
|
// 添加一些多余的标题内容
|
||||||
let title = 'Miao-Yunzai'
|
let title = 'Miao-Yunzai'
|
||||||
let qq = await fs.promises.readFile('./config/config/qq.yaml', 'UTF-8').then(yaml.parse).catch(() => null)
|
let qq = await fs.promises.readFile('./config/config/qq.yaml', 'UTF-8').then(yaml.parse).catch(() => null)
|
||||||
|
@ -57,7 +30,6 @@ if (qq) {
|
||||||
|
|
||||||
/** 设置标题 */
|
/** 设置标题 */
|
||||||
process.title = title
|
process.title = title
|
||||||
// process.title = `Miao-Yunzai ${(await getQQ()).qq === null ? '首次启动' : (await getQQ()).qq} ${(await getQQ()).platform === 1 ? '安卓手机' : (await getQQ()).platform === 2 ? 'aPad' : (await getQQ()).platform === 3 ? '安卓手表' : (await getQQ()).platform === 4 ? 'MacOS' : (await getQQ()).platform === 5 ? 'iPad' : 'Null'}`
|
|
||||||
|
|
||||||
/** 设置时区 */
|
/** 设置时区 */
|
||||||
process.env.TZ = 'Asia/Shanghai'
|
process.env.TZ = 'Asia/Shanghai'
|
||||||
|
@ -85,7 +57,7 @@ await checkInit()
|
||||||
async function checkInit () {
|
async function checkInit () {
|
||||||
/** 检查node_modules */
|
/** 检查node_modules */
|
||||||
if (!fs.existsSync('./node_modules') || !fs.existsSync('./node_modules/icqq')) {
|
if (!fs.existsSync('./node_modules') || !fs.existsSync('./node_modules/icqq')) {
|
||||||
console.log('请先运行命令:pnpm install 安装依赖')
|
console.log('请先运行命令:pnpm install -P 安装依赖')
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,26 @@
|
||||||
import YAML from 'yaml'
|
import cfg from './config.js'
|
||||||
import fs from 'fs'
|
|
||||||
import common from '../common/common.js'
|
import common from '../common/common.js'
|
||||||
import { createClient } from 'redis'
|
import { createClient } from 'redis'
|
||||||
|
import { exec } from 'node:child_process'
|
||||||
import { createRequire } from 'module'
|
|
||||||
const require = createRequire(import.meta.url)
|
|
||||||
const { exec } = require('child_process')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化全局redis客户端
|
* 初始化全局redis客户端
|
||||||
*/
|
*/
|
||||||
export default async function redisInit () {
|
export default async function redisInit () {
|
||||||
logger.mark('正在连接 Redis...')
|
|
||||||
const file = './config/config/redis.yaml'
|
|
||||||
const cfg = YAML.parse(fs.readFileSync(file, 'utf8'))
|
|
||||||
|
|
||||||
let redisUrl = ''
|
const rc = cfg.redis
|
||||||
if (cfg.password) {
|
let redisUn = rc.username || ''
|
||||||
redisUrl = `redis://:${cfg.password}@${cfg.host}:${cfg.port}`
|
let redisPw = rc.password ? `:${rc.password}` : ''
|
||||||
} else {
|
if (rc.username || rc.password) redisPw += '@'
|
||||||
redisUrl = `redis://${cfg.host}:${cfg.port}`
|
let redisUrl = `redis://${redisUn}${redisPw}${rc.host}:${rc.port}/${rc.db}`
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化reids
|
// 初始化reids
|
||||||
let client = createClient({ url: redisUrl })
|
let client = createClient({ url: redisUrl })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
logger.mark(`正在连接 Redis...`)
|
||||||
|
logger.mark(redisUrl)
|
||||||
|
|
||||||
await client.connect()
|
await client.connect()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let err = error.toString()
|
let err = error.toString()
|
||||||
|
@ -73,7 +68,6 @@ export default async function redisInit () {
|
||||||
process.exit()
|
process.exit()
|
||||||
})
|
})
|
||||||
|
|
||||||
client.select(cfg.db)
|
|
||||||
/** 全局变量 redis */
|
/** 全局变量 redis */
|
||||||
global.redis = client
|
global.redis = client
|
||||||
|
|
||||||
|
@ -101,7 +95,7 @@ async function aarch64 () {
|
||||||
|
|
||||||
/** 尝试自动启动redis */
|
/** 尝试自动启动redis */
|
||||||
async function startRedis (cmd, client, redisUrl) {
|
async function startRedis (cmd, client, redisUrl) {
|
||||||
logger.mark('正在尝试启动 Redis...')
|
logger.mark('正在启动 Redis...')
|
||||||
await execSync(cmd)
|
await execSync(cmd)
|
||||||
await common.sleep(500)
|
await common.sleep(500)
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -105,7 +105,7 @@ class PluginsLoader {
|
||||||
packageErr.forEach(v => {
|
packageErr.forEach(v => {
|
||||||
let pack = v.error.stack.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
let pack = v.error.stack.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
||||||
logger.mark(`${v.File.name} 缺少依赖:${logger.red(pack)}`)
|
logger.mark(`${v.File.name} 缺少依赖:${logger.red(pack)}`)
|
||||||
logger.mark(`新增插件后请执行安装命令:${logger.red('pnpm install')} 安装依赖`)
|
logger.mark(`新增插件后请执行安装命令:${logger.red('pnpm install -P')} 安装依赖`)
|
||||||
logger.mark(`如安装后仍未解决可联系插件作者将 ${logger.red(pack)} 依赖添加至插件的package.json dependencies中,或手工安装依赖`)
|
logger.mark(`如安装后仍未解决可联系插件作者将 ${logger.red(pack)} 依赖添加至插件的package.json dependencies中,或手工安装依赖`)
|
||||||
})
|
})
|
||||||
// logger.error('或者使用其他包管理工具安装依赖')
|
// logger.error('或者使用其他包管理工具安装依赖')
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"author": "Yoimiya-Kokomi, Le-niao",
|
"author": "Yoimiya-Kokomi, Le-niao",
|
||||||
"description": "QQ group Bot",
|
"description": "QQ group Bot",
|
||||||
|
"main": "app.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"app": "node app.js",
|
"app": "node .",
|
||||||
"dev": "node app.js dev",
|
"dev": "node . dev",
|
||||||
|
"login": "node . login",
|
||||||
"web": "node ./lib/tools/web.js",
|
"web": "node ./lib/tools/web.js",
|
||||||
"test": "node ./lib/tools/test.js",
|
"test": "node ./lib/tools/test.js",
|
||||||
"login": "node app.js login",
|
|
||||||
"start": "pm2 start ./config/pm2/pm2.json",
|
"start": "pm2 start ./config/pm2/pm2.json",
|
||||||
"stop": "pm2 stop ./config/pm2/pm2.json",
|
"stop": "pm2 stop ./config/pm2/pm2.json",
|
||||||
"restart": "pm2 restart ./config/pm2/pm2.json",
|
"restart": "pm2 restart ./config/pm2/pm2.json",
|
||||||
|
@ -31,7 +32,6 @@
|
||||||
"node-schedule": "^2.1.1",
|
"node-schedule": "^2.1.1",
|
||||||
"node-xlsx": "^0.21.0",
|
"node-xlsx": "^0.21.0",
|
||||||
"oicq": "^2.3.1",
|
"oicq": "^2.3.1",
|
||||||
"patch-package": "^6.5.1",
|
|
||||||
"pm2": "^5.2.2",
|
"pm2": "^5.2.2",
|
||||||
"puppeteer": "^19.7.3",
|
"puppeteer": "^19.7.3",
|
||||||
"redis": "^4.6.5",
|
"redis": "^4.6.5",
|
||||||
|
|
Loading…
Reference in New Issue