Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kotori-bot

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kotori-bot - npm Package Compare versions

Comparing version 0.6.5 to 0.6.6

claude.ts

26

main.ts

@@ -15,10 +15,5 @@ /*

export class Main {
/* 设置全局常量 */
private _const: Lib.obj = {
_ROOT_PATH: __dirname,
_CONFIG_PATH: `${__dirname}\\config`,
_DATA_PATH: `${__dirname}\\data`,
};
private _const = Lib._const;
private _config: Lib.obj = Lib.loadConfig(`${this._const._ROOT_PATH}\\config.yml`, 'yaml');

@@ -68,3 +63,3 @@

Http: [
this._config.connect['http'].url, this._config.connect['http'].port, this._config.connect['http']['retry-time'], this._config.connect['http']['reverse-port']
this._config.connect['http'].url, this._config.connect['http'].port, this._config.connect['http']['retry-time'], this._config.connect['http']['reverse-port']
],

@@ -76,3 +71,3 @@ Ws: [

};
protected EventPrototype = new EventPrototype.Event;
protected EventPrototype = new EventPrototype;
private _Api: Lib.obj = new Object;

@@ -82,5 +77,5 @@ private _Event: Lib.obj = new Object;

const connectMode = this.modeList[this._config.connect.mode];
new this.connectPrototype[connectMode](...this.connectConfig[connectMode], (connectDemo: Lib.obj) => {
new this.connectPrototype(...this.connectConfig[connectMode], (connectDemo: Lib.obj) => {
/* 接口实例化 */
this._Api = new ApiPrototype.Api(connectDemo.send);
this._Api = new ApiPrototype(connectDemo.send);
/* 事件注册实例化 */

@@ -130,4 +125,5 @@ this._Event = {

protected runAllEvent = (data: Lib.obj) => this.EventPrototype.handleEvent(this._pluginEventList, data)
private _pluginEntityList: Set<[Promise<Lib.obj>, string, string, Lib.obj?]> = Plugin.loadAll(__dirname);
private _pluginEntityList: Set<[Promise<Lib.obj>, string, string, Lib.obj?]> = new Set();
private runAllPlugin = () => {
this._pluginEntityList = Plugin.loadAll();
let num: number = 0;

@@ -138,4 +134,4 @@ this._pluginEntityList.forEach(async element => {

demo.PLUGIN(this._Event, this._Api, {
_CONFIG_PLUGIN_PATH: __dirname + '\\config\\plugins\\' + element[1],
_DATA_PLUGIN_PATH: __dirname + '\\data\\plugins\\' + element[1]
_CONFIG_PLUGIN_PATH: `${Lib._const._CONFIG_PATH}\\plugins\\${element[1]}`,
_DATA_PLUGIN_PATH: `${Lib._const._DATA_PATH}\\plugins\\${element[1]}`
});

@@ -158,4 +154,2 @@ const PLUGIN_INFO = element[3] ?? demo.PLUGIN_INFO;

export default {
Main
}
export default Main;
{
"name": "kotori-bot",
"version": "0.6.5",
"version": "0.6.6",
"description": "Korori Bot For Go-cqhttp And Nodejs",
"main": "./src/index.ts",
"main": "./dist/src/index.ts",
"scripts": {
"start": "ts-node app.ts"
"start": "ts-node ./src/app.ts",
"build": "tsc"
},

@@ -12,5 +13,7 @@ "author": "biyuehu",

"dependencies": {
"@lafjs/cloud": "^1.0.0-beta.7",
"@types/needle": "^3.2.0",
"@types/ws": "^8.5.4",
"axios": "^1.4.0",
"claude-api-slack": "^1.0.28",
"domain": "^0.0.1",

@@ -21,3 +24,2 @@ "fs": "^0.0.1-security",

"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"ws": "^8.13.0",

@@ -24,0 +26,0 @@ "yaml": "^2.3.1"

@@ -8,2 +8,17 @@ import fs from 'fs';

export const _const: obj = (function() {
let _ROOT_PATH = __dirname + '\\..';
if (!fs.existsSync(`${_ROOT_PATH}\\config.yml`)) {
_ROOT_PATH += '\\..';
}
return {
_ROOT_PATH,
_PLUGIN_PATH: `${_ROOT_PATH}\\plugins`,
_CONFIG_PATH: `${_ROOT_PATH}\\config`,
_DATA_PATH: `${_ROOT_PATH}\\data`,
_LOGS_PATH: `${_ROOT_PATH}\\logs`,
}
})();
export function loadConfig(filename: string, type: 'json' | 'yaml' | 'xml' | 'ini' = 'json') {

@@ -110,3 +125,3 @@ const data: string = fs.readFileSync(filename).toString()

public static prefixColor: string = 'blue';
public static logsFilePath: string = `${__dirname}\\..\\logs`;
public static logsFilePath: string = _const._LOGS_PATH;

@@ -156,3 +171,3 @@ public static originalLog = (__console: Function, type: string, typeColor: string, textColor: string, ...args: obj[]) => {

export function getPackageInfo() {
return loadConfig(`${__dirname}\\..\\package.json`);
return loadConfig(`${_const._ROOT_PATH}\\package.json`);
}

@@ -178,2 +193,3 @@

export default {
_const,
loadConfig,

@@ -180,0 +196,0 @@ stringProcess,

@@ -20,4 +20,5 @@ import { Main } from '../main';

protected config: Config = {connect: {mode: 'Http', port: 0}};
private callback;
public constructor(connectConfig: Connect) {
public constructor(connectConfig: Connect, callback: Function) {
super();

@@ -27,25 +28,25 @@ this.config = {

};
this.callback = callback;
}
/* Connect */
protected connectConfig: obj = {
Http: [
...this.connectConfig.Ws, this.config.connect.reverse_port
],
Ws: [
this.config.connect.url, this.config.connect.port, this.config.connect.retry_time
],
WsReverse: [ this.config.connect.port ]
protected connectConfig: obj = new Object;
public Api: obj = new Object;
public Event: obj = {
listen: (eventName: string, callback: Function) => this.EventPrototype.registerEvent(this._pluginEventList, eventName, callback)
};
public Api: obj = new Object;
public Event: obj = new Object;
protected connect = () => {
new this.connectPrototype[this.config.connect.mode](...this.connectConfig[this.config.connect.mode], (connectDemo: obj) => {
this.connectConfig = {
Http: [
this.config.connect.url, this.config.connect.port, this.config.connect.retry_time, this.config.connect.reverse_port
],
Ws: [
this.config.connect.url, this.config.connect.port, this.config.connect.retry_time
],
WsReverse: [ this.config.connect.port ]
}
new this.connectPrototype(...this.connectConfig[this.config.connect.mode], (connectDemo: obj) => {
/* 接口实例化 */
this.Api = new ApiPrototype.Api(connectDemo.send);
/* 事件注册实例化 */
this.Event = {
listen: (eventName: string, callback: Function) => this.EventPrototype.registerEvent(this._pluginEventList, eventName, callback)
}
this.Api = new ApiPrototype(connectDemo.send);
this.callback(this.Api, this.Event);
/* 监听主进程 */

@@ -60,6 +61,5 @@ connectDemo.listen((data: obj) => {

}
public create = () => this.run();
}
export default {
Kotori
}
export default Kotori;

@@ -848,4 +848,2 @@ /*

export default {
Api
}
export default Api;

@@ -42,10 +42,8 @@ /*

}
/* list.forEach(element => {
list.forEach(element => {
this.handleEventList[element[0]](eventData, element[1]);
}) */
})
}
}
export default {
Event
}
export default Event;
import Fs from 'fs';
import Path from 'path';
import { obj, loadConfig } from './function';
import { obj, loadConfig, _const } from './function';
export const load = (pluginName: string, path: string) => {
return import(`${path}\\plugins\\${pluginName}`)
export const load = (pluginName: string) => {
return import(`${_const._PLUGIN_PATH}\\${pluginName}`)
}
export const loadAll = (path: string) => {
const filePath = `${path}\\plugins`;
const fileList = Fs.readdirSync(filePath);
export const loadAll = () => {
const fileList = Fs.readdirSync(_const._PLUGIN_PATH);
const entityList: Set<[Promise<obj>, string, string, obj?]> = new Set();
fileList.forEach(fileName => {
const filedir = Path.join(filePath + '\\', fileName);
const filedir = Path.join(_const._PLUGIN_PATH + '\\', fileName);
const fileStat = Fs.statSync(filedir);

@@ -23,7 +22,7 @@

if (fileType === 'ts' || fileType === 'js') {
const entity = load(fileName, path);
entity && entityList.add([entity, fileName, `${path}\\plugins\\${fileName}`]);
const entity = load(fileName);
entity && entityList.add([entity, fileName, `${_const._ROOT_PATH}\\plugins\\${fileName}`]);
}
} else if (fileStat.isDirectory()) {
const Path = `${filePath}\\${fileName}\\`;
const Path = `${_const._PLUGIN_PATH}\\${fileName}\\`;
let info: obj|undefined;

@@ -35,6 +34,6 @@ if (Fs.existsSync(`${Path}manifest.json`)) {

if (Fs.existsSync(`${Path}index.ts`)) {
const entity = load(`${fileName}\\index.ts`, path);
const entity = load(`${fileName}\\index.ts`);
entity && entityList.add([entity, fileName, `${Path}index.ts`, info]);
} else if (Fs.existsSync(`${Path}index.js`)) {
const entity = load(`${fileName}\\index.js`, path);
const entity = load(`${fileName}\\index.js`);
entity && entityList.add([entity, fileName, `${Path}index.js`, info]);

@@ -41,0 +40,0 @@ }

import needle from "needle";
export default {
needle
}
export default needle;

@@ -36,4 +36,2 @@ import WebSocket from 'ws';

export default {
WsReverse
};
export default WsReverse;

@@ -51,4 +51,2 @@ import WebSocket from 'ws';

export default {
Ws
};
export default Ws;

@@ -1,32 +0,14 @@

function formatTime(time?: Date | null, format: Number = 0): string {
if (!time) time = new Date();
let result: string = '';
if (format === 0) {
result += `${time.getFullYear().toString().substring(2)}/`;
result += `${time.getMonth() + 1}/${time.getDate()} `;
result += `${time.getHours()}:${time.getMinutes()}:${time.getMinutes()}`
} else if (format === 1) {
result += `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`;
}
return result;
}
const originalLog = (__console: Function, ...agrs: any) => {
let message: string = '';
agrs.forEach((Element: any) => {
// try {
message += JSON.stringify(JSON.parse(Element)) + ' '
// } catch {
// message += JSON.stringify(Element) + ' '
// }
message.slice(0, -1)
import Kotori from "./src";
const Bot = new Kotori({
mode: 'WsReverse',
port: 8080
}, (Api: any, Event: any) => {
Event.listen('on_private_msg', (data: any) => {
console.log(data);
// Api.send_private_msg()
})
const time = formatTime();
let result: string = `${'\x1B[0m'}${time}${'\x1B[0m'} `
// result += `[${'\x1B[0m'}{'\x1B[0m'}] `
result += `${'\x1B[0m'}${agrs}${'\x1B[0m'}`;
__console(result);
}
const aaa = (...agrs: any) => originalLog(console.log, ...agrs);
aaa({ a: 'aa' }, {})
})
Bot.create();
const { Event, Api } = Bot;
console.log('ss')
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */

@@ -12,5 +11,4 @@ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */

// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */

@@ -27,5 +25,4 @@ // "jsx": "preserve", /* Specify what JSX code is generated. */

// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "CommonJS", /* Specify what module code is generated. */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */

@@ -47,3 +44,2 @@ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */

// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */

@@ -53,3 +49,2 @@ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */

// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */

@@ -79,3 +74,2 @@ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */

// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */

@@ -85,8 +79,7 @@ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */

// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */

@@ -110,7 +103,38 @@ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */

// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
// "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"outDir": "./dist/",// 打包到的目录
"sourceMap": true,// 是否生成sourceMap(用于浏览器调试)
"noImplicitAny": false,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
"declaration": true,// 是否生成声明文件
"declarationDir": "./dist/types/",// 声明文件打包的位置
"declarationMap": true,// 是否生成声明文件map文件(便于调试)
"moduleResolution": "node",
"baseUrl": "./",
"types": [
"node",
// "jest"
],
"typeRoots": [
"./node_modules/@types"
],
"lib": [
"dom",
"es2015"
],
"jsx": "react",
"allowJs": false
},
"include": [
"package.json",
"src/**/*.ts",
"plugins/**/*.ts"
], // 要打包的文件
"exclude": [
"node_modules",
"*.test.ts"
]
}

Sorry, the diff of this file is not supported yet

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