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

node-telegram-keyboard-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-telegram-keyboard-wrapper - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

2

lib/ForceReply.js

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

force_reply: true,
selective
selective,
};

@@ -10,0 +10,0 @@ }

@@ -10,8 +10,3 @@ import InlineKeyboardButton from "./InlineKeyboardButton";

inline_keyboard: {
[x: string]: string | boolean | {} | {
url: string;
forward_text?: string;
bot_username?: string;
request_write_access?: string;
};
[x: string]: any;
text: string;

@@ -18,0 +13,0 @@ }[][];

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

return {
inline_keyboard: this.map((row) => row.getJSON())
inline_keyboard: this.map((row) => row.getJSON()),
};

@@ -22,3 +22,3 @@ }

clone() {
return new InlineKeyboard(...this.map(row => row.clone()));
return new InlineKeyboard(...this.map((row) => row.clone()));
}

@@ -25,0 +25,0 @@ }

interface InlineKeyboardSupportedProperties {
"url": string;
"login_url": {
url: string;
login_url: {
url: string;

@@ -9,14 +9,17 @@ forward_text?: string;

};
"callback_data": string;
"switch_inline_query": string;
"switch_inline_query_current_chat": string;
"callback_game": {};
"pay": boolean;
callback_data: string;
switch_inline_query: string;
switch_inline_query_current_chat: string;
callback_game: {};
pay: boolean;
web_app: {
url: string;
};
}
export default class InlineKeyboardButton<P extends keyof InlineKeyboardSupportedProperties = keyof InlineKeyboardSupportedProperties> {
export default class InlineKeyboardButton<P extends keyof InlineKeyboardSupportedProperties = any> {
readonly text: string;
readonly exclusiveKey: keyof InlineKeyboardSupportedProperties;
readonly exclusiveKey: P;
readonly exclusiveValue: InlineKeyboardSupportedProperties[P];
constructor(text: string, exclusiveKey: P, exclusiveValue: InlineKeyboardSupportedProperties[P]);
clone(): InlineKeyboardButton<keyof InlineKeyboardSupportedProperties>;
clone(): InlineKeyboardButton<P>;
getJSON(): {

@@ -23,0 +26,0 @@ [x: string]: string | InlineKeyboardSupportedProperties[P];

@@ -14,3 +14,5 @@ "use strict";

clone() {
const exclusiveValue = typeof this.exclusiveValue === "object" ? Object.assign({}, this.exclusiveValue) : this.exclusiveValue;
const exclusiveValue = typeof this.exclusiveValue === "object"
? Object.assign({}, this.exclusiveValue)
: this.exclusiveValue;
return new InlineKeyboardButton(this.text, this.exclusiveKey, exclusiveValue);

@@ -21,3 +23,3 @@ }

text: this.text,
[this.exclusiveKey]: this.exclusiveValue
[this.exclusiveKey]: this.exclusiveValue,
};

@@ -24,0 +26,0 @@ }

@@ -1,8 +0,10 @@

interface KeyboardButtonPollType {
type: "quiz" | "regular";
}
interface KeyboardButtonOptions {
request_contact?: boolean;
request_location?: boolean;
request_poll?: KeyboardButtonPollType;
request_poll?: {
type: "quiz" | "regular";
};
web_app?: {
url: string;
};
}

@@ -17,3 +19,8 @@ export default class KeyboardButton {

request_location?: boolean;
request_poll?: KeyboardButtonPollType;
request_poll?: {
type: "quiz" | "regular";
};
web_app?: {
url: string;
};
text: string;

@@ -20,0 +27,0 @@ };

import KeyboardButton from "./KeyboardButton";
import Row from "./Row";
interface ReplyKeyboardMarkupOptions {
keyboard: Array<Array<any>>;
keyboard: Array<Array<KeyboardButton>>;
resize_keyboard?: boolean;

@@ -6,0 +6,0 @@ one_time_keyboard?: boolean;

@@ -1,13 +0,29 @@

import InlineKeyboardButton from "./InlineKeyboardButton";
import KeyboardButton from "./KeyboardButton";
declare type RowTypes = InlineKeyboardButton | KeyboardButton;
export default class Row<R extends RowTypes> extends Array<R> {
import type InlineKeyboardButton from "./InlineKeyboardButton";
import type KeyboardButton from "./KeyboardButton";
declare type RowButtonsTypes = InlineKeyboardButton | KeyboardButton;
/**
* To allow InlineKeyboardButton to have a type relation between
* `exclusiveKey` and `exclusiveValue`, we needed to equip it with
* a Generic. However, this creates a problem with Row that clashes
* with Typescript limits.
*
* `R` can be any subtype of `InlineKeyboardButton | KeyboardButton`,
* so like `InlineKeyboardButton<"pay">`.
*
* If Row is **NOT** equipped with a generic "R" on instance creation
* (like `new Row<InlineKeyboardButton>()`), and the first button is
* e.g. of type `InlineKeyboardButton<"pay">`, Row will automatically
* assume to be a `Row<InlineKeyboardButton<"pay">>`, requiring so
* all the buttons (objects) in it to be of the same type, and
* disallowing other buttons of the same "supertype"
* (InlineKeyboardButton), like `InlineKeyboardButton<"callback_data">`.
*
* Typescript seems doesn't provide a way to say that a Generic should
* be of a supertype
* (like, `InlineKeyboardButton` instead of `InlineKeyboardButton<"pay">`)
*/
export default class Row<R extends RowButtonsTypes> extends Array<R> {
clone(): Row<R>;
getJSON(): {
[x: string]: string | boolean | {} | {
url: string;
forward_text?: string;
bot_username?: string;
request_write_access?: string;
};
[x: string]: any;
text: string;

@@ -14,0 +30,0 @@ }[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* To allow InlineKeyboardButton to have a type relation between
* `exclusiveKey` and `exclusiveValue`, we needed to equip it with
* a Generic. However, this creates a problem with Row that clashes
* with Typescript limits.
*
* `R` can be any subtype of `InlineKeyboardButton | KeyboardButton`,
* so like `InlineKeyboardButton<"pay">`.
*
* If Row is **NOT** equipped with a generic "R" on instance creation
* (like `new Row<InlineKeyboardButton>()`), and the first button is
* e.g. of type `InlineKeyboardButton<"pay">`, Row will automatically
* assume to be a `Row<InlineKeyboardButton<"pay">>`, requiring so
* all the buttons (objects) in it to be of the same type, and
* disallowing other buttons of the same "supertype"
* (InlineKeyboardButton), like `InlineKeyboardButton<"callback_data">`.
*
* Typescript seems doesn't provide a way to say that a Generic should
* be of a supertype
* (like, `InlineKeyboardButton` instead of `InlineKeyboardButton<"pay">`)
*/
class Row extends Array {

@@ -4,0 +25,0 @@ clone() {

{
"name": "node-telegram-keyboard-wrapper",
"version": "3.0.0",
"version": "3.1.0",
"description": "A support to create keyboards in Telegram via bots",
"main": "lib/index.js",
"scripts": {
"build": "npm run build:src",
"build": "rm -rf lib && npm run build:src",
"test": "npm run build:spec && npx jasmine",

@@ -31,8 +31,9 @@ "example": "cd examples && npm run example",

"devDependencies": {
"@types/jasmine": "^3.6.5",
"@types/node-telegram-bot-api": "^0.51.1",
"jasmine": "^3.6.4",
"node-telegram-bot-api": "^0.51.0",
"@types/jasmine": "^4.0.3",
"@types/node-telegram-bot-api": "^0.56.2",
"jasmine": "^4.1.0",
"node-telegram-bot-api": "^0.56.0",
"rimraf": "^3.0.2",
"typescript": "^4.2.3"
"typescript": "^4.6.3",
"prettier": "^2.6.2"
},

@@ -39,0 +40,0 @@ "files": [

# Node telegram keyboard wrapper
This libray aims to provide a set of classes to improve the creation of keyboards and setup for force-reply in Telegram bots.
This library aims to provide a set of classes to improve the creation of keyboards and setup for force-reply in Telegram bots.
Built upon [yagop's node-telegram-bot-api](https://github.com/yagop/node-telegram-bot-api), it can work with any Node.js Bot Api wrapper, as it exports Telegram Bot APIs-compliant JSON structures.
> ⚠ v3.0.0 of this library is a major rewrite that is not retro-compatible. Now it never exports an object with `reply_markup` but just its content, which varies from keyboard to keyboard. ⚠
> ⚠ v3.0.0 of this library is a major rewrite that is not retro-compatible. It doesn't export anymore an object with `reply_markup`. From now on, it will export just the content for `reply_markup`, which will vary from keyboard to keyboard. ⚠

@@ -94,3 +94,3 @@ ---

Use this class to define a row to which button can be appended to.
Use this class to define a row to which buttons can be appended to.

@@ -147,3 +147,3 @@ Push this class into an InlineKeyboard or a ReplyKeyboard to let them create the structure.

Use this method method to export the structure to be sent to `reply_markup`.
Use this method to export the structure to be sent to `reply_markup`.

@@ -230,3 +230,3 @@ **Throws if no rows got pushed in the object**.

Use this class to create a new keyboard that is going to showup under the text area in your Telegram client.
Use this class to create a new keyboard that is going to show up under the text area in your Telegram client.

@@ -250,3 +250,3 @@ This class extends the native Array interface, therefore every operation you can perform on Arrays is allowed to be performed on this.

Use this method method to export the structure to be sent to `reply_markup` for opening the keyboard.
Use this method to export the structure to be sent to `reply_markup` for opening the keyboard.

@@ -268,3 +268,3 @@ **Throws if no rows got pushed in the object**.

This list might get outdated. The arguments are used as they are passed.
Refer to [ReplyKeyboardMarkup](https://core.telegram.org/bots/api#replykeyboardmarkup) for, eventually, the complete list.
Refer to [ReplyKeyboardMarkup](https://core.telegram.org/bots/api#replykeyboardmarkup) for the complete list, eventually.

@@ -284,3 +284,3 @@ <br />

Use this method method to export the structure to be sent to `reply_markup` for closing definitely the keyboard.
Use this method to export the structure to be sent to `reply_markup` for closing definitely the keyboard.

@@ -287,0 +287,0 @@ **Arguments**:

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