New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gramio

Package Overview
Dependencies
Maintainers
1
Versions
59
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.22 to 0.0.23

9

dist/bot.d.ts

@@ -0,3 +1,4 @@

import { CallbackData } from "@gramio/callback-data";
import type { Context, ContextType, MaybeArray, UpdateName } from "@gramio/contexts";
import type { APIMethodParams, APIMethods, SetMyCommandsParams, TelegramBotCommand, TelegramUser } from "@gramio/types";
import type { APIMethodParams, APIMethods, SetMyCommandsParams, TelegramBotCommand, TelegramReactionTypeEmojiEmoji, TelegramUser } from "@gramio/types";
import { Plugin } from "./plugin";

@@ -78,3 +79,7 @@ import type { BotOptions, DeriveDefinitions, ErrorDefinitions, Handler, Hooks, MaybePromise } from "./types";

use(handler: Handler<Context<typeof this> & Derives["global"]>): this;
extend<NewPlugin extends Plugin>(plugin: MaybePromise<NewPlugin>): Bot<Errors & NewPlugin["Errors"], Derives & NewPlugin["Derives"]>;
extend<NewPlugin extends Plugin<any, any>>(plugin: MaybePromise<NewPlugin>): Bot<Errors & NewPlugin["Errors"], Derives & NewPlugin["Derives"]>;
reaction(trigger: MaybeArray<TelegramReactionTypeEmojiEmoji>, handler: (context: ContextType<typeof this, "message_reaction"> & Derives["global"] & Derives["message_reaction"]) => unknown): this;
callbackQuery<Trigger extends CallbackData | string | RegExp>(trigger: Trigger, handler: (context: Omit<ContextType<typeof this, "callback_query">, "data"> & Derives["global"] & Derives["callback_query"] & {
data: Trigger extends CallbackData ? ReturnType<Trigger["unpack"]> : RegExpMatchArray | null;
}) => unknown): this;
hears<Ctx = ContextType<typeof this, "message"> & Derives["global"] & Derives["message"]>(trigger: RegExp | string | ((context: Ctx) => boolean), handler: (context: Ctx & {

@@ -81,0 +86,0 @@ args: RegExpMatchArray | null;

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

exports.Bot = void 0;
const callback_data_1 = require("@gramio/callback-data");
const files_1 = require("@gramio/files");

@@ -285,2 +286,41 @@ const format_1 = require("@gramio/format");

}
reaction(trigger, handler) {
const reactions = Array.isArray(trigger) ? trigger : [trigger];
return this.on("message_reaction", (context, next) => {
const newReactions = [];
for (const reaction of context.newReactions) {
if (reaction.type !== "emoji")
continue;
const foundIndex = context.oldReactions.findIndex((oldReaction) => oldReaction.type === "emoji" &&
oldReaction.emoji === reaction.emoji);
if (foundIndex === -1) {
newReactions.push(reaction);
}
else {
// TODO: REFACTOR
context.oldReactions.splice(foundIndex, 1);
}
}
if (!newReactions.some((x) => x.type === "emoji" && reactions.includes(x.emoji)))
return next();
return handler(context);
});
}
callbackQuery(trigger, handler) {
return this.on("callback_query", (context, next) => {
if (!context.data)
return next();
if (typeof trigger === "string" && context.data !== trigger)
return next();
if (trigger instanceof callback_data_1.CallbackData &&
!trigger.regexp().test(context.data))
return next();
if (trigger instanceof RegExp && !trigger.test(context.data))
return next();
// @ts-expect-error
context.data = trigger.unpack(context.data);
//@ts-expect-error
return handler(context);
});
}
hears(trigger, handler) {

@@ -287,0 +327,0 @@ return this.on("message", (context, next) => {

@@ -11,1 +11,2 @@ export * from "./bot";

export * from "@gramio/format";
export * from "@gramio/callback-data";

@@ -29,1 +29,2 @@ "use strict";

__exportStar(require("@gramio/format"), exports);
__exportStar(require("@gramio/callback-data"), exports);
{
"name": "gramio",
"version": "0.0.22",
"version": "0.0.23",
"description": "Powerful Telegram Bot API framework",

@@ -27,15 +27,16 @@ "main": "./dist/index.js",

"devDependencies": {
"@biomejs/biome": "1.6.0",
"@biomejs/biome": "1.6.2",
"@gramio/types": "^7.1.7",
"@types/node": "^20.11.25",
"typescript": "^5.4.2"
"@types/node": "^20.11.30",
"typescript": "^5.4.3"
},
"dependencies": {
"@gramio/callback-data": "^0.0.1",
"@gramio/contexts": "^0.0.7",
"@gramio/files": "^0.0.3",
"@gramio/format": "^0.0.8",
"@gramio/keyboards": "^0.2.0",
"@gramio/keyboards": "^0.2.2",
"inspectable": "^3.0.0",
"middleware-io": "^2.8.1",
"undici": "^6.7.1"
"undici": "^6.10.1"
},

@@ -42,0 +43,0 @@ "files": [

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