-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e47cbad
commit 9b96bad
Showing
4 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
label: 'Interactions' | ||
position: 4 | ||
collapsible: true | ||
collapsed: false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: message-interactions | ||
|
||
title: Message Interactions | ||
|
||
sidebar_position: 3 | ||
--- | ||
|
||
**Message interactions** — we'll call them "interaction" moving forward—are a framework for adding interactive elements to the messages your app or bot sends. They're accessible, customizable, and easy to use. | ||
|
||
There are several different types of interactions; this documentation will outline the basics of this new framework and each example. | ||
|
||
## Button | ||
|
||
**Buttons** are interactive components that render on messages. They can be clicked by users, and send an interaction to your app when clicked. | ||
|
||
<img src="/img/content/button.jpg" alt="Buttons" width="500" /> | ||
|
||
```typescript title="src/app.components.ts" | ||
import { Injectable } from '@nestjs/common'; | ||
import { Context, Button, ButtonContext, ComponentParam, On, TextCommandContext } from '@nestgramjs/core'; | ||
import { Markup, Telegraf } from 'telegraf'; | ||
|
||
@Injectable() | ||
export class AppService { | ||
@TextCommand({ | ||
name: 'start', | ||
description: 'Displays this help message.', | ||
}) | ||
onStart(@Context() [ctx]: TextCommandContext) { | ||
const inlineKeyboard = Markup.inlineKeyboard([ | ||
{ | ||
text: 'Button 1', | ||
callback_data: 'nestgram/button1', | ||
}, | ||
{ | ||
text: 'Button 2', | ||
callback_data: 'nestgram/button2', | ||
}, | ||
]) | ||
|
||
ctx.reply('Start message', inlineKeyboard); | ||
} | ||
|
||
@Button('nestgram/:name') | ||
async handleClickButton(@Context() ctx: ButtonContext, @ComponentParam('name') name: string) { | ||
await ctx.reply(`clicked on ${name}`); | ||
} | ||
} | ||
``` | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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