Payment not tested rest done-ish

This commit is contained in:
2026-04-11 20:40:41 +05:00
parent 8dbab98802
commit e5024d1582
6 changed files with 166 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
using System.Text.RegularExpressions;
using Microsoft.Playwright;
namespace BadmintonBooker;
public static class OTPExtractor
{
public static async Task<string?> GetEgovOTP(IBrowserContext context, IPage originalPage)
{
var msgPage = await context.NewPageAsync();
await msgPage.GotoAsync("https://messages.google.com/web/u/0/conversations/CgjwUsdGGwxxGhIBNw", new PageGotoOptions { WaitUntil = WaitUntilState.Load });
var messageElement = msgPage.Locator("mws-text-message-part").Last;
string messageText = await messageElement.InnerTextAsync();
await originalPage.BringToFrontAsync();
var match = Regex.Match(messageText, @"\b\d{5,}\b");
if (match.Success)
{
return match.Value;
}
else
{
Console.WriteLine("No OTP found in the message.");
return null;
}
}
}