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

@apidog/multibot-sdk-ts

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

@apidog/multibot-sdk-ts - npm Package Compare versions

Comparing version 0.0.8-2 to 0.0.8-3

5

dist/telegram/index.d.ts

@@ -42,5 +42,4 @@ /// <reference types="node" />

protected getApiEndpoint: (method: string) => string;
private readonly handleMethodsForFiles;
private handleParamsForFiles;
request: <T>(apiMethod: string, params?: Record<string, any>) => Promise<T>;
private createFormDataFromParams;
request: <T>(apiMethod: string, params?: Record<string, unknown>) => Promise<T>;
/**

@@ -47,0 +46,0 @@ * Public API

56

dist/telegram/index.js

@@ -15,3 +15,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const axios_1 = require("axios");

@@ -28,40 +27,25 @@ const FormData = require("form-data");

};
this.handleMethodsForFiles = {
'sendPhoto': 'photo',
'sendAudio': 'audio',
'sendDocument': 'document',
'sendSticker': 'sticker',
'sendVideo': 'video',
'sendAnimation': 'animation',
'sendVideoNote': 'video_note',
'sendVoice': 'voice',
'setChatPhoto': 'file',
/* 'uploadStickerFile',
'createNewStickerSet',
'addStickerToSet',*/
'sendMediaGroup': undefined
};
this.handleParamsForFiles = (data, name) => {
const entry = data[name];
if (typeof entry === 'string') {
if (fs.existsSync(entry)) {
data[name] = fs.createReadStream(entry);
this.createFormDataFromParams = (params) => {
return Object.entries(params).reduce((form, [key, value]) => {
if (value !== undefined) {
switch (typeof value) {
case 'number':
case 'boolean': {
value = String(value);
break;
}
case 'object': {
value = JSON.stringify(value);
break;
}
}
form.append(key, value);
}
}
return form;
}, new FormData());
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.request = (apiMethod, params = {}) => __awaiter(this, void 0, void 0, function* () {
if (apiMethod in this.handleMethodsForFiles) {
this.handleParamsForFiles(params, this.handleMethodsForFiles[apiMethod]);
}
const form = Object.keys(params).reduce((form, key) => {
if (params[key] !== undefined) {
const v = params[key];
form.append(key, typeof v === 'object' ? JSON.stringify(v) : v);
}
return form;
}, new FormData());
const endpoint = this.getApiEndpoint(apiMethod);
const { data, status, statusText } = yield axios_1.default.post(endpoint, form, {
headers: Object.assign({}, (form.getHeaders()))
const form = this.createFormDataFromParams(params);
const { data, status, statusText } = yield axios_1.default.post(this.getApiEndpoint(apiMethod), form, {
headers: form.getHeaders(),
});

@@ -68,0 +52,0 @@ if (status !== 200) {

{
"name": "@apidog/multibot-sdk-ts",
"version": "0.0.8-2",
"version": "0.0.8-3",
"description": "Telegram and VK bot SDK for TypeScript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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