1 Star 0 Fork 3

syp1999/xiaoxue-plugin

forked from XueWerY/xiaoxue-plugin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 7.88 KB
一键复制 编辑 原始数据 按行查看 历史
syp1999 提交于 2022-12-05 19:18 . syp
// ============= 旧版代码(即将废弃)==============
//
import config from './model/config/config.js'//
import tools from './model/other/tools.js' //
import cfg from '../../lib/config/config.js' //
//
// ============================================
import { XPluginDataYamlFile } from './model/data-file/XPluginDataYamlFile.js'
const pluginDataFile = new XPluginDataYamlFile()
import { XPluginInit } from './model/init/XPluginInit.js'
const pluginInit = new XPluginInit()
await pluginInit.initPlugin()
// ============================================================================== 旧版代码(即将废弃)===============================================================================
//
let currentTime = pluginDataFile.moment().unix() //
await redis.set(`Yz:xiaoxue:config:lastruntime`, currentTime) //
const DEFAULT_PLUGIN_INFO = config.getDefaultConfig('xiaoxue', 'plugininfo') //
if (!await redis.get('Yz:xiaoxue:config:notfirstusexiaoxue')) { //
await redis.set('Yz:xiaoxue:config:botname', '小雪') //
let masterQQ = cfg.getConfig('other').masterQQ[0] //
await Bot.pickFriend(masterQQ).sendMsg(`欢迎使用小雪插件V${DEFAULT_PLUGIN_INFO.version}\n配置教程\n【腾讯文档】小雪插件配置教程\nhttps://docs.qq.com/doc/DZERCSERCZ09PdEl0`) //
await redis.set('Yz:xiaoxue:config:notfirstusexiaoxue', 1) //
let time = tools.getCurrentTime() //
let masterJoinTime = `${time.year}${time.month}${time.day}${time.hour}:${time.minute}:${time.second}` //
let botGroupIds = [] //
for (let [key, value] of Bot.gl) { //
botGroupIds.push(key) //
} //
for (let i in botGroupIds) { //
let groupMemberMap = await Bot.pickGroup(botGroupIds[i]).getMemberMap() //
let masterQQs = tools.masterQQs //
let count = 0 //
for (let j in masterQQs) { //
if (groupMemberMap.get(masterQQs[j])) { //
count++ //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:xuebaocount`, count) //
let name = await tools.getNickname(botGroupIds[i], masterQQs[j]) //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:${masterQQs[j]}:xuebaoinfo:name`, name) //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:${masterQQs[j]}:xuebaoinfo:jointime`, masterJoinTime) //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:${masterQQs[j]}:xuebaoinfo:xuebaoid`, count) //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:${masterQQs[j]}:favorability`, 2500) //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:${masterQQs[j]}:permissionlevel`, 5) //
await redis.set(`Yz:xiaoxue:${botGroupIds[i]}:${masterQQs[j]}:xuebi`, 999999999) //
} //
} //
} //
} //
//
// ==============================================================================================================================================================================
let ret = []
let files1 = pluginInit.fs.readdirSync('./plugins/xiaoxue-plugin/apps')
let files2 = []
for (let i of files1) {
if (i.endsWith('.js')) {
files2.push(i)
ret.push(import(`./apps/${i}`))
} else {
let files3 = pluginInit.fs.readdirSync(`./plugins/xiaoxue-plugin/apps/${i}`)
for (let j of files3) {
if (j.endsWith('.js')) {
files2.push(`${i}/${j}`)
ret.push(import(`./apps/${i}/${j}`))
}
}
}
}
ret = await Promise.allSettled(ret)
let apps = {}
for (let i in files2) {
let name = files2[i].replace('.js', '')
if (ret[i].status !== 'fulfilled') {
pluginInit.logger.error(`载入插件错误:${pluginInit.logger.red(name)}`)
pluginInit.logger.error(ret[i].reason)
continue
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
export { apps }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/sakurabing/xiaoxue-plugin.git
git@gitee.com:sakurabing/xiaoxue-plugin.git
sakurabing
xiaoxue-plugin
xiaoxue-plugin
master

搜索帮助