Skip to content

Commit

Permalink
chore: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RozmarinUS committed Jul 9, 2024
1 parent e47cbad commit 9b96bad
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/content/interactions/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
label: 'Interactions'
position: 4
collapsible: true
collapsed: false
51 changes: 51 additions & 0 deletions docs/content/interactions/interaction-components.md
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}`);
}
}
```

Binary file added docs/static/img/content/button.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/inline-keyboard/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { Button, ButtonContext, ComponentParam, On } from '../../../packages/core';
import { CommandContext, Context, ContextOf } from '../../../packages/core';
import { Button, ButtonContext, ComponentParam, On, TextCommandContext } from '../../../packages/core';
import { Context, ContextOf } from '../../../packages/core';
import { Markup, Telegraf } from 'telegraf';
import { TextCommand } from '../../../packages/core';

Expand Down

0 comments on commit 9b96bad

Please sign in to comment.