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