mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6c7ac44ed0 | ||
|
542cdc2d0d | ||
|
02fa501530 | ||
|
556142c5ce | ||
|
3db5a71d01 | ||
|
06f692283b |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -369,4 +369,9 @@ __pycache__/
|
||||
|
||||
### VisualStudio Patch ###
|
||||
build/
|
||||
site/
|
||||
site/
|
||||
|
||||
## AI
|
||||
|
||||
.aider.*
|
||||
PROMPT.md
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
||||
|
@@ -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}"
|
||||
|
11
README.md
11
README.md
@@ -1,9 +1,4 @@
|
||||
[](https://nadeko.bot/)
|
||||
|
||||
[](https://invite.nadeko.bot/)
|
||||
|
||||
[](https://nadeko.bot/commands)
|
||||
|
||||
### Useful links
|
||||
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/latest)
|
||||
- [Discord support server](https://discord.nadeko.bot)
|
||||
- Nadeko has been moved to https://github.com/nadeko-bot/nadekobot
|
||||
|
||||
- This repo will stay here as a v3, v4 and v5 archive
|
@@ -54,7 +54,7 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
else
|
||||
await Response().Pending(strs.imageonly_disable).SendAsync();
|
||||
}
|
||||
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
@@ -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 =>
|
||||
@@ -221,7 +221,7 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
[BotPerm(GuildPerm.ManageChannels)]
|
||||
public async Task CreaTxtChanl([Leftover] string channelName)
|
||||
{
|
||||
var txtCh = await ctx.Guild.CreateTextChannelAsync(channelName);
|
||||
var txtCh = await ctx.Guild.CreateTextChannelAsync(channelName);
|
||||
await Response().Confirm(strs.createtextchan(Format.Bold(txtCh.Name))).SendAsync();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -360,11 +370,11 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
{
|
||||
if (ctx.Channel is not SocketTextChannel stc)
|
||||
return;
|
||||
|
||||
|
||||
await stc.CreateThreadAsync(name, message: ctx.Message.ReferencedMessage);
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
|
||||
[Cmd]
|
||||
[BotPerm(ChannelPermission.ManageThreads)]
|
||||
[UserPerm(ChannelPermission.ManageThreads)]
|
||||
@@ -373,14 +383,15 @@ 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)
|
||||
{
|
||||
await Response().Error(strs.not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await t.DeleteAsync();
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
@@ -406,7 +417,7 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
await Response().Confirm(strs.autopublish_disable).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.ManageNicknames)]
|
||||
[BotPerm(GuildPerm.ChangeNickname)]
|
||||
@@ -450,8 +461,9 @@ 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);
|
||||
|
||||
switch (result)
|
||||
@@ -472,7 +484,7 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPermission.ManageGuild)]
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
||||
}
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user