add placeholder for preset settings

This commit is contained in:
Slavasil 2025-04-20 20:48:22 +03:00
parent d71afa8ffe
commit 6cbae9f344
3 changed files with 62 additions and 3 deletions

View File

@ -15,4 +15,5 @@ enum DialogState
AwaitingSubtitle,
ShowingResult,
Settings,
ViewingPresets,
}

View File

@ -10,19 +10,23 @@ internal static class Interactions
public const string sendPictureOrQuitMessage = "Пришли мне картинку для демотиватора, чтобы продолжить. Чтобы отменить, напиши \"назад\" или \"отмена\"";
public const string sendTitleOrQuitMessage = "Пришли мне текст для демотиватора, чтобы продолжить. Чтобы отменить, нажми на кнопку в меню.";
public const string awaitingTitleMessage = "Шикарная картинка. Давай сделаем из неё крутой интернет-мэм для скуфов. Какой текст ты бы хотел видеть на нём? Можно написать две строки, тогда первая строка будет заголовком, а вторая под ним.";
public const string showingResultMessage = "Вот такой демотиватор получился. Можно поменять цветовую схему, добавить водяной знак или оставить как есть (нажмите одну из кнопок).";
public const string showingResultMessage = "Вот такой демотиватор получился. Можно добавить водяной знак или оставить как есть (нажмите одну из кнопок).";
public const string awaitingSubtitleMessage = "Найс. Напиши текст, который будет под заголовком, или точку (.), чтобы не добавлять его.";
public const string chooseActionMessage = "Нажмите на одну из кнопок.";
public const string settingsMessage = "Здесь можно:\n- настроить сохранённые стили";
static readonly string[] helloWords = ["прив","привет","▶️начать","ку","хай","приветик","превед","привки","хаюхай","здравствуй","здравствуйте","здорово","дарова","дороу","здарова","здорова"];
static readonly string[] cancelWords = ["↩️назад", "назад", "выйти", "отмена", "отменить", "отменяй", "галя", "галина", "стоп"];
static readonly string cancelButtonText = "↩️Назад";
static readonly string[] settingsWords = ["⚙️настройки", "настройки", "настроить"];
public static readonly string backButtonText = "↩️Назад";
public static readonly string gotoPresetsButtonText = "🎨Сохранённые стили";
public static readonly string doneButtonText = "✅Готово";
public static readonly IReplyMarkup mainReplyMarkup = new ReplyKeyboardMarkup([[new KeyboardButton("▶️Начать")], [new KeyboardButton("⚙️Настройки")]]);
public static readonly IReplyMarkup backButtonReplyMarkup = new ReplyKeyboardMarkup(new KeyboardButton("↩️Назад"));
public static readonly IReplyMarkup resultActionReplyMarkup = new ReplyKeyboardMarkup([new KeyboardButton(doneButtonText)]);
public static readonly IReplyMarkup settingsReplyMarkup = new ReplyKeyboardMarkup([[new KeyboardButton(gotoPresetsButtonText)], [new KeyboardButton(backButtonText)]]);
public static bool IsStartCommand(string message)
{
@ -35,6 +39,12 @@ internal static class Interactions
return helloWords.Any(word => messageWords.Contains(word));
}
public static bool IsGotoSettings(string message)
{
string[] messageWords = message.ToLower().Split(new char[] { ' ', ',', '.', ';', '(', ')' });
return settingsWords.Any(word => messageWords.Contains(word));
}
public static bool IsCancellation(string message)
{
string[] messageWords = message.ToLower().Split(new char[] { ' ', ',', '.', ';', '(', ')' });
@ -43,6 +53,6 @@ internal static class Interactions
public static bool IsCancelButton(string message)
{
return message == cancelButtonText;
return message == backButtonText;
}
}

View File

@ -106,6 +106,12 @@ internal class TelegramBot
dialogData.state = DialogState.AwaitingPicture;
replied = true;
}
else if (Interactions.IsGotoSettings(messageText))
{
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.settingsMessage, replyMarkup: Interactions.settingsReplyMarkup);
dialogData.state = DialogState.Settings;
replied = true;
}
}
if (!replied)
{
@ -188,6 +194,48 @@ internal class TelegramBot
}
break;
}
case DialogState.Settings:
{
bool replied = false;
if (message.Text is { } messageText)
{
if (messageText == Interactions.gotoPresetsButtonText)
{
replied = true;
dialogData.state = DialogState.ViewingPresets;
await botClient.SendTextMessageAsync(message.Chat.Id, "<заглушка>", replyMarkup: Interactions.backButtonReplyMarkup);
}
else if (messageText == Interactions.backButtonText)
{
replied = true;
dialogData.state = DialogState.Initial;
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.mainReplyMarkup);
}
}
if (!replied)
{
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.chooseActionMessage, replyMarkup: Interactions.settingsReplyMarkup);
}
break;
}
case DialogState.ViewingPresets:
{
bool replied = false;
if (message.Text is { } messageText)
{
if (messageText == Interactions.backButtonText)
{
replied = true;
dialogData.state = DialogState.Settings;
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.settingsMessage, replyMarkup: Interactions.settingsReplyMarkup);
}
}
if (!replied)
{
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.chooseActionMessage, replyMarkup: Interactions.settingsReplyMarkup);
}
break;
}
}
}