-
Notifications
You must be signed in to change notification settings - Fork 0
AdvancedMessages Code Snippets
SKitLs-dev edited this page Mar 31, 2024
·
5 revisions
To enable module's facilities support you should use custom delivery method when building you BotManager
(Advanced Delivery Service):
var bot = BotBuilder.NewBuilder("your_token")
.CustomDelivery(new AdvancedDeliveryService())
// ...
.Build();
Create new message, add keyboard and buttons.
var inviteMessage = new OutputMessageText("Message Text");
var inviteMenu = new InlineMenu(update.Owner);
inviteMenu.Add(new UrlButton("Join us!", $"https://github.com/SKitLs-dev/SKitLs.Bots.Telegram"));
inviteMessage.Menu = inviteMenu;
await update.Owner.DeliveryService.AnswerSenderAsync(await inviteMessage.BuildContentAsync(update), update);
Or since v3 Release
var inviteMessage = new OutputMessageText("Message Text")
{
Menu = new InlineMenu(update.Owner)
{
new UrlButton("Join us!", $"https://github.com/SKitLs-dev/SKitLs.Bots.Telegram")),
// More Buttons...
}
};
Localize your buttons with Localize
shortcuts.
Localize.Inline(new UrlButton("app.JoinUsLabel", $"https://github.com/SKitLs-dev/SKitLs.Bots.Telegram"));
var inviteMessage = new LocalizedTextMessage("app.clickMeText2")
{
Menu = new InlineMenu(update.Owner, localize: true, columnsCount: 1)
{
Localize.Inline(new UrlButton("app.JoinUsLabel", $"https://github.com/SKitLs-dev/SKitLs.Bots.Telegram")),
// OR (because `localize = true`) is equal:
new UrlButton("app.JoinUsLabel", $"https://github.com/SKitLs-dev/SKitLs.Bots.Telegram")
}
};
Your localization file {lang}.{name}.json
{
"app.clickMeText2": "This is 'Join Us' message.",
"app.JoinUsLabel": "Join us!",
}
If you don't understand how this or that thing works, please share your problem in discussion.