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.18 to 0.0.19

5

dist/bot.d.ts
import { Context, ContextType, MaybeArray, UpdateName } from "@gramio/contexts";
import type { APIMethodParams, APIMethods, TelegramUser } from "@gramio/types";
import { Plugin } from "./plugin";
import { BotOptions, DeriveDefinitions, ErrorDefinitions, Handler, Hooks } from "./types";
import { BotOptions, DeriveDefinitions, ErrorDefinitions, Handler, Hooks, MaybePromise } from "./types";
import { Updates } from "./updates";

@@ -11,2 +11,3 @@ export declare class Bot<Errors extends ErrorDefinitions = {}, Derives extends DeriveDefinitions = DeriveDefinitions> {

readonly api: APIMethods;
private lazyloadPlugins;
private dependencies;

@@ -75,3 +76,3 @@ private errorsDefinitions;

use(handler: Handler<Context<typeof this> & Derives["global"]>): this;
extend<NewPlugin extends Plugin>(plugin: NewPlugin): Bot<Errors & NewPlugin["Errors"], Derives & NewPlugin["Derives"]>;
extend<NewPlugin extends Plugin>(plugin: MaybePromise<NewPlugin>): Bot<Errors & NewPlugin["Errors"], Derives & NewPlugin["Derives"]>;
start({ webhook, dropPendingUpdates, allowedUpdates, }?: {

@@ -78,0 +79,0 @@ webhook?: Omit<APIMethodParams<"setWebhook">, "drop_pending_updates" | "allowed_updates">;

19

dist/bot.js

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

const format_1 = require("@gramio/format");
const form_data_encoder_1 = require("form-data-encoder");
const inspectable_1 = require("inspectable");

@@ -68,2 +67,3 @@ const undici_1 = require("undici");

});
lazyloadPlugins = [];
dependencies = [];

@@ -98,2 +98,4 @@ errorsDefinitions = {

constructor(token, options) {
if (!token || typeof token !== "string")
throw new Error(`Token is ${typeof token} but it should be a string!`);
this.options = { ...options, token };

@@ -119,3 +121,2 @@ }

method: "POST",
duplex: "half",
};

@@ -133,5 +134,3 @@ const context = await this.runHooks("preRequest",

const formData = await (0, files_1.convertJsonToFormData)(method, params);
const encoder = new form_data_encoder_1.FormDataEncoder(formData);
reqOptions.body = encoder.encode();
reqOptions.headers = encoder.headers;
reqOptions.body = formData;
}

@@ -144,4 +143,4 @@ else {

}
const response = await (0, undici_1.fetch)(url, reqOptions);
const data = (await response.json());
const response = await (0, undici_1.request)(url, reqOptions);
const data = (await response.body.json());
if (!data.ok)

@@ -232,2 +231,6 @@ throw new errors_1.TelegramError(data, method, params);

extend(plugin) {
if (plugin instanceof Promise) {
this.lazyloadPlugins.push(plugin);
return this;
}
if (plugin.dependencies.some((dep) => !this.dependencies.includes(dep)))

@@ -252,3 +255,3 @@ throw new Error(`The «${plugin.name}» plugin needs dependencies registered before: ${plugin.dependencies

async start({ webhook, dropPendingUpdates, allowedUpdates, } = {}) {
//TODO: maybe it useless??
await Promise.all(this.lazyloadPlugins.map(async (plugin) => this.extend(await plugin)));
this.info = await this.api.getMe();

@@ -255,0 +258,0 @@ if (!webhook) {

import { TelegramUpdate } from "@gramio/types";
import { MaybePromise } from "../types";
export interface FrameworkHandler {
update: TelegramUpdate;
update: MaybePromise<TelegramUpdate>;
header?: string;

@@ -16,2 +17,10 @@ }

};
hono: (c: any) => {
update: any;
header: any;
};
express: (req: any) => {
update: any;
header: any;
};
};

@@ -14,2 +14,10 @@ "use strict";

}),
hono: (c) => ({
update: c.req.json(),
header: c.req.header(SECRET_TOKEN_HEADER)
}),
express: (req) => ({
update: req.body,
header: req.header(SECRET_TOKEN_HEADER)
})
};

@@ -9,5 +9,5 @@ "use strict";

const { update } = frameworkAdapter(...args);
await bot.updates.handleUpdate(update);
await bot.updates.handleUpdate(await update);
};
}
exports.webhookHandler = webhookHandler;
{
"name": "gramio",
"version": "0.0.18",
"description": "Powerful Telegram Bot API framework",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"keywords": [
"telegram",
"telegram-bot",
"telegram-bot-api",
"bot",
"framework",
"types",
"client",
"webhook",
"long-polling"
],
"scripts": {
"type": "tsc --noEmit",
"lint": "bun check ./src",
"lint:fix": "bun lint --apply",
"prepublishOnly": "tsc && bunx tsc-alias"
},
"author": "kravets",
"license": "ISC",
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@gramio/types": "^7.1.4",
"@types/node": "^20.11.20",
"typescript": "^5.3.3"
},
"dependencies": {
"@gramio/contexts": "^0.0.6",
"@gramio/files": "^0.0.3",
"@gramio/format": "^0.0.8",
"@gramio/keyboards": "^0.2.0",
"form-data-encoder": "^4.0.2",
"inspectable": "^3.0.0",
"middleware-io": "^2.8.1",
"undici": "^6.6.2"
},
"files": [
"dist"
]
"name": "gramio",
"version": "0.0.19",
"description": "Powerful Telegram Bot API framework",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"keywords": [
"telegram",
"telegram-bot",
"telegram-bot-api",
"bot",
"framework",
"types",
"client",
"webhook",
"long-polling"
],
"scripts": {
"type": "tsc --noEmit",
"lint": "bun check ./src",
"lint:fix": "bun lint --apply",
"prepublishOnly": "tsc && bunx tsc-alias"
},
"author": "kravets",
"license": "ISC",
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@gramio/types": "^7.1.6",
"@types/node": "^20.11.24",
"typescript": "^5.3.3"
},
"dependencies": {
"@gramio/contexts": "^0.0.7",
"@gramio/files": "^0.0.3",
"@gramio/format": "^0.0.8",
"@gramio/keyboards": "^0.2.0",
"inspectable": "^3.0.0",
"middleware-io": "^2.8.1",
"undici": "^6.6.2"
},
"files": [
"dist"
]
}
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