mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b009438e0e | ||
|
4b5d27d963 | ||
|
91ee0d121c | ||
|
a8767f1136 | ||
|
44478e0f47 | ||
|
c73c2da6a4 |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -3,6 +3,26 @@
|
||||
|
||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||
|
||||
## Unreleased
|
||||
|
||||
## [4.1.5] - 11.05.2022
|
||||
|
||||
### Changed
|
||||
|
||||
- `.clubdesc <msg>` will now have a nicer response
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.give` DM will once again show an amount
|
||||
- Fixed an issue with filters not working and with custom reactions no longer being able to override commands.
|
||||
- Fixed `.stock` command
|
||||
|
||||
## [4.1.4] - 06-05-2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.yun`
|
||||
|
||||
## [4.1.3] - 06.05.2022
|
||||
|
||||
### Added
|
||||
@@ -44,7 +64,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
- Fixed `.deletexp` command
|
||||
- `.give` command should send DMs again
|
||||
- `.modules` commanad now has a medusa module description
|
||||
- `.modules` command now has a medusa module description
|
||||
|
||||
## [4.1.2] - 16.04.2022
|
||||
|
||||
|
@@ -363,7 +363,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await _cs.TransferAsync(_eb, ctx.User, receiver, amount, msg))
|
||||
if (!await _cs.TransferAsync(_eb, ctx.User, receiver, amount, msg, N(amount)))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign));
|
||||
return;
|
||||
|
@@ -1,5 +1,9 @@
|
||||
using System.Text.Json;
|
||||
using YahooFinanceApi;
|
||||
using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using System.Globalization;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace NadekoBot.Modules.Searches;
|
||||
|
||||
@@ -17,19 +21,14 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
||||
if (!query.IsAlphaNumeric())
|
||||
return default;
|
||||
|
||||
var symbols = await Yahoo.Symbols(query)
|
||||
.Fields(Field.LongName,
|
||||
Field.Symbol,
|
||||
Field.RegularMarketPrice,
|
||||
Field.RegularMarketPreviousClose,
|
||||
Field.MarketCap,
|
||||
Field.FiftyDayAverageChangePercent,
|
||||
Field.TwoHundredDayAverageChangePercent,
|
||||
Field.AverageDailyVolume10Day,
|
||||
Field.FullExchangeName)
|
||||
.QueryAsync();
|
||||
using var http = _httpClientFactory.CreateClient();
|
||||
var data = await http.GetFromJsonAsync<YahooQueryModel>(
|
||||
$"https://query1.finance.yahoo.com/v7/finance/quote?symbols={query}");
|
||||
|
||||
var symbol = symbols.Values.FirstOrDefault();
|
||||
if (data is null)
|
||||
return default;
|
||||
|
||||
var symbol = data.QuoteResponse.Result.FirstOrDefault();
|
||||
|
||||
if (symbol is null)
|
||||
return default;
|
||||
@@ -79,11 +78,25 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static CsvConfiguration _csvConfig = new(CultureInfo.InvariantCulture)
|
||||
{
|
||||
PrepareHeaderForMatch = args => args.Header.Humanize(LetterCasing.Title)
|
||||
};
|
||||
|
||||
public async Task<IReadOnlyCollection<CandleData>> GetCandleDataAsync(string query)
|
||||
{
|
||||
var candles = await Yahoo.GetHistoricalAsync(query, DateTime.Now.Subtract(30.Days()));
|
||||
using var http = _httpClientFactory.CreateClient();
|
||||
await using var resStream = await http.GetStreamAsync(
|
||||
$"https://query1.finance.yahoo.com/v7/finance/download/{query}"
|
||||
+ $"?period1={DateTime.UtcNow.Subtract(30.Days()).ToTimestamp().Seconds}"
|
||||
+ $"&period2={DateTime.UtcNow.ToTimestamp().Seconds}"
|
||||
+ "&interval=1d");
|
||||
|
||||
return candles
|
||||
using var textReader = new StreamReader(resStream);
|
||||
using var csv = new CsvReader(textReader, _csvConfig);
|
||||
var records = csv.GetRecords<YahooFinanceCandleData>().ToArray();
|
||||
|
||||
return records
|
||||
.Map(static x => new CandleData(x.Open, x.Close, x.High, x.Low, x.Volume));
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace NadekoBot.Modules.Searches;
|
||||
|
||||
public class QuoteResponse
|
||||
{
|
||||
public class ResultModel
|
||||
{
|
||||
[JsonPropertyName("longName")]
|
||||
public string LongName { get; set; }
|
||||
|
||||
[JsonPropertyName("regularMarketPrice")]
|
||||
public double RegularMarketPrice { get; set; }
|
||||
|
||||
[JsonPropertyName("regularMarketPreviousClose")]
|
||||
public double RegularMarketPreviousClose { get; set; }
|
||||
|
||||
[JsonPropertyName("fullExchangeName")]
|
||||
public string FullExchangeName { get; set; }
|
||||
|
||||
[JsonPropertyName("averageDailyVolume10Day")]
|
||||
public int AverageDailyVolume10Day { get; set; }
|
||||
|
||||
[JsonPropertyName("fiftyDayAverageChangePercent")]
|
||||
public double FiftyDayAverageChangePercent { get; set; }
|
||||
|
||||
[JsonPropertyName("twoHundredDayAverageChangePercent")]
|
||||
public double TwoHundredDayAverageChangePercent { get; set; }
|
||||
|
||||
[JsonPropertyName("marketCap")]
|
||||
public long MarketCap { get; set; }
|
||||
|
||||
[JsonPropertyName("symbol")]
|
||||
public string Symbol { get; set; }
|
||||
}
|
||||
|
||||
[JsonPropertyName("result")]
|
||||
public List<ResultModel> Result { get; set; }
|
||||
|
||||
[JsonPropertyName("error")]
|
||||
public object Error { get; set; }
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
namespace NadekoBot.Modules.Searches;
|
||||
|
||||
public class YahooFinanceCandleData
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public decimal Open { get; set; }
|
||||
public decimal High { get; set; }
|
||||
public decimal Low { get; set; }
|
||||
public decimal Close { get; set; }
|
||||
public decimal AdjClose { get; set; }
|
||||
public long Volume { get; set; }
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace NadekoBot.Modules.Searches;
|
||||
|
||||
public class YahooQueryModel
|
||||
{
|
||||
[JsonPropertyName("quoteResponse")]
|
||||
public QuoteResponse QuoteResponse { get; set; }
|
||||
}
|
@@ -53,7 +53,7 @@ public class FeedsService : INService
|
||||
if (kvp.Value.Count == 0)
|
||||
continue;
|
||||
|
||||
var rssUrl = kvp.Key;
|
||||
var rssUrl = kvp.Value.First().Url;
|
||||
try
|
||||
{
|
||||
var feed = await FeedReader.ReadAsync(rssUrl);
|
||||
@@ -143,8 +143,9 @@ public class FeedsService : INService
|
||||
allSendTasks.Add(feedSendTasks.WhenAll());
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning("An error occured while getting rss stream: {Message}", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -319,9 +319,23 @@ public partial class Xp
|
||||
public async partial Task ClubDescription([Leftover] string desc = null)
|
||||
{
|
||||
if (_service.SetDescription(ctx.User.Id, desc))
|
||||
await ReplyConfirmLocalizedAsync(strs.club_desc_updated(Format.Bold(desc ?? "-")));
|
||||
{
|
||||
desc = string.IsNullOrWhiteSpace(desc)
|
||||
? "-"
|
||||
: desc;
|
||||
|
||||
var eb = _eb.Create(ctx)
|
||||
.WithAuthor(ctx.User)
|
||||
.WithTitle(GetText(strs.club_desc_update))
|
||||
.WithOkColor()
|
||||
.WithDescription(desc);
|
||||
|
||||
await ctx.Channel.EmbedAsync(eb);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_desc_update_failed);
|
||||
}
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
|
@@ -26,6 +26,7 @@
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.8.4" />
|
||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||
<PackageReference Include="CsvHelper" Version="27.2.1" />
|
||||
<PackageReference Include="Discord.Net" Version="3.5.0" />
|
||||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.92" />
|
||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
||||
@@ -81,7 +82,6 @@
|
||||
<!-- <PackageReference Include="System.Runtime.Experimental" Version="6.0.2" />-->
|
||||
|
||||
<!-- Used by .crypto command -->
|
||||
<PackageReference Include="YahooFinanceApi" Version="2.1.2" />
|
||||
|
||||
<!-- Used by stream notifications -->
|
||||
<PackageReference Include="TwitchLib.Api" Version="3.4.1" />
|
||||
|
@@ -17,7 +17,8 @@ public static class CurrencyServiceExtensions
|
||||
IUser from,
|
||||
IUser to,
|
||||
long amount,
|
||||
string? note)
|
||||
string? note,
|
||||
string formattedAmount)
|
||||
{
|
||||
var fromWallet = await cs.GetWalletAsync(from.Id);
|
||||
var toWallet = await cs.GetWalletAsync(to.Id);
|
||||
@@ -28,8 +29,8 @@ public static class CurrencyServiceExtensions
|
||||
{
|
||||
await to.SendConfirmAsync(ebs,
|
||||
string.IsNullOrWhiteSpace(note)
|
||||
? $"Gift from {from}"
|
||||
: $"Gift from {from}: {note}");
|
||||
? $"Received {formattedAmount} from {from} "
|
||||
: $"Received {formattedAmount} from {from}: {note}");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -116,6 +116,8 @@ public sealed class BehaviorHandler : IBehaviorHandler, INService
|
||||
usrMsg.Author.Id,
|
||||
usrMsg.Channel.Id,
|
||||
usrMsg.Content?.TrimTo(10));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
|
||||
|
||||
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
||||
{
|
||||
public const string BOT_VERSION = "4.1.3";
|
||||
public const string BOT_VERSION = "4.1.5";
|
||||
|
||||
public string Author
|
||||
=> "Kwoth#2452";
|
||||
|
@@ -838,7 +838,7 @@
|
||||
"club_user_ban_fail": "Failed to ban. You're either not the club owner, or that user is not in your club or applied to it.",
|
||||
"club_user_unbanned": "Unbanned user {0} in {1} club.",
|
||||
"club_user_unban_fail": "Failed to unban. You're either not the club owner, or that user is not in your club or applied to it.",
|
||||
"club_desc_updated": "Updated club description to {0}",
|
||||
"club_desc_update": "Club Description Updated",
|
||||
"club_desc_update_failed": "Failed changing club description.",
|
||||
"club_disbanded": "Club {0} has been disbanded",
|
||||
"club_disband_error": "Error. You are either not in a club, or you are not the owner of your club.",
|
||||
|
Reference in New Issue
Block a user