Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fee1044838 | |||
| 4fa140d91f |
@@ -48,12 +48,6 @@ jobs:
|
||||
BotPages.Telegram
|
||||
BotPages
|
||||
|
||||
- name: Upload package artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: nuget-packages
|
||||
path: artifacts/*.nupkg
|
||||
|
||||
- name: Publish to NuGet
|
||||
env:
|
||||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
|
||||
|
||||
@@ -22,6 +22,11 @@ public class InlineButton
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Стиль кнопки.
|
||||
/// </summary>
|
||||
public ButtonStyle Style { get; set; } = ButtonStyle.Default;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public InlineButton(Enum value)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,11 @@ public class ReplyButton
|
||||
this.Label = value.GetButtonLabel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Стиль кнопки.
|
||||
/// </summary>
|
||||
public ButtonStyle Style { get; set; } = ButtonStyle.Default;
|
||||
|
||||
/// <summary>
|
||||
/// Преобразование строки к кнопке.
|
||||
/// </summary>
|
||||
@@ -34,3 +39,19 @@ public class ReplyButton
|
||||
/// <param name="en"></param>
|
||||
public static implicit operator ReplyButton(Enum en) => new ReplyButton(en);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Стиль оформления сообщения.
|
||||
/// </summary>
|
||||
public enum ButtonStyle
|
||||
{
|
||||
/// <summary>Обычный стиль.</summary>
|
||||
Default,
|
||||
/// <summary>Стиль информационого сообщения.</summary>
|
||||
Info,
|
||||
/// <summary>Стиль успеха.</summary>
|
||||
Success,
|
||||
/// <summary>Стиль ошибки.</summary>
|
||||
Error,
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Telegram.Bot" Version="22.7.5" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.9.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -375,7 +375,17 @@ public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
{
|
||||
if (inline is null || !inline.Any()) return null;
|
||||
return new InlineKeyboardMarkup(
|
||||
inline.Select(row => row.Select(b => new InlineKeyboardButton(b.Label, b.Value)).ToArray()).ToArray()
|
||||
inline.Select(row => row.Select(b => new InlineKeyboardButton(b.Label, b.Value)
|
||||
{
|
||||
Style = b.Style switch
|
||||
{
|
||||
ButtonStyle.Default => null,
|
||||
ButtonStyle.Info => KeyboardButtonStyle.Primary,
|
||||
ButtonStyle.Error => KeyboardButtonStyle.Danger,
|
||||
ButtonStyle.Success => KeyboardButtonStyle.Success,
|
||||
_ => null,
|
||||
}
|
||||
}).ToArray()).ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -385,7 +395,17 @@ public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
|
||||
if (reply.Any())
|
||||
{
|
||||
return new ReplyKeyboardMarkup(reply.Select(row => row.Select(b => new KeyboardButton(b.Label)).ToArray()).ToArray())
|
||||
return new ReplyKeyboardMarkup(reply.Select(row => row.Select(b => new KeyboardButton(b.Label)
|
||||
{
|
||||
Style = b.Style switch
|
||||
{
|
||||
ButtonStyle.Default => null,
|
||||
ButtonStyle.Info => KeyboardButtonStyle.Primary,
|
||||
ButtonStyle.Error => KeyboardButtonStyle.Danger,
|
||||
ButtonStyle.Success => KeyboardButtonStyle.Success,
|
||||
_ => null,
|
||||
}
|
||||
}).ToArray()).ToArray())
|
||||
{
|
||||
ResizeKeyboard = true
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ public sealed class WelcomePage : SingletonPage
|
||||
return ctx.Navigation.GoToAsync<TitlePage>(ctx, ct);
|
||||
|
||||
case WelcomePageButtons.Help:
|
||||
return new MessageBuilder(ctx).Text("Здесь будет справка.", MessageFormat.Plain).SendAsync(ct);
|
||||
return new MessageBuilder(ctx).Text("Здесь будет справка.", MessageFormat.Plain).Style(MessageStyle.Success).SendAsync(ct);
|
||||
|
||||
case WelcomePageButtons.SendFile:
|
||||
return ctx.Navigation.GoToAsync<FileSendPage>(ctx, ct);
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Demo
|
||||
.MapCommand("/open {page}", openHandler, true, "открыть страницу /open {page}")
|
||||
.MapCommand(DetailsPage.Command, DetailsPage.CommandHandler, true, DetailsPage.CommandDescription)
|
||||
.AutoMapRoute()
|
||||
.AddTelegramAdapter(token, "Telegram")
|
||||
.AddMiddleware(new ErrorHandlingMiddleware(logger))
|
||||
.AddMiddleware(new LoggingMiddleware(logger))
|
||||
.AddTelegramAdapter(token, "Telegram");
|
||||
.AddMiddleware(new LoggingMiddleware(logger));
|
||||
|
||||
await app.RunAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user