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

@satorijs/adapter-kook

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@satorijs/adapter-kook - npm Package Compare versions

Comparing version 4.5.0-alpha.0 to 4.5.0-alpha.1

36

lib/index.js

@@ -1,6 +0,4 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -20,10 +18,2 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -507,5 +497,2 @@

// src/bot.ts
var import_form_data2 = __toESM(require("form-data"));
// src/ws.ts

@@ -627,3 +614,2 @@ var import_satori2 = require("@satorijs/satori");

var import_satori4 = require("@satorijs/satori");
var import_form_data = __toESM(require("form-data"));
function isDirectChannel(channelId) {

@@ -676,20 +662,16 @@ return channelId.length > 30;

if (await this.bot.http.isLocal(src)) {
const payload = new import_form_data.default();
const payload = new FormData();
const result = await this.bot.ctx.http.file(src, attrs);
payload.append("file", Buffer.from(result.data), {
filename: attrs.file || result.filename
});
const { url } = await this.bot.request("POST", "/asset/create", payload, payload.getHeaders());
payload.append("file", new Blob([result.data], { type: result.mime }), attrs.file || result.filename);
const { url } = await this.bot.request("POST", "/asset/create", payload);
return url;
} else if (!src.includes("kookapp.cn")) {
const res = await this.bot.ctx.http.get(src, {
const { data, headers } = await this.bot.ctx.http("GET", src, {
headers: { accept: type + "/*" },
responseType: "stream",
responseType: "arraybuffer",
timeout: +attrs.timeout || void 0
});
const payload = new import_form_data.default();
payload.append("file", res, {
filename: "file"
});
const { url } = await this.bot.request("POST", "/asset/create", payload, payload.getHeaders());
const payload = new FormData();
payload.append("file", new Blob([data], { type: headers.get("Content-Type") }), "file");
const { url } = await this.bot.request("POST", "/asset/create", payload);
return url;

@@ -960,3 +942,3 @@ } else {

} else {
data = data instanceof import_form_data2.default ? data : JSON.stringify(data);
data = data instanceof FormData ? data : JSON.stringify(data);
return (await this.http(method, path, { data, headers })).data;

@@ -963,0 +945,0 @@ }

{
"name": "@satorijs/adapter-kook",
"description": "KOOK (开黑啦) Adapter for Satorijs",
"version": "4.5.0-alpha.0",
"version": "4.5.0-alpha.1",
"main": "lib/index.js",

@@ -35,7 +35,4 @@ "typings": "lib/index.d.ts",

"peerDependencies": {
"@satorijs/satori": "^3.6.0-alpha.0"
},
"dependencies": {
"form-data": "^4.0.0"
"@satorijs/satori": "^3.6.0-alpha.2"
}
}
import { Bot, Context, Fragment, h, Quester, Schema, Universal } from '@satorijs/satori'
import { adaptGroup, adaptMessage, adaptUser, decodeGuildMember, decodeRole, encodeRole } from './utils'
import * as Kook from './types'
import FormData from 'form-data'
import { WsClient } from './ws'

@@ -6,0 +5,0 @@ import { HttpServer } from './http'

import { Context, h, MessageEncoder, Schema } from '@satorijs/satori'
import FormData from 'form-data'
import { KookBot } from './bot'
import * as Kook from './types'
import internal from 'stream'

@@ -57,18 +55,14 @@ export function isDirectChannel(channelId: string) {

const result = await this.bot.ctx.http.file(src, attrs)
payload.append('file', Buffer.from(result.data), {
filename: attrs.file || result.filename,
})
const { url } = await this.bot.request('POST', '/asset/create', payload, payload.getHeaders())
payload.append('file', new Blob([result.data], { type: result.mime }), attrs.file || result.filename)
const { url } = await this.bot.request('POST', '/asset/create', payload)
return url
} else if (!src.includes('kookapp.cn')) {
const res = await this.bot.ctx.http.get<internal.Readable>(src, {
const { data, headers } = await this.bot.ctx.http<ArrayBuffer>('GET', src, {
headers: { accept: type + '/*' },
responseType: 'stream',
responseType: 'arraybuffer',
timeout: +attrs.timeout || undefined,
})
const payload = new FormData()
payload.append('file', res, {
filename: 'file',
})
const { url } = await this.bot.request('POST', '/asset/create', payload, payload.getHeaders())
payload.append('file', new Blob([data], { type: headers.get('Content-Type') }), 'file')
const { url } = await this.bot.request('POST', '/asset/create', payload)
return url

@@ -75,0 +69,0 @@ } else {

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