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()
|
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();
|
return new kwum(num).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
namespace NadekoBot.Modules.Games;
|
namespace NadekoBot.Modules.Games;
|
||||||
|
|
||||||
public sealed class FishCatch
|
public sealed class FishCatch
|
||||||
|
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@@ -35,29 +35,29 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
|||||||
if (!query.IsAlphaNumeric())
|
if (!query.IsAlphaNumeric())
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
var info = await GetNasdaqDataResponse<NasdaqSummaryResponse>(
|
var sum = await GetNasdaqDataResponse<NasdaqSummaryResponse>(
|
||||||
$"https://api.nasdaq.com/api/quote/{query}/summary?assetclass=stocks");
|
$"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;
|
return default;
|
||||||
|
|
||||||
var closePrice = double.Parse(sd.PreviousClose.Value?.Substring(1) ?? "0",
|
var closePrice = double.Parse(sd.PreviousClose.Value?.Substring(1) ?? "0",
|
||||||
NumberStyles.Any,
|
NumberStyles.Any,
|
||||||
CultureInfo.InvariantCulture);
|
CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
var price = d.BidAsk.Bid.Value.IndexOf('*') is var idx and > 0
|
var info = await GetNasdaqDataResponse<NasdaqInfoResponse>(
|
||||||
&& double.TryParse(d.BidAsk.Bid.Value.Substring(1, idx - 1),
|
$"https://api.nasdaq.com/api/quote/{query}/info?assetclass=stocks");
|
||||||
NumberStyles.Any,
|
|
||||||
CultureInfo.InvariantCulture,
|
if (info?.Data?.PrimaryData is not { } pd)
|
||||||
out var bid)
|
return default;
|
||||||
? bid
|
|
||||||
: double.NaN;
|
var priceStr = pd.LastSalePrice;
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
Name = query,
|
Name = info.Data.CompanyName,
|
||||||
Symbol = info.Data.Symbol,
|
Symbol = sum.Data.Symbol,
|
||||||
Price = price,
|
Price = double.Parse(priceStr?.Substring(1) ?? "0", NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||||
Close = closePrice,
|
Close = closePrice,
|
||||||
MarketCap = sd.MarketCap.Value,
|
MarketCap = sd.MarketCap.Value,
|
||||||
DailyVolume =
|
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 string Symbol { get; init; }
|
||||||
|
|
||||||
public required NasdaqSummaryResponseData SummaryData { 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
|
public sealed class NasdaqSummaryResponseData
|
||||||
{
|
{
|
||||||
|
@@ -30,4 +30,5 @@ public static class SocketMessageComponentExtensions
|
|||||||
string text,
|
string text,
|
||||||
bool ephemeral = false)
|
bool ephemeral = false)
|
||||||
=> smc.RespondAsync(sender, text, MsgType.Ok, ephemeral);
|
=> smc.RespondAsync(sender, text, MsgType.Ok, ephemeral);
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user