fix reply markup and message text
This commit is contained in:
parent
58b17759c4
commit
d71afa8ffe
@ -14,4 +14,5 @@ enum DialogState
|
||||
AwaitingTitle,
|
||||
AwaitingSubtitle,
|
||||
ShowingResult,
|
||||
Settings,
|
||||
}
|
||||
|
@ -4,9 +4,10 @@ namespace SimpleTGBot;
|
||||
|
||||
internal static class Interactions
|
||||
{
|
||||
public const string greetingMessage = "Привет. Я - бот, который умеет делать демотиваторы. Нажми на одну из кнопок в меню или отправь картинку, чтобы продолжить.";
|
||||
public const string awaitingPictureMessage = "Присылай картинку, а я скажу, что делать дальше. Или можешь нажать на кнопку в меню.";
|
||||
public const string sayHelloMessage = "Напиши \"привет\" или нажми на кнопку в меню, чтобы начать.";
|
||||
public const string sendPictureOrQuitMessage = "Пришли мне картинку для демотиватора, чтобы продолжить. Чтобы отменить, напиши \"назад\" или \"\"";
|
||||
public const string sendPictureOrQuitMessage = "Пришли мне картинку для демотиватора, чтобы продолжить. Чтобы отменить, напиши \"назад\" или \"отмена\"";
|
||||
public const string sendTitleOrQuitMessage = "Пришли мне текст для демотиватора, чтобы продолжить. Чтобы отменить, нажми на кнопку в меню.";
|
||||
public const string awaitingTitleMessage = "Шикарная картинка. Давай сделаем из неё крутой интернет-мэм для скуфов. Какой текст ты бы хотел видеть на нём? Можно написать две строки, тогда первая строка будет заголовком, а вторая под ним.";
|
||||
public const string showingResultMessage = "Вот такой демотиватор получился. Можно поменять цветовую схему, добавить водяной знак или оставить как есть (нажмите одну из кнопок).";
|
||||
@ -19,9 +20,8 @@ internal static class Interactions
|
||||
|
||||
public static readonly string doneButtonText = "✅Готово";
|
||||
|
||||
public static readonly IReplyMarkup initialReplyMarkup = new ReplyKeyboardMarkup([[new KeyboardButton("▶️Начать")]]);
|
||||
public static readonly IReplyMarkup mainReplyMarkup = new ReplyKeyboardMarkup([[new KeyboardButton("▶️Начать")], [new KeyboardButton("⚙️Настройки")]]);
|
||||
public static readonly IReplyMarkup backButtonReplyMarkup = new ReplyKeyboardMarkup(new KeyboardButton("↩️Назад"));
|
||||
public static readonly IReplyMarkup quickActionReplyMarkup = new ReplyKeyboardRemove();
|
||||
public static readonly IReplyMarkup resultActionReplyMarkup = new ReplyKeyboardMarkup([new KeyboardButton(doneButtonText)]);
|
||||
|
||||
public static bool IsStartCommand(string message)
|
||||
|
@ -95,16 +95,21 @@ internal class TelegramBot
|
||||
}
|
||||
else if (message.Text is { } messageText)
|
||||
{
|
||||
if (Interactions.IsStartCommand(messageText) || Interactions.IsHello(messageText))
|
||||
if (Interactions.IsStartCommand(messageText))
|
||||
{
|
||||
_ = botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.backButtonReplyMarkup);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.greetingMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
replied = true;
|
||||
}
|
||||
else if (Interactions.IsHello(messageText))
|
||||
{
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.backButtonReplyMarkup);
|
||||
dialogData.state = DialogState.AwaitingPicture;
|
||||
replied = true;
|
||||
}
|
||||
}
|
||||
if (!replied)
|
||||
{
|
||||
_ = botClient.SendTextMessageAsync(message.Chat.Id, Interactions.sayHelloMessage, replyMarkup: Interactions.initialReplyMarkup);
|
||||
_ = botClient.SendTextMessageAsync(message.Chat.Id, Interactions.sayHelloMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -122,7 +127,7 @@ internal class TelegramBot
|
||||
if (Interactions.IsCancellation(messageText))
|
||||
{
|
||||
dialogData.state = DialogState.Initial;
|
||||
_ = botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.quickActionReplyMarkup);
|
||||
_ = botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
reacted = true;
|
||||
}
|
||||
}
|
||||
@ -141,7 +146,7 @@ internal class TelegramBot
|
||||
} else
|
||||
{
|
||||
DialogCancelDemotivatorCreation(dialogData);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.quickActionReplyMarkup);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
}
|
||||
} else
|
||||
{
|
||||
@ -160,7 +165,7 @@ internal class TelegramBot
|
||||
else
|
||||
{
|
||||
DialogCancelDemotivatorCreation(dialogData);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.quickActionReplyMarkup);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -173,8 +178,8 @@ internal class TelegramBot
|
||||
if (messageText == Interactions.doneButtonText)
|
||||
{
|
||||
replied = true;
|
||||
dialogData.state = DialogState.AwaitingPicture;
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.quickActionReplyMarkup);
|
||||
DialogFinishDemotivatorCreation(dialogData);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
}
|
||||
}
|
||||
if (!replied)
|
||||
@ -211,7 +216,7 @@ internal class TelegramBot
|
||||
logger.Error(e.StackTrace ?? "");
|
||||
dialogData.state = DialogState.Initial;
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, "Ошибка :(");
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.quickActionReplyMarkup);
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Interactions.awaitingPictureMessage, replyMarkup: Interactions.mainReplyMarkup);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,7 +241,7 @@ internal class TelegramBot
|
||||
dialogData.inputPictureFilename!,
|
||||
[new DemotivatorText() { Title = title, Subtitle = subtitle }],
|
||||
DemotivatorGen.DefaultStyle());
|
||||
DialogFinishDemotivatorCreation(dialogData);
|
||||
dialogData.state = DialogState.ShowingResult;
|
||||
await botClient.SendPhotoAsync(message.Chat.Id, new InputFile(demotivator, "dem.png"), caption: Interactions.showingResultMessage, replyMarkup: Interactions.resultActionReplyMarkup, cancellationToken: cancellationToken);
|
||||
demotivator.Dispose();
|
||||
} else
|
||||
@ -258,21 +263,21 @@ internal class TelegramBot
|
||||
dialogData.inputPictureFilename!,
|
||||
[new DemotivatorText() { Title = title, Subtitle = subtitle }],
|
||||
DemotivatorGen.DefaultStyle());
|
||||
DialogFinishDemotivatorCreation(dialogData);
|
||||
dialogData.state = DialogState.ShowingResult;
|
||||
await botClient.SendPhotoAsync(message.Chat.Id, new InputFile(demotivator, "dem.png"), caption: Interactions.showingResultMessage, replyMarkup: Interactions.resultActionReplyMarkup, cancellationToken: cancellationToken);
|
||||
demotivator.Dispose();
|
||||
}
|
||||
|
||||
void DialogCancelDemotivatorCreation(DialogData dialogData)
|
||||
{
|
||||
dialogData.state = DialogState.AwaitingPicture;
|
||||
dialogData.state = DialogState.Initial;
|
||||
if (dialogData.inputPictureFilename != null)
|
||||
temp.deleteTemporaryFile(dialogData.inputPictureFilename);
|
||||
}
|
||||
|
||||
void DialogFinishDemotivatorCreation(DialogData dialogData)
|
||||
{
|
||||
dialogData.state = DialogState.ShowingResult;
|
||||
dialogData.state = DialogState.Initial;
|
||||
if (dialogData.inputPictureFilename != null)
|
||||
temp.deleteTemporaryFile(dialogData.inputPictureFilename);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user