@gramio/keyboards
Advanced tools
Comparing version 0.1.6 to 0.2.0
@@ -35,3 +35,4 @@ import { TelegramForceReply } from "@gramio/types"; | ||
*/ | ||
build(): TelegramForceReply; | ||
toJSON(): TelegramForceReply; | ||
} |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ForceReplyKeyboard = void 0; | ||
const inspectable_1 = require("inspectable"); | ||
/** | ||
@@ -18,3 +11,3 @@ * **ForceReply** builder | ||
*/ | ||
let ForceReplyKeyboard = class ForceReplyKeyboard { | ||
class ForceReplyKeyboard { | ||
options = { | ||
@@ -51,2 +44,5 @@ isSelective: false, | ||
*/ | ||
build() { | ||
return this.toJSON(); | ||
} | ||
toJSON() { | ||
@@ -59,8 +55,3 @@ return { | ||
} | ||
}; | ||
} | ||
exports.ForceReplyKeyboard = ForceReplyKeyboard; | ||
exports.ForceReplyKeyboard = ForceReplyKeyboard = __decorate([ | ||
(0, inspectable_1.Inspectable)({ | ||
serialize: (keyboard) => keyboard.toJSON(), | ||
}) | ||
], ForceReplyKeyboard); |
@@ -1,2 +0,1 @@ | ||
import "reflect-metadata"; | ||
export * from "./keyboard"; | ||
@@ -3,0 +2,0 @@ export * from "./inline-keyboard"; |
@@ -17,3 +17,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("reflect-metadata"); | ||
// INFO: Temp polyfill, more info https://github.com/microsoft/TypeScript/issues/55453#issuecomment-1687496648 | ||
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | ||
Symbol.metadata ??= Symbol("Symbol.metadata"); | ||
__exportStar(require("./keyboard"), exports); | ||
@@ -20,0 +22,0 @@ __exportStar(require("./inline-keyboard"), exports); |
@@ -189,4 +189,5 @@ import { TelegramCallbackGame, TelegramInlineKeyboardButton, TelegramInlineKeyboardMarkup, TelegramLoginUrl, TelegramSwitchInlineQueryChosenChat } from "@gramio/types"; | ||
*/ | ||
build(): TelegramInlineKeyboardMarkupFix; | ||
toJSON(): TelegramInlineKeyboardMarkupFix; | ||
} | ||
export {}; |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var InlineKeyboard_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InlineKeyboard = void 0; | ||
const inspectable_1 = require("inspectable"); | ||
const base_keyboard_constructor_1 = require("./base-keyboard-constructor"); | ||
@@ -20,3 +12,3 @@ /** | ||
*/ | ||
let InlineKeyboard = InlineKeyboard_1 = class InlineKeyboard extends base_keyboard_constructor_1.BaseKeyboardConstructor { | ||
class InlineKeyboard extends base_keyboard_constructor_1.BaseKeyboardConstructor { | ||
/** | ||
@@ -34,3 +26,3 @@ * Text button with data to be sent in a [callback query](https://core.telegram.org/bots/api/#callbackquery) to the bot when button is pressed, 1-64 bytes | ||
text(text, payload) { | ||
return this.add(InlineKeyboard_1.text(text, payload)); | ||
return this.add(InlineKeyboard.text(text, payload)); | ||
} | ||
@@ -54,3 +46,3 @@ /** | ||
url(text, url) { | ||
return this.add(InlineKeyboard_1.url(text, url)); | ||
return this.add(InlineKeyboard.url(text, url)); | ||
} | ||
@@ -74,3 +66,3 @@ /** | ||
webApp(text, url) { | ||
return this.add(InlineKeyboard_1.webApp(text, url)); | ||
return this.add(InlineKeyboard.webApp(text, url)); | ||
} | ||
@@ -99,3 +91,3 @@ /** | ||
login(text, url) { | ||
return this.add(InlineKeyboard_1.login(text, url)); | ||
return this.add(InlineKeyboard.login(text, url)); | ||
} | ||
@@ -123,3 +115,3 @@ /** | ||
throw new Error("This type of button must always be the first button in the first row and can only be used in invoice messages."); | ||
return this.add(InlineKeyboard_1.pay(text)); | ||
return this.add(InlineKeyboard.pay(text)); | ||
} | ||
@@ -149,3 +141,3 @@ /** | ||
switchToChat(text, query = "") { | ||
return this.add(InlineKeyboard_1.switchToChat(text, query)); | ||
return this.add(InlineKeyboard.switchToChat(text, query)); | ||
} | ||
@@ -181,3 +173,3 @@ /** | ||
switchToChosenChat(text, query = "") { | ||
return this.add(InlineKeyboard_1.switchToChosenChat(text, query)); | ||
return this.add(InlineKeyboard.switchToChosenChat(text, query)); | ||
} | ||
@@ -205,3 +197,3 @@ /** | ||
switchToCurrentChat(text, query = "") { | ||
return this.add(InlineKeyboard_1.switchToCurrentChat(text, query)); | ||
return this.add(InlineKeyboard.switchToCurrentChat(text, query)); | ||
} | ||
@@ -230,3 +222,3 @@ /** | ||
throw new Error("This type of button must always be the first button in the first row."); | ||
return this.add(InlineKeyboard_1.game(text, gameOptions)); | ||
return this.add(InlineKeyboard.game(text, gameOptions)); | ||
} | ||
@@ -273,2 +265,5 @@ /** | ||
*/ | ||
build() { | ||
return this.toJSON(); | ||
} | ||
toJSON() { | ||
@@ -280,8 +275,3 @@ return { | ||
} | ||
}; | ||
} | ||
exports.InlineKeyboard = InlineKeyboard; | ||
exports.InlineKeyboard = InlineKeyboard = InlineKeyboard_1 = __decorate([ | ||
(0, inspectable_1.Inspectable)({ | ||
serialize: (keyboard) => keyboard.toJSON(), | ||
}) | ||
], InlineKeyboard); |
@@ -178,5 +178,6 @@ import type { TelegramKeyboardButton, TelegramKeyboardButtonPollType, TelegramKeyboardButtonRequestChat, TelegramKeyboardButtonRequestUsers, TelegramReplyKeyboardMarkup } from "@gramio/types"; | ||
/** | ||
* Return {@link TelegramReplyKeyboardMarkup} as JSON | ||
* Return {@link TelegramReplyKeyboardMarkup} as object | ||
*/ | ||
build(): TelegramReplyKeyboardMarkup; | ||
toJSON(): TelegramReplyKeyboardMarkup; | ||
} |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var Keyboard_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Keyboard = void 0; | ||
const inspectable_1 = require("inspectable"); | ||
const base_keyboard_constructor_1 = require("./base-keyboard-constructor"); | ||
@@ -20,3 +12,3 @@ /** | ||
*/ | ||
let Keyboard = Keyboard_1 = class Keyboard extends base_keyboard_constructor_1.BaseKeyboardConstructor { | ||
class Keyboard extends base_keyboard_constructor_1.BaseKeyboardConstructor { | ||
options = { | ||
@@ -37,3 +29,3 @@ isOneTime: false, | ||
text(text) { | ||
return this.add(Keyboard_1.text(text)); | ||
return this.add(Keyboard.text(text)); | ||
} | ||
@@ -56,3 +48,3 @@ /** | ||
requestUsers(text, requestId, options = {}) { | ||
return this.add(Keyboard_1.requestUsers(text, requestId, options)); | ||
return this.add(Keyboard.requestUsers(text, requestId, options)); | ||
} | ||
@@ -81,3 +73,3 @@ /** | ||
requestChat(text, requestId, options) { | ||
return this.add(Keyboard_1.requestChat(text, requestId, options)); | ||
return this.add(Keyboard.requestChat(text, requestId, options)); | ||
} | ||
@@ -106,3 +98,3 @@ /** | ||
requestContact(text) { | ||
return this.add(Keyboard_1.requestContact(text)); | ||
return this.add(Keyboard.requestContact(text)); | ||
} | ||
@@ -126,3 +118,3 @@ /** | ||
requestLocation(text) { | ||
return this.add(Keyboard_1.requestLocation(text)); | ||
return this.add(Keyboard.requestLocation(text)); | ||
} | ||
@@ -148,3 +140,3 @@ /** | ||
requestPoll(text, type) { | ||
return this.add(Keyboard_1.requestPoll(text, type)); | ||
return this.add(Keyboard.requestPoll(text, type)); | ||
} | ||
@@ -172,3 +164,3 @@ /** | ||
webApp(text, url) { | ||
return this.add(Keyboard_1.webApp(text, url)); | ||
return this.add(Keyboard.webApp(text, url)); | ||
} | ||
@@ -271,4 +263,7 @@ /** | ||
/** | ||
* Return {@link TelegramReplyKeyboardMarkup} as JSON | ||
* Return {@link TelegramReplyKeyboardMarkup} as object | ||
*/ | ||
build() { | ||
return this.toJSON(); | ||
} | ||
toJSON() { | ||
@@ -284,8 +279,3 @@ return { | ||
} | ||
}; | ||
} | ||
exports.Keyboard = Keyboard; | ||
exports.Keyboard = Keyboard = Keyboard_1 = __decorate([ | ||
(0, inspectable_1.Inspectable)({ | ||
serialize: (keyboard) => keyboard.toJSON(), | ||
}) | ||
], Keyboard); |
@@ -25,5 +25,6 @@ import { TelegramReplyKeyboardRemove } from "@gramio/types"; | ||
/** | ||
* Return {@link TelegramReplyKeyboardRemove} as JSON | ||
* Return {@link TelegramReplyKeyboardRemove} as object | ||
*/ | ||
build(): TelegramReplyKeyboardRemove; | ||
toJSON(): TelegramReplyKeyboardRemove; | ||
} |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RemoveKeyboard = void 0; | ||
const inspectable_1 = require("inspectable"); | ||
/** | ||
@@ -18,3 +11,3 @@ * **ReplyKeyboardRemove** builder | ||
*/ | ||
let RemoveKeyboard = class RemoveKeyboard { | ||
class RemoveKeyboard { | ||
options = { | ||
@@ -38,4 +31,7 @@ isSelective: false, | ||
/** | ||
* Return {@link TelegramReplyKeyboardRemove} as JSON | ||
* Return {@link TelegramReplyKeyboardRemove} as object | ||
*/ | ||
build() { | ||
return this.toJSON(); | ||
} | ||
toJSON() { | ||
@@ -47,8 +43,3 @@ return { | ||
} | ||
}; | ||
} | ||
exports.RemoveKeyboard = RemoveKeyboard; | ||
exports.RemoveKeyboard = RemoveKeyboard = __decorate([ | ||
(0, inspectable_1.Inspectable)({ | ||
serialize: (keyboard) => keyboard.toJSON(), | ||
}) | ||
], RemoveKeyboard); |
{ | ||
"name": "@gramio/keyboards", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Framework-agnostic Telegram bot keyboard builder with many cool features!", | ||
"main": "dist/index.js", | ||
"homepage": "https://github.com/gramiojs/types", | ||
"type": "commonjs", | ||
"homepage": "https://github.com/gramiojs/keyboards", | ||
"readme": "https://gramio.netlify.app/keyboards/overview.html", | ||
@@ -19,16 +20,12 @@ "scripts": { | ||
"telegram-bot-api", | ||
"grammy" | ||
"grammy", | ||
"telegraf", | ||
"node-telegram-bot-api" | ||
], | ||
"devDependencies": { | ||
"@gramio/types": "^7.0.9", | ||
"@types/bun": "^1.0.4", | ||
"grammy": "^1.20.3", | ||
"inspectable": "^2.1.0", | ||
"reflect-metadata": "^0.2.1" | ||
"@types/bun": "^1.0.7", | ||
"typescript": "^5.3.3" | ||
}, | ||
"peerDependencies": { | ||
"@gramio/types": "^7.0.9", | ||
"inspectable": "^2.1.0", | ||
"typescript": "^5.3.3", | ||
"reflect-metadata": "^0.2.1" | ||
"dependencies": { | ||
"@gramio/types": "^7.1.0" | ||
}, | ||
@@ -35,0 +32,0 @@ "files": [ |
@@ -24,3 +24,3 @@ # @gramio/keyboards | ||
.text("second row") | ||
.toJSON(); // NOTE: In gramio, you don't have to use the ".toJSON" method | ||
.build(); // NOTE: In GramIO, you don't have to use the ".build" method | ||
``` | ||
@@ -32,4 +32,20 @@ | ||
GramIO is not ready yet... | ||
```ts | ||
import { Bot, Keyboard } from "gramio"; // import from GramIO package!! | ||
const bot = new Bot(process.env.TOKEN); | ||
const data = ["Apple", "Realme", "Tesla", "Xiaomi"]; | ||
bot.on("message", (ctx) => { | ||
return ctx.reply("test", { | ||
reply_markup: new Keyboard() | ||
.columns(1) | ||
.text("simple keyboard") | ||
.add(...data.map((x) => Keyboard.text(x))) | ||
.filter(({ button }) => button.text !== "Tesla"), | ||
}); | ||
}); | ||
``` | ||
### Send via [Grammy](https://grammy.dev/) | ||
@@ -52,3 +68,3 @@ | ||
.filter(({ button }) => button.text !== "Tesla") | ||
.toJSON(), | ||
.build(), | ||
}); | ||
@@ -55,0 +71,0 @@ }); |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Possible typosquat attack
Supply chain riskThere is a package with a similar name that is downloaded much more often.
Did you mean |
---|
@lumino/keyboard |
1
2
107
0
61459
14
1462
1
+ Added@gramio/types@^7.1.0
- Removedinspectable@2.1.1(transitive)
- Removedreflect-metadata@0.2.2(transitive)
- Removedtypescript@5.7.2(transitive)