Skip to content

Commit

Permalink
Fix ending conversation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 18, 2024
1 parent 44af2ee commit 1bc4c93
Showing 1 changed file with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ protected override async Task HandleAfter(IPipelineContext ctx, PipedFieldPacket

var type = message.Packet.Type;
var conversation = message.User.ActiveConversation;


if (message.Packet.Info is StructuredScriptMessageAnswerInfoStatus status)
{
if (
type != ConversationMessageType.Say &&
type != ConversationMessageType.AskYesNo &&
type != ConversationMessageType.AskAccept &&
status.Status == byte.MinValue ||
type is
ConversationMessageType.Say or
ConversationMessageType.AskYesNo or
ConversationMessageType.AskAccept &&
status.Status == byte.MaxValue
)
{
await message.User.EndConversation();
return;
}
}

switch (message.Packet.Info)
{
case StructuredScriptMessageAnswerInfoAnswer<LPString> answerString:
Expand All @@ -31,27 +50,11 @@ protected override async Task HandleAfter(IPipelineContext ctx, PipedFieldPacket
case StructuredScriptMessageAnswerInfoAnswer<bool> answerBool:
await conversation.Answer(new ConversationMessageAnswer<bool>(type, answerBool.Answer));
break;
case StructuredScriptMessageAnswerInfoQuiz quiz:
await conversation.Answer(new ConversationMessageAnswer<string>(type, quiz.Answer.Value));
case StructuredScriptMessageAnswerInfoQuiz answerQuiz:
await conversation.Answer(new ConversationMessageAnswer<string>(type, answerQuiz.Answer.Value));
break;
case StructuredScriptMessageAnswerInfoStatus status:
if (
type != ConversationMessageType.Say &&
type != ConversationMessageType.AskYesNo &&
type != ConversationMessageType.AskAccept &&
status.Status == byte.MinValue ||
type is
ConversationMessageType.Say or
ConversationMessageType.AskYesNo or
ConversationMessageType.AskAccept &&
status.Status == byte.MaxValue
)
{
await message.User.EndConversation();
return;
}

await conversation.Answer(new ConversationMessageAnswer<byte>(type, status.Status));
case StructuredScriptMessageAnswerInfoStatus answerStatus:
await conversation.Answer(new ConversationMessageAnswer<byte>(type, answerStatus.Status));
break;
}
}
Expand Down

0 comments on commit 1bc4c93

Please sign in to comment.