mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
fix: fixed .stock command, most likely
fix: fixed 2 character captchas, again, most likely
This commit is contained in:
@@ -52,7 +52,7 @@ public sealed class CaptchaService(FontProvider fonts, IBotCache cache, IPatrona
|
||||
|
||||
public string GeneratePassword()
|
||||
{
|
||||
var num = _rng.Next((int)Math.Pow(31, 2), (int)Math.Pow(32, 3));
|
||||
var num = _rng.Next((int)Math.Pow(32, 2) + 1, (int)Math.Pow(32, 3));
|
||||
return new kwum(num).ToString();
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
namespace NadekoBot.Modules.Games;
|
||||
|
||||
public sealed class FishCatch
|
||||
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
@@ -35,29 +35,29 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
||||
if (!query.IsAlphaNumeric())
|
||||
return default;
|
||||
|
||||
var info = await GetNasdaqDataResponse<NasdaqSummaryResponse>(
|
||||
var sum = await GetNasdaqDataResponse<NasdaqSummaryResponse>(
|
||||
$"https://api.nasdaq.com/api/quote/{query}/summary?assetclass=stocks");
|
||||
|
||||
if (info?.Data is not { } d || d.SummaryData is not { } sd)
|
||||
if (sum?.Data is not { } d || d.SummaryData is not { } sd)
|
||||
return default;
|
||||
|
||||
var closePrice = double.Parse(sd.PreviousClose.Value?.Substring(1) ?? "0",
|
||||
NumberStyles.Any,
|
||||
CultureInfo.InvariantCulture);
|
||||
|
||||
var price = d.BidAsk.Bid.Value.IndexOf('*') is var idx and > 0
|
||||
&& double.TryParse(d.BidAsk.Bid.Value.Substring(1, idx - 1),
|
||||
NumberStyles.Any,
|
||||
CultureInfo.InvariantCulture,
|
||||
out var bid)
|
||||
? bid
|
||||
: double.NaN;
|
||||
var info = await GetNasdaqDataResponse<NasdaqInfoResponse>(
|
||||
$"https://api.nasdaq.com/api/quote/{query}/info?assetclass=stocks");
|
||||
|
||||
if (info?.Data?.PrimaryData is not { } pd)
|
||||
return default;
|
||||
|
||||
var priceStr = pd.LastSalePrice;
|
||||
|
||||
return new()
|
||||
{
|
||||
Name = query,
|
||||
Symbol = info.Data.Symbol,
|
||||
Price = price,
|
||||
Name = info.Data.CompanyName,
|
||||
Symbol = sum.Data.Symbol,
|
||||
Price = double.Parse(priceStr?.Substring(1) ?? "0", NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||
Close = closePrice,
|
||||
MarketCap = sd.MarketCap.Value,
|
||||
DailyVolume =
|
||||
|
@@ -0,0 +1,15 @@
|
||||
namespace NadekoBot.Modules.Searches;
|
||||
|
||||
public sealed class NasdaqInfoResponse
|
||||
{
|
||||
public required string Symbol { get; init; }
|
||||
public required string CompanyName {get; init; }
|
||||
public required NasdaqInfoPrimaryData PrimaryData { get; init; }
|
||||
|
||||
public sealed class NasdaqInfoPrimaryData
|
||||
{
|
||||
public required string LastSalePrice{ get; init; }
|
||||
public required string PercentageChange { get; init; }
|
||||
public required string DeltaIndicator { get; init; }
|
||||
}
|
||||
}
|
@@ -7,18 +7,6 @@ public sealed class NasdaqSummaryResponse
|
||||
public required string Symbol { get; init; }
|
||||
|
||||
public required NasdaqSummaryResponseData SummaryData { get; init; }
|
||||
public required NasdaqSummaryBidAsk BidAsk { get; init; }
|
||||
|
||||
public sealed class NasdaqSummaryBidAsk
|
||||
{
|
||||
[JsonPropertyName("Bid * Size")]
|
||||
public required NasdaqBid Bid { get; init; }
|
||||
|
||||
public sealed class NasdaqBid
|
||||
{
|
||||
public required string Value { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NasdaqSummaryResponseData
|
||||
{
|
||||
|
@@ -30,4 +30,5 @@ public static class SocketMessageComponentExtensions
|
||||
string text,
|
||||
bool ephemeral = false)
|
||||
=> smc.RespondAsync(sender, text, MsgType.Ok, ephemeral);
|
||||
|
||||
}
|
Reference in New Issue
Block a user