Compare commits

...

6 Commits
5.3.9 ... v5

14 changed files with 96 additions and 52 deletions

5
.gitignore vendored
View File

@@ -370,3 +370,8 @@ __pycache__/
### VisualStudio Patch ###
build/
site/
## AI
.aider.*
PROMPT.md

View File

@@ -29,6 +29,10 @@ variables:
build:
stage: build
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_TAG
script:
- |
VERSION_STRING=""
@@ -54,6 +58,8 @@ upload-builds:
stage: upload-builds
image: alpine:latest
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_TAG
script:
- apk add --no-cache curl tar zip
@@ -83,6 +89,8 @@ release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_TAG
script:
- |
@@ -130,7 +138,6 @@ publish-medusa-package:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
script:
- LAST_TAG=$(git describe --tags --abbrev=0)
- if [ $CI_COMMIT_TAG ];then MEDUSA_VERSION="$CI_COMMIT_TAG"; else MEDUSA_VERSION="$LAST_TAG-alpha$CI_COMMIT_SHORT_SHA"; fi
@@ -162,6 +169,8 @@ docker-build:
- docker push "$CI_REGISTRY_IMAGE${tag}"
# Run this job in a branch where a Dockerfile exists
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
exists:
- Dockerfile

View File

@@ -1,4 +1,4 @@
Copyright 2023 Kwoth
Copyright 2025 Breaker
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -12,8 +12,6 @@ ProjectSection(SolutionItems) = preProject
README.md = README.md
.gitlab-ci.yml = .gitlab-ci.yml
Dockerfile = Dockerfile
migrate.ps1 = migrate.ps1
remove-migration.ps1 = remove-migration.ps1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NadekoBot", "src\NadekoBot\NadekoBot.csproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"

View File

@@ -1,9 +1,4 @@
[![nadeko0](https://cdn.nadeko.bot/tutorial/docs-top.png)](https://nadeko.bot/)
[![nadeko1](https://cdn.nadeko.bot/tutorial/docs-mid.png)](https://invite.nadeko.bot/)
- Nadeko has been moved to https://github.com/nadeko-bot/nadekobot
[![nadeko2](https://cdn.nadeko.bot/tutorial/docs-bot.png)](https://nadeko.bot/commands)
### Useful links
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/latest)
- [Discord support server](https://discord.nadeko.bot)
- This repo will stay here as a v3, v4 and v5 archive

View File

@@ -97,9 +97,9 @@ public partial class Administration : NadekoModule<AdministrationService>
var (enabled, channels) = _service.GetDelMsgOnCmdData(ctx.Guild.Id);
var embed = CreateEmbed()
.WithOkColor()
.WithTitle(GetText(strs.server_delmsgoncmd))
.WithDescription(enabled ? "✅" : "❌");
.WithOkColor()
.WithTitle(GetText(strs.server_delmsgoncmd))
.WithDescription(enabled ? "✅" : "❌");
var str = string.Join("\n",
channels.Select(x =>
@@ -301,6 +301,16 @@ public partial class Administration : NadekoModule<AdministrationService>
public Task Delete(ulong messageId, ParsedTimespan timespan = null)
=> Delete((ITextChannel)ctx.Channel, messageId, timespan);
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Delete(MessageLink messageLink, ParsedTimespan timespan = null)
{
if (messageLink.Channel is not ITextChannel tc)
return;
await Delete(tc, messageLink.Message.Id, timespan);
}
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Delete(ITextChannel channel, ulong messageId, ParsedTimespan timespan = null)
@@ -373,7 +383,8 @@ public partial class Administration : NadekoModule<AdministrationService>
if (ctx.Channel is not SocketTextChannel stc)
return;
var t = stc.Threads.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase));
var t = stc.Threads.FirstOrDefault(
x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase));
if (t is null)
{
@@ -450,7 +461,8 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task SetServerBanner([Leftover] string img = null)
{
// Tier2 or higher is required to set a banner.
if (ctx.Guild.PremiumTier is PremiumTier.Tier1 or PremiumTier.None) return;
if (ctx.Guild.PremiumTier is PremiumTier.Tier1 or PremiumTier.None)
return;
var result = await _service.SetServerBannerAsync(ctx.Guild, img);

View File

@@ -111,8 +111,20 @@ public partial class OpenAiApiSession : IChatterBotSession
});
var dataString = await data.Content.ReadAsStringAsync();
try
{
data.EnsureSuccessStatusCode();
}
catch (Exception ex)
{
Log.Error(ex, "Failed to get response from OpenAI: {Message}", ex.Message);
return new Error<string>("Failed to get response from OpenAI");
}
try
{
var response = JsonConvert.DeserializeObject<OpenAiCompletionResponse>(dataString);
// Log.Information("Received response: {Response} ", dataString);

View File

@@ -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();
}

View File

@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
namespace NadekoBot.Modules.Games;
public sealed class FishCatch
{
[Key]
public int Id { get; set; }

View File

@@ -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 =

View File

@@ -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; }
}
}

View File

@@ -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
{

View File

@@ -30,4 +30,5 @@ public static class SocketMessageComponentExtensions
string text,
bool ephemeral = false)
=> smc.RespondAsync(sender, text, MsgType.Ok, ephemeral);
}

View File

@@ -4134,7 +4134,11 @@ edit:
text:
desc: "The new text content of the edited message."
delete:
desc: Deletes a single message given the channel and message ID. If channel is ommited, message will be searched for in the current channel. You can also specify time parameter after which the message will be deleted (up to 7 days). This timer won't persist through bot restarts.
desc: |-
Deletes a single message given the channel and message ID, or a message link.
If channel is omitted, message will be searched for in the current channel.
You can also specify time parameter after which the message will be deleted (up to 7 days).
This timer won't persist through bot restarts.
ex:
- '#chat 771562360594628608'
- 771562360594628608
@@ -4144,6 +4148,10 @@ delete:
desc: "The id of a specific message within a channel, used to target the deletion operation."
time:
desc: "The duration after which the message should be automatically deleted."
- messageLink:
desc: "The link of the message to delete. It must be on the same server."
time:
desc: "The duration after which the message should be automatically deleted."
- channel:
desc: "The channel where the message is located or should be searched for."
messageId: