✨ 适配segment作为全局变量
This commit is contained in:
@@ -12,7 +12,8 @@ module.exports = {
|
||||
Bot: true,
|
||||
redis: true,
|
||||
logger: true,
|
||||
plugin: true
|
||||
plugin: true,
|
||||
segment: true
|
||||
},
|
||||
rules: {
|
||||
'eqeqeq': ['off'],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import { common, QQApi } from '../model/index.js'
|
||||
import _ from 'lodash'
|
||||
import moment from 'moment'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import fetch from 'node-fetch'
|
||||
import { segment } from 'oicq'
|
||||
import _ from 'lodash'
|
||||
import { Config } from '../components/index.js'
|
||||
import { common, uploadRecord, QQApi, funApi } from '../model/index.js'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import _ from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { segment } from 'oicq'
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { Config } from '../components/index.js'
|
||||
import { common, GroupAdmin as ga, puppeteer, QQApi } from '../model/index.js'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import { Config } from '../components/index.js'
|
||||
import { common, GroupAdmin as ga } from '../model/index.js'
|
||||
import _ from 'lodash'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import _ from 'lodash'
|
||||
import { segment } from 'oicq'
|
||||
import { common } from '../model/index.js'
|
||||
import moment from 'moment'
|
||||
const ROLE_MAP = {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import gsCfg from '../../genshin/model/gsCfg.js'
|
||||
import { segment } from 'oicq'
|
||||
import fs from 'node:fs'
|
||||
import common from '../../../lib/common/common.js'
|
||||
import { Data, Plugin_Path } from '../components/index.js'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
import moment from 'moment'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import cfg from '../../../lib/config/config.js'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
|
||||
8
index.js
8
index.js
@@ -13,6 +13,14 @@ files.forEach((file) => {
|
||||
ret.push(import(`./apps/${file}`))
|
||||
})
|
||||
|
||||
if (!global.segment) {
|
||||
try {
|
||||
global.segment = (await import('oicq')).segment
|
||||
} catch (err) {
|
||||
global.segment = (await import('icqq')).segment
|
||||
}
|
||||
}
|
||||
|
||||
ret = await Promise.allSettled(ret)
|
||||
|
||||
let apps = {}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { segment } from 'oicq'
|
||||
import fs from 'fs'
|
||||
import _ from 'lodash'
|
||||
import puppeteer from 'puppeteer'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import fetch from 'node-fetch'
|
||||
import { segment } from 'oicq'
|
||||
import { Config } from '../../components/index.js'
|
||||
import { Agent } from 'https'
|
||||
import { HttpsProxyAgent } from './httpsProxyAgentMod.js'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import _ from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { segment } from 'oicq'
|
||||
import loader from '../../../lib/plugins/loader.js'
|
||||
import { Config } from '../components/index.js'
|
||||
import { common, QQApi } from './index.js'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import _ from 'lodash'
|
||||
import { segment } from 'oicq'
|
||||
import { puppeteer } from '../index.js'
|
||||
import request from '../../lib/request/request.js'
|
||||
import { Config } from '../../components/index.js'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import request from '../../lib/request/request.js'
|
||||
import { Config, Plugin_Path } from '../../components/index.js'
|
||||
import { segment } from 'oicq'
|
||||
import common from '../../../../lib/common/common.js'
|
||||
import _ from 'lodash'
|
||||
export default async function doSearch (imgURL) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import _ from 'lodash'
|
||||
import moment from 'moment'
|
||||
import fetch from 'node-fetch'
|
||||
import { segment } from 'oicq'
|
||||
import { Config } from '../components/index.js'
|
||||
import request from '../lib/request/request.js'
|
||||
import { rankType } from '../tools/pixiv.js'
|
||||
|
||||
@@ -2,7 +2,6 @@ import fetch from 'node-fetch'
|
||||
import { common } from '../index.js'
|
||||
import _ from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { core } from 'oicq'
|
||||
import request from '../../lib/request/request.js'
|
||||
/** 获取gtk */
|
||||
const gtk = function (t) {
|
||||
@@ -426,6 +425,12 @@ export default new class {
|
||||
* @return {Object}
|
||||
*/
|
||||
async thumbUp (uid, times = 1) {
|
||||
let core = null
|
||||
try {
|
||||
core = (await import('oicq')).core
|
||||
} catch (err) {
|
||||
core = (await import('icqq')).core
|
||||
}
|
||||
if (times > 20) { times = 20 }
|
||||
let ReqFavorite
|
||||
if (Bot.fl.get(uid)) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import fetch from 'node-fetch'
|
||||
import md5 from 'md5'
|
||||
import _ from 'lodash'
|
||||
import request from '../../lib/request/request.js'
|
||||
import { segment } from 'oicq'
|
||||
const API_ERROR = '出了点小问题,待会再试试吧'
|
||||
|
||||
export default new class {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable no-void */
|
||||
import Contactable, { core } from 'oicq'
|
||||
import querystring from 'querystring'
|
||||
import fetch from 'node-fetch'
|
||||
import fs from 'fs'
|
||||
@@ -8,7 +7,15 @@ import os from 'os'
|
||||
import crypto from 'crypto'
|
||||
import child_process from 'child_process'
|
||||
let errors = {}
|
||||
|
||||
let core = null
|
||||
let Contactable = null
|
||||
try {
|
||||
Contactable = (await import('oicq')).default
|
||||
core = (await import('oicq')).core
|
||||
} catch (err) {
|
||||
Contactable = (await import('icqq')).default
|
||||
core = (await import('icqq')).core
|
||||
}
|
||||
async function uploadRecord (record_url, seconds = 0, transcoding = true) {
|
||||
const result = await getPttBuffer(record_url, Bot.config.ffmpeg_path, transcoding)
|
||||
if (!result.buffer) {
|
||||
|
||||
Reference in New Issue
Block a user