Skip to content

Commit

Permalink
various enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
wiz0u committed Oct 5, 2024
1 parent 1551628 commit 1b45b9b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We also check all the HTTP URLs and inter-file references during CI to avoid bro
1. Fork this repository
1. Commit your changes
1. Make sure all tests are passing
1. Make a pull request to `develop` branch here
1. Make a pull request to `master` branch here

## 📜 Contribution Rules

Expand Down
13 changes: 8 additions & 5 deletions src/2/reply-markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

[![reply markup tests](https://img.shields.io/badge/Examples-Reply_Markup-green.svg?style=flat-square)](https://github.com/TelegramBots/Telegram.Bot/blob/master/test/Telegram.Bot.Tests.Integ/ReplyMarkup/ReplyMarkupTests.cs)

Telegram provides two types of reply markup: [Custom keyboards](#custom-keyboards) and [Inline keyboards](#inline-keyboards).
Telegram provides two types of reply markup: [Custom reply keyboards](#custom-reply-keyboards) and [Inline keyboards](#inline-keyboards).

## Custom keyboards
## Custom reply keyboards

Whenever your bot sends a message, it can pass along a [special keyboard] with predefined reply options. Regular keyboards are represented by [`ReplyKeyboardMarkup`] object. You can request a contact or location information from the user with [`KeyboardButton`] or send a poll. Regular button will send predefined text to the chat.
> These are buttons visible below the textbox. Pressing such button will make the user send a message
Whenever your bot sends a message, it can pass along a [special keyboard](https://core.telegram.org/bots/features#keyboards) with predefined reply options. Regular keyboards are represented by [`ReplyKeyboardMarkup`] object. You can request a contact or location information from the user with [`KeyboardButton`] or send a poll. Regular button will send predefined text to the chat.

Keyboard is an array of button rows, each represented by an array of [`KeyboardButton`] objects. [`KeyboardButton`] supports text and emoji.

By default, custom keyboards are displayed until a new keyboard is sent by a bot.
By default, reply keyboards are displayed until a new keyboard is sent by a bot.

### Single-row keyboard markup

Expand Down Expand Up @@ -56,6 +58,8 @@ To remove keyboard you have to send an instance of [`ReplyKeyboardRemove`] objec

## Inline keyboards

> These are buttons visible below a bot message. Pressing such button will NOT make the user send a message
There are times when you'd prefer to do things without sending any messages to the chat. For example, when your user is changing settings or flipping through search results. In such cases you can use [Inline Keyboards] that are integrated directly into the messages they belong to.

Unlike custom reply keyboards, pressing buttons on inline keyboards doesn't result in messages sent to the chat. Instead, inline keyboards support buttons that work behind the scenes: [callback buttons](#callback-buttons), [URL buttons](#url-buttons) and [switch to inline buttons](#switch-to-inline-buttons).
Expand Down Expand Up @@ -95,7 +99,6 @@ Pressing a [switch to inline button] prompts the user to select a chat, opens it
{{#include ../../Examples/2/ReplyMarkup.cs:switch-to-inline}}
```

[special keyboard]: https://core.telegram.org/bots#keyboards
[`ReplyKeyboardMarkup`]: https://core.telegram.org/bots/api/#replykeyboardmarkup
[`KeyboardButton`]: https://core.telegram.org/bots/api/#keyboardbutton
[Inline Keyboards]: https://core.telegram.org/bots/features#inline-keyboards
Expand Down
4 changes: 2 additions & 2 deletions src/4/payments.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ This update is received when the user has entered their payment information and
You must reply within 10 seconds with:
```csharp
if (confirm)
await bot.AnswerPreCheckoutQueryAsync(preCheckoutQuery.Id);
await bot.AnswerPreCheckoutQueryAsync(preCheckoutQuery.Id); // success
else
await bot.AnswerPreCheckoutQueryAsync(preCheckoutQuery.Id, "Can't process your order: <REASON>");
```
Expand Down Expand Up @@ -122,7 +122,7 @@ async Task OnUpdate(Update update)
break;
case { PreCheckoutQuery: { } preCheckoutQuery }:
if (preCheckoutQuery is { InvoicePayload: "unlock_X", Currency: "XTR", TotalAmount: 200 })
await bot.AnswerPreCheckoutQueryAsync(preCheckoutQuery.Id);
await bot.AnswerPreCheckoutQueryAsync(preCheckoutQuery.Id); // success
else
await bot.AnswerPreCheckoutQueryAsync(preCheckoutQuery.Id, "Invalid order");
break;
Expand Down
4 changes: 2 additions & 2 deletions src/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ I recommend you read all of these as you will learn many interesting things. Or

### _1. Can you give me documentation/examples links?_
- Follow [this installation guide](https://telegrambots.github.io/book/#-installation) to install the latest versions of the library.
- Here is on the [main documentation website](https://telegrambots.github.io/book/).
- Here is the [main documentation website](https://telegrambots.github.io/book/).
- You can find [more bot example projects](https://github.com/TelegramBots/Telegram.Bot.Examples) here
- Search the [official API documentation](https://core.telegram.org/bots/api) and [official bots FAQ](https://core.telegram.org/bots/faq).
- check tooltips in your IDE, or navigate with F12 on API methods and read/expand comments.
Expand Down Expand Up @@ -128,7 +128,7 @@ You can call API methods (like sending messages) from several instances in paral

You can't with Bot API but it's possible with [WTelegramBot](https://www.nuget.org/packages/WTelegramBot#readme-body-tab).
Alternatively, you could store in database the mapping of `UserId`<->`Username`.
Remember that not every user has a username.
Remember that not every user has a username, and it can be changed.

### _26. How to receive messages from channels?_

Expand Down

0 comments on commit 1b45b9b

Please sign in to comment.