Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ba411a04b |
@@ -36,19 +36,19 @@ internal static class SessionListMessageRenderer
|
|||||||
|
|
||||||
actions.Add(new PlatformMessageAction(
|
actions.Add(new PlatformMessageAction(
|
||||||
$"cancel_session:{session.Id}",
|
$"cancel_session:{session.Id}",
|
||||||
$"❌ Отменить {dateTitle}",
|
$"❌ {dateTitle}",
|
||||||
$"cancel_session:{session.Id}"));
|
$"cancel_session:{session.Id}"));
|
||||||
|
|
||||||
actions.Add(new PlatformMessageAction(
|
actions.Add(new PlatformMessageAction(
|
||||||
$"reschedule_session:{session.Id}",
|
$"reschedule_session:{session.Id}",
|
||||||
$"⏰ Перенести {dateTitle}",
|
$"⏰ {dateTitle}",
|
||||||
$"reschedule_session:{session.Id}"));
|
$"reschedule_session:{session.Id}"));
|
||||||
|
|
||||||
if (SessionCapacityRules.CanPromoteWaitlistedPlayer(session.MaxPlayers, session.PlayerCount, session.WaitlistCount))
|
if (SessionCapacityRules.CanPromoteWaitlistedPlayer(session.MaxPlayers, session.PlayerCount, session.WaitlistCount))
|
||||||
{
|
{
|
||||||
actions.Add(new PlatformMessageAction(
|
actions.Add(new PlatformMessageAction(
|
||||||
$"promote_waitlist:{session.Id}",
|
$"promote_waitlist:{session.Id}",
|
||||||
$"⬆️ С ожидания {dateTitle}",
|
$"⬆️ Из ожидания {dateTitle}",
|
||||||
$"promote_waitlist:{session.Id}"));
|
$"promote_waitlist:{session.Id}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
using Telegram.Bot;
|
|
||||||
using Telegram.Bot.Types;
|
|
||||||
|
|
||||||
namespace GmRelay.Bot.Infrastructure.Telegram;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Registers the bot's command list with Telegram so users see the
|
|
||||||
/// command menu when they type "/" in a chat.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class TelegramCommandsSetupService(
|
|
||||||
ITelegramBotClient bot,
|
|
||||||
ILogger<TelegramCommandsSetupService> logger) : IHostedService
|
|
||||||
{
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var commands = new[]
|
|
||||||
{
|
|
||||||
new BotCommand { Command = "start", Description = "Начать работу с ботом" },
|
|
||||||
new BotCommand { Command = "newsession", Description = "Создать новую игровую сессию" },
|
|
||||||
new BotCommand { Command = "listsessions", Description = "Список предстоящих сессий" },
|
|
||||||
new BotCommand { Command = "exportcalendar", Description = "Экспортировать расписание в ICS" },
|
|
||||||
new BotCommand { Command = "help", Description = "Справка по командам" }
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await bot.SetMyCommands(
|
|
||||||
commands,
|
|
||||||
scope: new BotCommandScopeAllPrivateChats(),
|
|
||||||
cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
await bot.SetMyCommands(
|
|
||||||
commands,
|
|
||||||
scope: new BotCommandScopeAllGroupChats(),
|
|
||||||
cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
logger.LogInformation("Telegram command menu registered for private chats and groups.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger.LogWarning(ex, "Failed to register Telegram command menu.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
||||||
}
|
|
||||||
@@ -366,13 +366,6 @@ public sealed class UpdateRouter(
|
|||||||
text: """
|
text: """
|
||||||
GM-Relay — бот для управления игровыми сессиями.
|
GM-Relay — бот для управления игровыми сессиями.
|
||||||
|
|
||||||
/start — начать работу с ботом
|
|
||||||
/newsession — создать новую игровую сессию
|
|
||||||
/listsessions — список предстоящих сессий
|
|
||||||
/exportcalendar — экспортировать расписание в ICS
|
|
||||||
/help — эта справка
|
|
||||||
|
|
||||||
Пример создания сессии:
|
|
||||||
/newsession
|
/newsession
|
||||||
Название: My Game
|
Название: My Game
|
||||||
Время: 15.05.2026 19:30
|
Время: 15.05.2026 19:30
|
||||||
@@ -384,8 +377,10 @@ public sealed class UpdateRouter(
|
|||||||
Игр: 4
|
Игр: 4
|
||||||
Интервал: 7
|
Интервал: 7
|
||||||
|
|
||||||
|
/listsessions — список предстоящих сессий
|
||||||
Для owner/co-GM /listsessions показывает кнопки отмены, переноса, удаления и повышения из листа ожидания.
|
Для owner/co-GM /listsessions показывает кнопки отмены, переноса, удаления и повышения из листа ожидания.
|
||||||
Игроки могут записаться кнопкой «На дату» и сняться кнопкой «Выйти».
|
Игроки могут записаться кнопкой «На дату» и сняться кнопкой «Выйти».
|
||||||
|
/help — эта справка
|
||||||
""",
|
""",
|
||||||
cancellationToken: ct);
|
cancellationToken: ct);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ builder.Services.AddSingleton<DirectSessionNotificationSender>();
|
|||||||
// ── Telegram infrastructure ──────────────────────────────────────────
|
// ── Telegram infrastructure ──────────────────────────────────────────
|
||||||
builder.Services.AddSingleton<UpdateRouter>();
|
builder.Services.AddSingleton<UpdateRouter>();
|
||||||
builder.Services.AddSingleton<ITelegramUpdateHandler>(sp => sp.GetRequiredService<UpdateRouter>());
|
builder.Services.AddSingleton<ITelegramUpdateHandler>(sp => sp.GetRequiredService<UpdateRouter>());
|
||||||
builder.Services.AddHostedService<TelegramCommandsSetupService>();
|
|
||||||
builder.Services.AddHostedService<TelegramMiniAppMenuButtonService>();
|
builder.Services.AddHostedService<TelegramMiniAppMenuButtonService>();
|
||||||
builder.Services.AddHostedService<TelegramBotService>();
|
builder.Services.AddHostedService<TelegramBotService>();
|
||||||
|
|
||||||
|
|||||||
-6
@@ -32,12 +32,6 @@ public sealed class SessionListMessageRendererTests
|
|||||||
Assert.Contains(actions, a => a.Payload == $"reschedule_session:{sessionId}");
|
Assert.Contains(actions, a => a.Payload == $"reschedule_session:{sessionId}");
|
||||||
Assert.Contains(actions, a => a.Payload == $"promote_waitlist:{sessionId}");
|
Assert.Contains(actions, a => a.Payload == $"promote_waitlist:{sessionId}");
|
||||||
Assert.Contains(actions, a => a.Payload == $"delete_session:{sessionId}");
|
Assert.Contains(actions, a => a.Payload == $"delete_session:{sessionId}");
|
||||||
|
|
||||||
var shortDate = new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc).FormatMoscowShort();
|
|
||||||
Assert.Contains(actions, a => a.Label == $"❌ Отменить {shortDate}");
|
|
||||||
Assert.Contains(actions, a => a.Label == $"⏰ Перенести {shortDate}");
|
|
||||||
Assert.Contains(actions, a => a.Label == $"⬆️ С ожидания {shortDate}");
|
|
||||||
Assert.Contains(actions, a => a.Label == $"🗑 Удалить {shortDate}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user