Last active
April 29, 2024 11:27
-
-
Save waptik/1a57faa9a6aa89702c23ade43ad8a08f to your computer and use it in GitHub Desktop.
An example on how to use grammY's Interactive Menus plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm using deno | |
import "https://deno.land/std@0.178.0/dotenv/load.ts"; | |
import { green } from "https://deno.land/std@0.178.0/fmt/colors.ts"; | |
import { itemsMenu } from './menus/example.menu.ts'; | |
const grammy = new Bot<GrammyContext>(Deno.env.get("BOT_TOKEN")||""); // replace `BOT_TOKEN` inside `.env` file with your own telegram bot's token | |
// attaching the menu to bot to get it to work if not we'll get the following errors inside the terminal | |
// `Error: Cannot send menu 'bot-items-menu'! Did you forget to use bot.use() for it?` | |
grammy.use(itemsMenu); | |
// setting up a command to bring the menu in action | |
grammy.command('items', async (ctx) => { | |
const text = `Here are the items we currently have:`; | |
return await ctx.replyWithHTML(text, { | |
reply_markup: itemsMenu, | |
}); | |
}); | |
grammy.start({ | |
drop_pending_updates: false, | |
onStart: ({ username }) => | |
console.log(`[bot] @${green(username)} is up and running ๐ฆ`), | |
}); | |
// Path: bot.ts |
Hi. I was wandering if two or more users are using pagination at the same time won't it affect the other user menu as pageIndex is registered globally?
I think itโs possible so the best way is to add pageIndex as a session key
so that the order of the pagination is unique to each user
โฆOn Mon, 29 Apr 2024 at 11:24, Shaxrillo Nusratov ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hi. I was wandering if two or more users are using pagination at the same
time won't it affect the other user menu as pageIndex is registered
globally?
โ
Reply to this email directly, view it on GitHub
<https://gist.github.com/waptik/1a57faa9a6aa89702c23ade43ad8a08f#gistcomment-5040228>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAM377YGSCQQ6ZEIH6L5RE3Y7YUV7BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTENJTGEZDGMRTU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a step by step instruction set on how to use grammY's Interactive Menus plugin.
Steps:
example.menu.ts
and replace the contents ofitems
set of object with your own values or you can use your database to populate them for you. You can renameexample.menu.ts
to whatever name you want.composer.use
andbot.use
respectively.command
,callbackQuery
,conversation
or wherever you wish to use it then you're good to go ๐A video of it in action can be found here https://twitter.com/_waptik/status/1710217968548737172