New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koishi-plugin-cave

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koishi-plugin-cave - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

2

lib/index.d.ts

@@ -19,2 +19,4 @@ import { Context, Schema } from 'koishi';

nameinfo: any;
number: number;
helpinfo: any;
}

@@ -21,0 +23,0 @@ export declare const Config: Schema<Config>;

106

lib/index.js

@@ -1,54 +0,23 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = exports.name = void 0;
exports.saveImages = saveImages;
exports.getFileCountPlusOne = getFileCountPlusOne;
exports.getMaxCaveId = getMaxCaveId;
exports.apply = apply;
const koishi_1 = require("koishi");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const util_1 = __importDefault(require("util"));
import { Schema, h, Logger } from 'koishi';
import * as fs from 'fs';
import * as path from 'path';
import util from 'util';
// import { get } from 'http';
// import { stringify } from 'querystring';
const logger = new koishi_1.Logger('cave');
exports.name = 'cave';
exports.Config = koishi_1.Schema.intersect([
koishi_1.Schema.object({
manager: koishi_1.Schema.array(koishi_1.Schema.string())
const logger = new Logger('cave');
export const name = 'cave';
export const Config = Schema.intersect([
Schema.object({
manager: Schema.array(Schema.string())
.required()
.description('管理员QQ,一个项目填一个ID'),
consoleinfo: koishi_1.Schema.boolean().default(false).description('日志调试模式'),
consolefor: koishi_1.Schema.boolean().default(true).description('开启-g指令指定回声洞'),
nameinfo: koishi_1.Schema.boolean().default(false).description('使用陌生人接口获取昵称'),
consoleinfo: Schema.boolean().default(false).description('日志调试模式'),
consolefor: Schema.boolean().default(false).description('开启-g指令指定回声洞'),
number: Schema.number().default(3).description('群单位回声洞冷却时间,单位为秒'),
helpinfo: Schema.boolean().default(true).description('开启冷却显示'),
nameinfo: Schema.boolean().default(false).description('使用陌生人接口获取昵称')
})
]);
//抄上学的
async function saveImages(urls, selectedPath, safeFilename, imageExtension, config, session, ctx) {
export async function saveImages(urls, selectedPath, safeFilename, imageExtension, config, session, ctx) {
let url = urls;

@@ -92,3 +61,3 @@ let fileRoot = path.join(selectedPath, safeFilename);

//根据文件名最大数字更改大小函数
async function getFileCountPlusOne(dirPath) {
export async function getFileCountPlusOne(dirPath) {
let maxNumber = 0;

@@ -107,4 +76,4 @@ function traverseDir(dir) {

//检索json文件内的cave_id最大值+1
const readFile = util_1.default.promisify(fs.readFile);
async function getMaxCaveId(filePath) {
const readFile = util.promisify(fs.readFile);
export async function getMaxCaveId(filePath) {
try {

@@ -187,3 +156,3 @@ const data = await readFile(filePath, 'utf8');

}
async function apply(ctx, config) {
export async function apply(ctx, config) {
async function ensureDirExists(dirPath) {

@@ -219,2 +188,3 @@ if (!fs.existsSync(dirPath)) {

await ensureFileExistss(caveDataFilePath);
const lastUsed = new Map();
ctx.command('cave [image]', '回声洞')

@@ -224,2 +194,4 @@ .option('a', '-a 添加回声洞')

.option('r', '-r 删除当前id的回声洞')
.usage('注意: 直接使用回声洞指令该为cave,添加回声洞为cave -a,-g为只能管理员使用.')
.example('cave 随机一条回声洞\ncave -a 回复你要添加的图片或文字添加回声洞(不能是合并转发,视频,音频等)\ncave -g 查看当前id的回声洞内容(只能管理员使用或开启可选项后所有人都能使用)\ncave -r 删除当前id的回声洞')
// .option('c', '-c 设置当前群聊的回声洞冷却')

@@ -232,3 +204,3 @@ // .option('m', '-m 获取新增投稿的审核情况')

let sessioncontent = session.content;
imageURL = koishi_1.h.select(sessioncontent, 'img').map(a => a.attrs.src)[0];
imageURL = h.select(sessioncontent, 'img').map(a => a.attrs.src)[0];
console.log(session.event.message);

@@ -268,3 +240,3 @@ console.log(imageURL);

quotemessage = session.quote?.content ?? image;
imageURL = koishi_1.h.select(quotemessage, 'img').map(a => a.attrs.src)[0];
imageURL = h.select(quotemessage, 'img').map(a => a.attrs.src)[0];
}

@@ -339,3 +311,3 @@ let selectedPath;

textContentss,
koishi_1.h.image(imageURL),
h.image(imageURL),
`—— ${contributor_id}`

@@ -459,3 +431,3 @@ ];

`\n`,
(0, koishi_1.h)('image', { src: messages.filter(msg => msg).join('\n') }),
h('image', { src: messages.filter(msg => msg).join('\n') }),
`—— ${username}`

@@ -471,5 +443,5 @@ ];

// h.transform(message, ),
koishi_1.h.text(str), // 确保文本部分正确显示
h.text(str), // 确保文本部分正确显示
'\n\n', // 手动添加换行符
(0, koishi_1.h)('image', { src: messages.filter(msg => msg).join('\n') }),
h('image', { src: messages.filter(msg => msg).join('\n') }),
// '\n\n', // 手动添加换行符

@@ -486,5 +458,19 @@ `—— ${username}`

const filteredData = data.filter(item => item.state === 0);
const guildId = session.guildId;
const lastCall = lastUsed.get(guildId) || 0;
const now = Date.now();
if (filteredData.length === 0) {
return session.send('没有找到符合条件的回声洞。');
}
const diff = now - lastCall;
if (diff < config.number * 1000) {
const timeLeft = Math.ceil((config.number * 1000 - diff) / 1000);
if (config.helpinfo) {
return `群回声洞调用的太频繁了,请等待${timeLeft}秒后再试`;
}
else {
return;
}
}
lastUsed.set(guildId, now);
const randomObject = getRandomObject(filteredData);

@@ -541,3 +527,3 @@ const { cave_id, message, contributor_id, state } = randomObject;

`\n`,
(0, koishi_1.h)('image', { src: messages.filter(msg => msg).join('\n') }),
h('image', { src: messages.filter(msg => msg).join('\n') }),
`—— ${username}`

@@ -553,5 +539,5 @@ ];

// h.transform(message, ),
koishi_1.h.text(str), // 确保文本部分正确显示
h.text(str), // 确保文本部分正确显示
'\n\n', // 手动添加换行符
(0, koishi_1.h)('image', { src: messages.filter(msg => msg).join('\n') }),
h('image', { src: messages.filter(msg => msg).join('\n') }),
// '\n\n', // 手动添加换行符

@@ -568,2 +554,4 @@ `—— ${username}`

.option('f', '-f 私聊审核不通过回声洞')
.usage('注意:未审核的回声洞不在可抽取列表,该指令只能在私聊使用,群聊使用无响应属于正常.')
.example('setcave -t 1/all 审核通过id为1/全部的未审核回声洞\nsetcave -f 1/all 不通过id为1/全部的未审核回声洞')
.action(async ({ session, options }, image) => {

@@ -570,0 +558,0 @@ const all = 'all';

{
"name": "koishi-plugin-cave",
"description": "",
"version": "1.0.1",
"version": "1.1.0",
"contributors": [

@@ -15,6 +15,2 @@ "AXLMLY xiuzhantianming@163.com"

"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/axlmly/koishi-plugin-cave.git"
},
"keywords": [

@@ -28,10 +24,14 @@ "chatbot",

"peerDependencies": {
"koishi": "^4.17.6"
"koishi": "^4.17.8"
},
"repository": {
"type": "git",
"url": "https://github.com/axlmly/koishi-plugin-cave.git"
},
"koishi": {
"description": {
"en": "A mysterious cave where the sound is echoed over and over again.",
"zh": "<ruby>群回声洞插件,各群友投稿加入回声洞库,可以随机抽取其中内容<rp>(</rp><rt>没错,koishi也要有自己的回声洞插件!赢!</rt><rp>)</rp></ruby>. 用户投稿回声洞后,会自动推送给审核人(配置内)进行审核,通过审核后,才能加入库中."
"zh": "<ruby>群回声洞插件,各群友投稿加入回声洞库,可以随机抽取其中内容<rp>(</rp><rt>没错,koishi也要有自己的回声洞插件!赢!</rt><rp>)</rp></ruby>用户投稿回声洞后,会自动推送给审核人(配置内)进行审核,通过审核后,才能加入库中."
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc