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.2.0 to 0.3.0

7

dist/telegram/index.d.ts

@@ -97,2 +97,3 @@ /// <reference types="node" />

reply_markup?: Markup;
__filename?: string;
}) => Promise<Message>;

@@ -113,2 +114,3 @@ sendAudio: (props: {

reply_markup?: Markup;
__filename?: string;
}) => Promise<Message>;

@@ -127,2 +129,3 @@ sendDocument: (props: {

allow_sending_without_reply?: boolean;
__filename?: string;
}) => Promise<Message>;

@@ -144,2 +147,3 @@ sendVideo: (props: {

reply_markup?: Markup;
__filename?: string;
}) => Promise<Message>;

@@ -160,2 +164,3 @@ sendAnimation: (props: {

reply_markup?: Markup;
__filename?: string;
}) => Promise<Message>;

@@ -173,2 +178,3 @@ sendVoice: (props: {

reply_markup?: Markup;
__filename?: string;
}) => Promise<Message>;

@@ -185,2 +191,3 @@ sendVideoNote: (props: {

reply_markup?: Markup;
__filename?: string;
}) => Promise<Message>;

@@ -187,0 +194,0 @@ sendMediaGroup: (props: {

62

dist/telegram/index.js

@@ -25,2 +25,4 @@ "use strict";

const FormData = require("form-data");
const fs = require("fs");
const path = require("path");
const abstract_bot_1 = require("../abstract-bot");

@@ -32,21 +34,34 @@ const matcher_1 = require("./matcher");

super();
this.getApiEndpoint = (method) => {
return `${this.config.apiUrl}/bot${this.config.secret}/${method}`;
};
this.getApiEndpoint = (method) => `${this.config.apiUrl}/bot${this.config.secret}/${method}`;
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;
}
if (value === undefined) {
return form;
}
if (typeof value === 'string' && ['photo', 'video', 'audio', 'document'].includes(key) && !value.startsWith('http') && fs.existsSync(value)) {
value = fs.createReadStream(value);
}
if (value instanceof Buffer || value instanceof fs.ReadStream) {
let filename = 'filename'; // fallback
if ('__filename' in params) {
filename = params.__filename; // user-specified name
}
form.append(key, value);
else if (value instanceof fs.ReadStream && typeof value.path === 'string') {
filename = path.basename(value.path); // file stream path
}
form.append(key, value, { filename });
return form;
}
switch (typeof value) {
case 'number':
case 'boolean': {
value = String(value);
break;
}
case 'object': {
value = JSON.stringify(value);
break;
}
}
form.append(key, value);
return form;

@@ -56,10 +71,11 @@ }, new FormData());

this.request = (apiMethod, params = {}) => __awaiter(this, void 0, void 0, function* () {
var _a;
const url = this.getApiEndpoint(apiMethod);
const form = this.createFormDataFromParams(params);
const { data, status, statusText } = yield axios_1.default.post(this.getApiEndpoint(apiMethod), form, {
headers: form.getHeaders(),
});
if (status !== 200) {
throw new Error(`Error HTTP ${statusText}`);
const headers = form.getHeaders();
const { data, status, statusText } = yield axios_1.default.post(url, form, { headers });
if (data === null || data === void 0 ? void 0 : data.ok) {
return data.result;
}
return data.result;
throw new Error(`Error HTTP ${status} ${statusText}: ${(_a = data) === null || _a === void 0 ? void 0 : _a.description}`);
});

@@ -145,5 +161,5 @@ /**

if (!this.events[event]) {
this.events[event] = [];
this.events[event] = new Set();
}
this.events[event].push(listener);
this.events[event].add(listener);
return this;

@@ -150,0 +166,0 @@ };

{
"name": "@apidog/multibot-sdk-ts",
"version": "0.2.0",
"version": "0.3.0",
"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