Completed Payment and Timings (not tested during 8AM timing yet.)

This commit is contained in:
2026-04-12 11:02:42 +05:00
parent 430c5fd2b8
commit 869b0b466e
6 changed files with 147 additions and 33 deletions
+63
View File
@@ -0,0 +1,63 @@
using System.Text.RegularExpressions;
using Microsoft.Playwright;
namespace BadmintonBooker;
public static class GoogleMessages
{
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;
}
}
public static async Task<string?> GetBMLOTP(IBrowserContext context, IPage originalPage)
{
var msgPage = await context.NewPageAsync();
await msgPage.GotoAsync("https://messages.google.com/web/u/0/conversations/Cgj4KNDeDzFopxIBMQ", 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{6,}\b");
if (match.Success)
{
return match.Value;
}
else
{
Console.WriteLine("No OTP found in the message.");
return null;
}
}
public static async Task<string> GetMessageFromHDC(IBrowserContext context, IPage originalPage)
{
var msgPage = await context.NewPageAsync();
await msgPage.GotoAsync("https://messages.google.com/web/u/0/conversations/Cghm7Ql96iXyyhIBMg", new PageGotoOptions { WaitUntil = WaitUntilState.Load });
var messageElement = msgPage.Locator("mws-text-message-part").Last;
string messageText = await messageElement.InnerTextAsync();
await originalPage.BringToFrontAsync();
return messageText;
}
}