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

gramio

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gramio - npm Package Compare versions

Comparing version 0.0.36 to 0.0.37

8

dist/bot.d.ts

@@ -47,4 +47,8 @@ import { CallbackData } from "@gramio/callback-data";

private hooks;
/** Create new Bot instance */
constructor(token: string, options?: Omit<BotOptions, "token">);
constructor(token: string, options?: Omit<BotOptions, "token" | "api"> & {
api?: Partial<BotOptions["api"]>;
});
constructor(options: Omit<BotOptions, "api"> & {
api?: Partial<BotOptions["api"]>;
});
private runHooks;

@@ -51,0 +55,0 @@ private runImmutableHooks;

@@ -84,3 +84,3 @@ "use strict";

/** Options provided to instance */
options = {};
options;
/** Bot data (filled in when calling bot.init/bot.start) */

@@ -129,7 +129,13 @@ info;

};
/** Create new Bot instance */
constructor(token, options) {
constructor(tokenOrOptions, options) {
const token = typeof tokenOrOptions === "string"
? tokenOrOptions
: tokenOrOptions?.token;
if (!token || typeof token !== "string")
throw new Error(`Token is ${typeof token} but it should be a string!`);
this.options = { ...options, token };
this.options = {
...(typeof tokenOrOptions === "object" ? tokenOrOptions : options),
token,
api: { ...options?.api, baseURL: "https://api.telegram.org/bot" },
};
if (!(options?.plugins &&

@@ -163,3 +169,3 @@ "format" in options.plugins &&

async _callApi(method, params = {}) {
const url = `https://api.telegram.org/bot${this.options.token}/${method}`;
const url = `${this.options.api.baseURL}${this.options.token}/${method}`;
const reqOptions = {

@@ -220,3 +226,3 @@ method: "POST",

const file = await this.api.getFile({ file_id: fileId });
const url = `https://api.telegram.org/file/bot${this.options.token}/${file.file_path}`;
const url = `${this.options.api.baseURL.replace("/bot", "/file/bot")}${this.options.token}/${file.file_path}`;
const res = await (0, undici_1.request)(url);

@@ -223,0 +229,0 @@ const buffer = await res.body.arrayBuffer();

@@ -9,6 +9,22 @@ import type { Context, UpdateName } from "@gramio/contexts";

export interface BotOptions {
token?: string;
/** Bot token */
token: string;
/** List of plugins enabled by default */
plugins?: {
/** Pass `false` to disable plugin. @default true */
format?: boolean;
};
/** Options to configure how to send requests to the Telegram Bot API */
api: {
/** URL which will be used to send requests to. @default "https://api.telegram.org/bot" */
baseURL: string;
/**
* Should we send requests to `test` data center?
* The test environment is completely separate from the main environment, so you will need to create a new user account and a new bot with `@BotFather`.
*
* [Documentation](https://core.telegram.org/bots/webapps#using-bots-in-the-test-environment)
* @default false
* */
useTest?: boolean;
};
}

@@ -15,0 +31,0 @@ /**

{
"name": "gramio",
"version": "0.0.36",
"version": "0.0.37",
"description": "Powerful Telegram Bot API framework",

@@ -37,4 +37,4 @@ "main": "./dist/index.js",

"@gramio/files": "^0.0.8",
"@gramio/format": "^0.1.1",
"@gramio/keyboards": "^0.3.1",
"@gramio/format": "^0.1.2",
"@gramio/keyboards": "^0.3.2",
"@gramio/types": "^7.3.4",

@@ -41,0 +41,0 @@ "inspectable": "^3.0.1",

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