mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
23b3ad5837 | ||
|
18619b4d3a | ||
|
ef06388335 | ||
|
d1db54498b | ||
|
eef5b3f948 | ||
|
d86b5b2b6c | ||
|
127a46a9b8 | ||
|
a7e1e8a982 | ||
|
b0ac35b82e | ||
|
367135be6a | ||
|
f69f8548b0 | ||
|
449dbafff7 | ||
|
afba004d85 |
35
CHANGELOG.md
35
CHANGELOG.md
@@ -2,6 +2,40 @@
|
||||
|
||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||
|
||||
## [4.3.22] - 23.04.2023
|
||||
|
||||
### Added
|
||||
- Added `.setbanner` command (thx cata)
|
||||
|
||||
### Fixed
|
||||
- Fixed pagination error due to a missing emoji
|
||||
|
||||
|
||||
## [4.3.21] - 19.04.2023
|
||||
|
||||
### Fixed
|
||||
- Possible fix for a duplicate in `.h bank`
|
||||
- Fixed `.stock` command
|
||||
- Fixed `.clubapply` and `.clubaccept`
|
||||
- Removed some redundant discriminators
|
||||
|
||||
## [4.3.20] - 20.01.2024
|
||||
|
||||
### Fixed
|
||||
- Fixed `.config searches followedStreams.maxCount` not working
|
||||
|
||||
## [4.3.19] - 20.01.2024
|
||||
|
||||
### Added
|
||||
- Added `followedStreams.maxCount` to `searches.yml` which lets bot owners change the default of 10 per server
|
||||
|
||||
### Changed
|
||||
- Improvements to GPT ChatterBot (thx alexandra)
|
||||
- Add a personality prompt to tweak the way chatgpt bot behaves
|
||||
- Added Chat history support to chatgpt ChatterBot
|
||||
- Chatgpt token usage now correctly calculated
|
||||
- More chatgpt configs in `games.yml`
|
||||
|
||||
## [4.3.18] - 26.12.2023
|
||||
|
||||
### Added
|
||||
@@ -23,7 +57,6 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
### Removed
|
||||
|
||||
- `.revimg` and `.revav` as google removed reverse image search
|
||||
-
|
||||
|
||||
## [4.3.17] - 06.09.2023
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.104.0" />
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.204.0" />
|
||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
</ItemGroup>
|
||||
|
@@ -28,5 +28,10 @@ public class DiscordUser : DbEntity
|
||||
=> UserId.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
=> Username + "#" + Discriminator;
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Discriminator) || Discriminator == "0000")
|
||||
return Username;
|
||||
|
||||
return Username + "#" + Discriminator;
|
||||
}
|
||||
}
|
@@ -19,25 +19,25 @@ public class WaifuInfo : DbEntity
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var claimer = "no one";
|
||||
var status = string.Empty;
|
||||
|
||||
var waifuUsername = Waifu.Username.TrimTo(20);
|
||||
var claimerUsername = Claimer?.Username.TrimTo(20);
|
||||
var waifuUsername = Waifu.ToString().TrimTo(20);
|
||||
var claimer = Claimer?.ToString().TrimTo(20)
|
||||
?? "no one";
|
||||
|
||||
var affinity = Affinity?.ToString().TrimTo(20);
|
||||
|
||||
if (ClaimerId is not null)
|
||||
claimer = $"{claimerUsername}#{Claimer.Discriminator}";
|
||||
if (AffinityId is null)
|
||||
status = $"... but {waifuUsername}'s heart is empty";
|
||||
else if (AffinityId == ClaimerId)
|
||||
status = $"... and {waifuUsername} likes {claimerUsername} too <3";
|
||||
status = $"... and {waifuUsername} likes {claimer} too <3";
|
||||
else
|
||||
{
|
||||
status =
|
||||
$"... but {waifuUsername}'s heart belongs to {Affinity.Username.TrimTo(20)}#{Affinity.Discriminator}";
|
||||
$"... but {waifuUsername}'s heart belongs to {affinity}";
|
||||
}
|
||||
|
||||
return $"**{waifuUsername}#{Waifu.Discriminator}** - claimed by **{claimer}**\n\t{status}";
|
||||
return $"**{waifuUsername}** - claimed by **{claimer}**\n\t{status}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -146,4 +146,5 @@ public sealed class DoAsUserMessage : IUserMessage
|
||||
public MessageResolvedData ResolvedData => _msg.ResolvedData;
|
||||
|
||||
public IUserMessage ReferencedMessage => _msg.ReferencedMessage;
|
||||
public IMessageInteractionMetadata InteractionMetadata { get; }
|
||||
}
|
@@ -501,6 +501,16 @@ public partial class Administration
|
||||
if (success)
|
||||
await ReplyConfirmLocalizedAsync(strs.set_avatar);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
public async Task SetBanner([Leftover] string img = null)
|
||||
{
|
||||
var success = await _service.SetBanner(img);
|
||||
|
||||
if (success)
|
||||
await ReplyConfirmLocalizedAsync(strs.set_banner);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
|
@@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using System.Collections.Immutable;
|
||||
using Nadeko.Common;
|
||||
|
||||
namespace NadekoBot.Modules.Administration.Services;
|
||||
|
||||
@@ -321,6 +320,40 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> SetBanner(string img)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(img))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Uri.IsWellFormedUriString(img, UriKind.Absolute))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var uri = new Uri(img);
|
||||
|
||||
using var http = _httpFactory.CreateClient();
|
||||
using var sr = await http.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);
|
||||
|
||||
if (!sr.IsImage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sr.GetContentLength() > 8.Megabytes().Bytes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
await using var imageStream = await sr.Content.ReadAsStreamAsync();
|
||||
|
||||
await _client.CurrentUser.ModifyAsync(x => x.Banner = new Image(imageStream));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void ClearStartupCommands()
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
|
@@ -363,7 +363,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
if (before.Username != after.Username)
|
||||
{
|
||||
embed.WithTitle("👥 " + GetText(g, strs.username_changed))
|
||||
.WithDescription($"{before.Username}#{before.Discriminator} | {before.Id}")
|
||||
.WithDescription($"{before.Username} | {before.Id}")
|
||||
.AddField("Old Name", $"{before.Username}", true)
|
||||
.AddField("New Name", $"{after.Username}", true)
|
||||
.WithFooter(CurrentTime(g))
|
||||
@@ -905,7 +905,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
str = "🎙"
|
||||
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
||||
+ GetText(logChannel.Guild,
|
||||
strs.user_vmoved("👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
||||
strs.user_vmoved("👤" + Format.Bold(usr.Username),
|
||||
Format.Bold(beforeVch?.Name ?? ""),
|
||||
Format.Bold(afterVch?.Name ?? "")));
|
||||
}
|
||||
@@ -914,7 +914,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
str = "🎙"
|
||||
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
||||
+ GetText(logChannel.Guild,
|
||||
strs.user_vjoined("👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
||||
strs.user_vjoined("👤" + Format.Bold(usr.Username),
|
||||
Format.Bold(afterVch?.Name ?? "")));
|
||||
}
|
||||
else if (afterVch is null)
|
||||
@@ -922,7 +922,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
str = "🎙"
|
||||
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
||||
+ GetText(logChannel.Guild,
|
||||
strs.user_vleft("👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
||||
strs.user_vleft("👤" + Format.Bold(usr.Username),
|
||||
Format.Bold(beforeVch.Name ?? "")));
|
||||
}
|
||||
|
||||
|
@@ -239,7 +239,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
|
||||
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
||||
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user),
|
||||
$"**{usr.Username}#{usr.Discriminator}**",
|
||||
$"**{usr.Username}**",
|
||||
footer: $"ID: {usr.Id}");
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
|
||||
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
||||
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user),
|
||||
$"**{usr.Username}#{usr.Discriminator}**",
|
||||
$"**{usr.Username}**",
|
||||
footer: $"ID: {usr.Id}");
|
||||
}
|
||||
|
||||
|
@@ -79,8 +79,12 @@ public class ChatterBotService : IExecOnMessage
|
||||
case ChatBotImplementation.Gpt3:
|
||||
if (!string.IsNullOrWhiteSpace(_creds.Gpt3ApiKey))
|
||||
return new OfficialGpt3Session(_creds.Gpt3ApiKey,
|
||||
_gcs.Data.ChatGpt.Model,
|
||||
_gcs.Data.ChatGpt.ModelName,
|
||||
_gcs.Data.ChatGpt.ChatHistory,
|
||||
_gcs.Data.ChatGpt.MaxTokens,
|
||||
_gcs.Data.ChatGpt.MinTokens,
|
||||
_gcs.Data.ChatGpt.PersonalityPrompt,
|
||||
_client.CurrentUser.Username,
|
||||
_httpFactory);
|
||||
|
||||
Log.Information("Gpt3 will not work as the api key is missing.");
|
||||
@@ -199,7 +203,7 @@ public class ChatterBotService : IExecOnMessage
|
||||
}
|
||||
|
||||
_ = channel.TriggerTypingAsync();
|
||||
var response = await cbs.Think(message);
|
||||
var response = await cbs.Think(message, usrMsg.Author.ToString());
|
||||
await channel.SendConfirmAsync(_eb,
|
||||
title: null,
|
||||
response.SanitizeMentions(true)
|
||||
|
@@ -11,7 +11,13 @@ public class Gpt3Response
|
||||
|
||||
public class Choice
|
||||
{
|
||||
public string Text { get; set; }
|
||||
[JsonPropertyName("message")]
|
||||
public Message Message { get; init; }
|
||||
}
|
||||
|
||||
public class Message {
|
||||
[JsonPropertyName("content")]
|
||||
public string Content { get; init; }
|
||||
}
|
||||
|
||||
public class Gpt3ApiRequest
|
||||
@@ -19,12 +25,22 @@ public class Gpt3ApiRequest
|
||||
[JsonPropertyName("model")]
|
||||
public string Model { get; init; }
|
||||
|
||||
[JsonPropertyName("prompt")]
|
||||
public string Prompt { get; init; }
|
||||
[JsonPropertyName("messages")]
|
||||
public List<GPTMessage> Messages { get; init; }
|
||||
|
||||
[JsonPropertyName("temperature")]
|
||||
public int Temperature { get; init; }
|
||||
|
||||
[JsonPropertyName("max_tokens")]
|
||||
public int MaxTokens { get; init; }
|
||||
}
|
||||
|
||||
public class GPTMessage
|
||||
{
|
||||
[JsonPropertyName("role")]
|
||||
public string Role {get; init;}
|
||||
[JsonPropertyName("content")]
|
||||
public string Content {get; init;}
|
||||
[JsonPropertyName("name")]
|
||||
public string Name {get; init;}
|
||||
}
|
@@ -3,5 +3,5 @@ namespace NadekoBot.Modules.Games.Common.ChatterBot;
|
||||
|
||||
public interface IChatterBotSession
|
||||
{
|
||||
Task<string> Think(string input);
|
||||
Task<string> Think(string input, string username);
|
||||
}
|
@@ -18,7 +18,7 @@ public class OfficialCleverbotSession : IChatterBotSession
|
||||
_httpFactory = factory;
|
||||
}
|
||||
|
||||
public async Task<string> Think(string input)
|
||||
public async Task<string> Think(string input, string username)
|
||||
{
|
||||
using var http = _httpFactory.CreateClient();
|
||||
var dataString = await http.GetStringAsync(string.Format(QueryString, input, cs ?? ""));
|
||||
|
@@ -1,63 +1,101 @@
|
||||
#nullable disable
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Json;
|
||||
using SharpToken;
|
||||
using Antlr.Runtime;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace NadekoBot.Modules.Games.Common.ChatterBot;
|
||||
|
||||
public class OfficialGpt3Session : IChatterBotSession
|
||||
{
|
||||
private string Uri
|
||||
=> $"https://api.openai.com/v1/completions";
|
||||
=> $"https://api.openai.com/v1/chat/completions";
|
||||
|
||||
private readonly string _apiKey;
|
||||
private readonly string _model;
|
||||
private readonly int _maxHistory;
|
||||
private readonly int _maxTokens;
|
||||
private readonly int _minTokens;
|
||||
private readonly string _nadekoUsername;
|
||||
private readonly GptEncoding _encoding;
|
||||
private List<GPTMessage> messages = new();
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
|
||||
|
||||
|
||||
public OfficialGpt3Session(
|
||||
string apiKey,
|
||||
Gpt3Model model,
|
||||
ChatGptModel model,
|
||||
int chatHistory,
|
||||
int maxTokens,
|
||||
int minTokens,
|
||||
string personality,
|
||||
string nadekoUsername,
|
||||
IHttpClientFactory factory)
|
||||
{
|
||||
_apiKey = apiKey;
|
||||
_httpFactory = factory;
|
||||
switch (model)
|
||||
{
|
||||
case Gpt3Model.Ada001:
|
||||
_model = "text-ada-001";
|
||||
case ChatGptModel.Gpt35Turbo:
|
||||
_model = "gpt-3.5-turbo";
|
||||
break;
|
||||
case Gpt3Model.Babbage001:
|
||||
_model = "text-babbage-001";
|
||||
case ChatGptModel.Gpt4:
|
||||
_model = "gpt-4";
|
||||
break;
|
||||
case Gpt3Model.Curie001:
|
||||
_model = "text-curie-001";
|
||||
break;
|
||||
case Gpt3Model.Davinci003:
|
||||
_model = "text-davinci-003";
|
||||
case ChatGptModel.Gpt432k:
|
||||
_model = "gpt-4-32k";
|
||||
break;
|
||||
}
|
||||
|
||||
_maxHistory = chatHistory;
|
||||
_maxTokens = maxTokens;
|
||||
_minTokens = minTokens;
|
||||
_nadekoUsername = nadekoUsername;
|
||||
_encoding = GptEncoding.GetEncodingForModel(_model);
|
||||
messages.Add(new GPTMessage(){Role = "user", Content = personality, Name = _nadekoUsername});
|
||||
}
|
||||
|
||||
public async Task<string> Think(string input)
|
||||
public async Task<string> Think(string input, string username)
|
||||
{
|
||||
messages.Add(new GPTMessage(){Role = "user", Content = input, Name = username});
|
||||
while(messages.Count > _maxHistory + 2){
|
||||
messages.RemoveAt(1);
|
||||
}
|
||||
int tokensUsed = 0;
|
||||
foreach(GPTMessage message in messages){
|
||||
tokensUsed += _encoding.Encode(message.Content).Count;
|
||||
}
|
||||
tokensUsed *= 2; //Unsure why this is the case, but the token count chatgpt reports back is double what I calculate.
|
||||
//check if we have the minimum number of tokens available to use. Remove messages until we have enough, otherwise exit out and inform the user why.
|
||||
while(_maxTokens - tokensUsed <= _minTokens){
|
||||
if(messages.Count > 2){
|
||||
int tokens = _encoding.Encode(messages[1].Content).Count * 2;
|
||||
tokensUsed -= tokens;
|
||||
messages.RemoveAt(1);
|
||||
}
|
||||
else{
|
||||
return "Token count exceeded, please increase the number of tokens in the bot config and restart.";
|
||||
}
|
||||
}
|
||||
using var http = _httpFactory.CreateClient();
|
||||
http.DefaultRequestHeaders.Authorization = new("Bearer", _apiKey);
|
||||
var data = await http.PostAsJsonAsync(Uri, new Gpt3ApiRequest()
|
||||
{
|
||||
Model = _model,
|
||||
Prompt = input,
|
||||
MaxTokens = _maxTokens,
|
||||
Messages = messages,
|
||||
MaxTokens = _maxTokens - tokensUsed,
|
||||
Temperature = 1,
|
||||
});
|
||||
var dataString = await data.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<Gpt3Response>(dataString);
|
||||
|
||||
return response?.Choices[0]?.Text;
|
||||
string message = response?.Choices[0]?.Message?.Content;
|
||||
//Can't rely on the return to except, now that we need to add it to the messages list.
|
||||
_ = message ?? throw new ArgumentNullException(nameof(message));
|
||||
messages.Add(new GPTMessage(){Role = "assistant", Content = message, Name = _nadekoUsername});
|
||||
return message;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Games.Common;
|
||||
public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
||||
{
|
||||
[Comment("DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 2;
|
||||
public int Version { get; set; } = 3;
|
||||
|
||||
[Comment("Hangman related settings (.hangman command)")]
|
||||
public HangmanConfig Hangman { get; set; } = new()
|
||||
@@ -108,14 +108,22 @@ public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
||||
public sealed partial class ChatGptConfig
|
||||
{
|
||||
[Comment(@"Which GPT-3 Model should bot use.
|
||||
'ada001' - cheapest and fastest
|
||||
'babbage001' - 2nd option
|
||||
'curie001' - 3rd option
|
||||
'davinci003' - Most expensive, slowest")]
|
||||
public Gpt3Model Model { get; set; } = Gpt3Model.Ada001;
|
||||
gpt35turbo - cheapest
|
||||
gpt4 - 30x more expensive, higher quality
|
||||
gp432k - same model as above, but with a 32k token limit")]
|
||||
public ChatGptModel ModelName { get; set; } = ChatGptModel.Gpt35Turbo;
|
||||
|
||||
[Comment(@"How should the chat bot behave, what's its personality? (Usage of this counts towards the max tokens)")]
|
||||
public string PersonalityPrompt { get; set; } = "You are a chat bot willing to have a conversation with anyone about anything.";
|
||||
|
||||
[Comment(@"The maximum number of messages in a conversation that can be remembered. (This will increase the number of tokens used)")]
|
||||
public int ChatHistory { get; set; } = 5;
|
||||
|
||||
[Comment(@"The maximum number of tokens to use per GPT-3 API call")]
|
||||
public int MaxTokens { get; set; } = 100;
|
||||
|
||||
[Comment(@"The minimum number of tokens to use per GPT-3 API call, such that chat history is removed to make room.")]
|
||||
public int MinTokens { get; set; } = 30;
|
||||
}
|
||||
|
||||
[Cloneable]
|
||||
@@ -149,10 +157,9 @@ public enum ChatBotImplementation
|
||||
Gpt3
|
||||
}
|
||||
|
||||
public enum Gpt3Model
|
||||
public enum ChatGptModel
|
||||
{
|
||||
Ada001,
|
||||
Babbage001,
|
||||
Curie001,
|
||||
Davinci003
|
||||
Gpt35Turbo,
|
||||
Gpt4,
|
||||
Gpt432k
|
||||
}
|
@@ -28,20 +28,33 @@ public sealed class GamesConfigService : ConfigServiceBase<GamesConfig>
|
||||
long.TryParse,
|
||||
ConfigPrinters.ToString,
|
||||
val => val >= 0);
|
||||
|
||||
AddParsedProp("chatbot",
|
||||
gs => gs.ChatBot,
|
||||
ConfigParsers.InsensitiveEnum,
|
||||
ConfigPrinters.ToString);
|
||||
AddParsedProp("gpt.model",
|
||||
gs => gs.ChatGpt.Model,
|
||||
AddParsedProp("gpt.modelName",
|
||||
gs => gs.ChatGpt.ModelName,
|
||||
ConfigParsers.InsensitiveEnum,
|
||||
ConfigPrinters.ToString);
|
||||
AddParsedProp("gpt.personality",
|
||||
gs => gs.ChatGpt.PersonalityPrompt,
|
||||
ConfigParsers.String,
|
||||
ConfigPrinters.ToString);
|
||||
AddParsedProp("gpt.chathistory",
|
||||
gs => gs.ChatGpt.ChatHistory,
|
||||
int.TryParse,
|
||||
ConfigPrinters.ToString,
|
||||
val => val > 0);
|
||||
AddParsedProp("gpt.max_tokens",
|
||||
gs => gs.ChatGpt.MaxTokens,
|
||||
int.TryParse,
|
||||
ConfigPrinters.ToString,
|
||||
val => val > 0);
|
||||
AddParsedProp("gpt.min_tokens",
|
||||
gs => gs.ChatGpt.MinTokens,
|
||||
int.TryParse,
|
||||
ConfigPrinters.ToString,
|
||||
val => val > 0);
|
||||
|
||||
Migrate();
|
||||
}
|
||||
@@ -65,7 +78,16 @@ public sealed class GamesConfigService : ConfigServiceBase<GamesConfig>
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 2;
|
||||
c.ChatBot = ChatBotImplementation.Cleverbot;
|
||||
c.ChatBot = ChatBotImplementation.Cleverbot;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 3)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 3;
|
||||
c.ChatGpt.ModelName = ChatGptModel.Gpt35Turbo;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -292,7 +292,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
.WithTitle(GetText(strs.cmd_group_commands(group.Name)))
|
||||
.WithOkColor();
|
||||
|
||||
foreach (var cmd in group.Commands)
|
||||
foreach (var cmd in group.Commands.DistinctBy(x => x.Aliases[0]))
|
||||
{
|
||||
eb.AddField(prefix + cmd.Aliases.First(), cmd.RealSummary(_strings, _medusae, Culture, prefix));
|
||||
}
|
||||
|
@@ -85,11 +85,11 @@ public partial class Searches
|
||||
.WithUrl($"https://www.tradingview.com/chart/?symbol={stock.Symbol}")
|
||||
.WithTitle(stock.Name)
|
||||
.AddField(GetText(strs.price), $"{sign} **{price}**", true)
|
||||
.AddField(GetText(strs.market_cap), stock.MarketCap.ToString("C0", localCulture), true)
|
||||
.AddField(GetText(strs.market_cap), stock.MarketCap, true)
|
||||
.AddField(GetText(strs.volume_24h), stock.DailyVolume.ToString("C0", localCulture), true)
|
||||
.AddField("Change", $"{change} ({changePercent})", true)
|
||||
.AddField("Change 50d", $"{sign50}{change50}", true)
|
||||
.AddField("Change 200d", $"{sign200}{change200}", true)
|
||||
// .AddField("Change 50d", $"{sign50}{change50}", true)
|
||||
// .AddField("Change 200d", $"{sign200}{change200}", true)
|
||||
.WithFooter(stock.Exchange);
|
||||
|
||||
var message = await ctx.Channel.EmbedAsync(eb);
|
||||
|
@@ -1,5 +1,8 @@
|
||||
using CsvHelper;
|
||||
using AngleSharp;
|
||||
using AngleSharp.Html.Dom;
|
||||
using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using System.Globalization;
|
||||
using System.Net.Http.Json;
|
||||
@@ -23,33 +26,61 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
||||
return default;
|
||||
|
||||
using var http = _httpClientFactory.CreateClient();
|
||||
var data = await http.GetFromJsonAsync<YahooQueryModel>(
|
||||
$"https://query1.finance.yahoo.com/v7/finance/quote?symbols={query}");
|
||||
|
||||
if (data is null)
|
||||
return default;
|
||||
|
||||
var symbol = data.QuoteResponse.Result.FirstOrDefault();
|
||||
|
||||
if (symbol is null)
|
||||
return default;
|
||||
|
||||
var quoteHtmlPage = $"https://finance.yahoo.com/quote/{query.ToUpperInvariant()}";
|
||||
|
||||
var config = Configuration.Default.WithDefaultLoader();
|
||||
using var document = await BrowsingContext.New(config).OpenAsync(quoteHtmlPage);
|
||||
var divElem =
|
||||
document.QuerySelector(
|
||||
"#quote-header-info > div:nth-child(2) > div > div > h1");
|
||||
var tickerName = (divElem)?.TextContent;
|
||||
|
||||
var marketcap = document
|
||||
.QuerySelectorAll("table")
|
||||
.Skip(1)
|
||||
.First()
|
||||
.QuerySelector("tbody > tr > td:nth-child(2)")
|
||||
?.TextContent;
|
||||
|
||||
|
||||
var volume = document.QuerySelector("td[data-test='AVERAGE_VOLUME_3MONTH-value']")
|
||||
?.TextContent;
|
||||
|
||||
var close= document.QuerySelector("td[data-test='PREV_CLOSE-value']")
|
||||
?.TextContent ?? "0";
|
||||
|
||||
var price = document
|
||||
.QuerySelector("#quote-header-info")
|
||||
?.QuerySelector("fin-streamer[data-field='regularMarketPrice']")
|
||||
?.TextContent ?? close;
|
||||
|
||||
// var data = await http.GetFromJsonAsync<YahooQueryModel>(
|
||||
// $"https://query1.finance.yahoo.com/v7/finance/quote?symbols={query}");
|
||||
//
|
||||
// if (data is null)
|
||||
// return default;
|
||||
|
||||
// var symbol = data.QuoteResponse.Result.FirstOrDefault();
|
||||
|
||||
// if (symbol is null)
|
||||
// return default;
|
||||
|
||||
return new()
|
||||
{
|
||||
Name = symbol.LongName,
|
||||
Symbol = symbol.Symbol,
|
||||
Price = symbol.RegularMarketPrice,
|
||||
Close = symbol.RegularMarketPreviousClose,
|
||||
MarketCap = symbol.MarketCap,
|
||||
Change50d = symbol.FiftyDayAverageChangePercent,
|
||||
Change200d = symbol.TwoHundredDayAverageChangePercent,
|
||||
DailyVolume = symbol.AverageDailyVolume10Day,
|
||||
Exchange = symbol.FullExchangeName
|
||||
Name = tickerName,
|
||||
Symbol = query,
|
||||
Price = double.Parse(price, NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||
Close = double.Parse(close, NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||
MarketCap = marketcap,
|
||||
DailyVolume = (long)double.Parse(volume ?? "0", NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||
};
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log.Warning(ex, "Error getting stock data: {ErrorMessage}", ex.Message);
|
||||
Log.Warning(ex, "Error getting stock data: {ErrorMessage}", ex.ToString());
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -60,9 +91,9 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
|
||||
query = Uri.EscapeDataString(query);
|
||||
|
||||
|
||||
using var http = _httpClientFactory.CreateClient();
|
||||
|
||||
|
||||
var res = await http.GetStringAsync(
|
||||
"https://finance.yahoo.com/_finance_doubledown/api/resource/searchassist"
|
||||
+ $";searchTerm={query}"
|
||||
@@ -72,11 +103,11 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
||||
|
||||
if (data is null or { Items: null })
|
||||
return Array.Empty<SymbolData>();
|
||||
|
||||
|
||||
return data.Items
|
||||
.Where(x => x.Type == "S")
|
||||
.Select(x => new SymbolData(x.Symbol, x.Name))
|
||||
.ToList();
|
||||
.Where(x => x.Type == "S")
|
||||
.Select(x => new SymbolData(x.Symbol, x.Name))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static CsvConfiguration _csvConfig = new(CultureInfo.InvariantCulture)
|
||||
|
@@ -6,7 +6,7 @@ public class StockData
|
||||
public string Name { get; set; }
|
||||
public string Symbol { get; set; }
|
||||
public double Price { get; set; }
|
||||
public long MarketCap { get; set; }
|
||||
public string MarketCap { get; set; }
|
||||
public double Close { get; set; }
|
||||
public double Change50d { get; set; }
|
||||
public double Change200d { get; set; }
|
||||
|
@@ -28,6 +28,7 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
|
||||
private readonly IPubSub _pubSub;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly SearchesConfigService _config;
|
||||
|
||||
public TypedKey<List<StreamData>> StreamsOnlineKey { get; }
|
||||
public TypedKey<List<StreamData>> StreamsOfflineKey { get; }
|
||||
@@ -49,14 +50,16 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
IHttpClientFactory httpFactory,
|
||||
Bot bot,
|
||||
IPubSub pubSub,
|
||||
IEmbedBuilderService eb)
|
||||
IEmbedBuilderService eb,
|
||||
SearchesConfigService config)
|
||||
{
|
||||
_db = db;
|
||||
_client = client;
|
||||
_strings = strings;
|
||||
_pubSub = pubSub;
|
||||
_eb = eb;
|
||||
|
||||
_config = config;
|
||||
|
||||
_streamTracker = new(httpFactory, creds);
|
||||
|
||||
StreamsOnlineKey = new("streams.online");
|
||||
@@ -69,34 +72,34 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
{
|
||||
var ids = client.GetGuildIds();
|
||||
var guildConfigs = uow.Set<GuildConfig>()
|
||||
.AsQueryable()
|
||||
.Include(x => x.FollowedStreams)
|
||||
.Where(x => ids.Contains(x.GuildId))
|
||||
.ToList();
|
||||
.AsQueryable()
|
||||
.Include(x => x.FollowedStreams)
|
||||
.Where(x => ids.Contains(x.GuildId))
|
||||
.ToList();
|
||||
|
||||
_offlineNotificationServers = new(guildConfigs
|
||||
.Where(gc => gc.NotifyStreamOffline)
|
||||
.Select(x => x.GuildId)
|
||||
.ToList());
|
||||
|
||||
.Where(gc => gc.NotifyStreamOffline)
|
||||
.Select(x => x.GuildId)
|
||||
.ToList());
|
||||
|
||||
_deleteOnOfflineServers = new(guildConfigs
|
||||
.Where(gc => gc.DeleteStreamOnlineMessage)
|
||||
.Select(x => x.GuildId)
|
||||
.ToList());
|
||||
.Where(gc => gc.DeleteStreamOnlineMessage)
|
||||
.Select(x => x.GuildId)
|
||||
.ToList());
|
||||
|
||||
var followedStreams = guildConfigs.SelectMany(x => x.FollowedStreams).ToList();
|
||||
|
||||
_shardTrackedStreams = followedStreams.GroupBy(x => new
|
||||
{
|
||||
x.Type,
|
||||
Name = x.Username.ToLower()
|
||||
})
|
||||
.ToList()
|
||||
.ToDictionary(
|
||||
x => new StreamDataKey(x.Key.Type, x.Key.Name.ToLower()),
|
||||
x => x.GroupBy(y => y.GuildId)
|
||||
.ToDictionary(y => y.Key,
|
||||
y => y.AsEnumerable().ToHashSet()));
|
||||
{
|
||||
x.Type,
|
||||
Name = x.Username.ToLower()
|
||||
})
|
||||
.ToList()
|
||||
.ToDictionary(
|
||||
x => new StreamDataKey(x.Key.Type, x.Key.Name.ToLower()),
|
||||
x => x.GroupBy(y => y.GuildId)
|
||||
.ToDictionary(y => y.Key,
|
||||
y => y.AsEnumerable().ToHashSet()));
|
||||
|
||||
// shard 0 will keep track of when there are no more guilds which track a stream
|
||||
if (client.ShardId == 0)
|
||||
@@ -107,12 +110,12 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
_streamTracker.AddLastData(fs.CreateKey(), null, false);
|
||||
|
||||
_trackCounter = allFollowedStreams.GroupBy(x => new
|
||||
{
|
||||
x.Type,
|
||||
Name = x.Username.ToLower()
|
||||
})
|
||||
.ToDictionary(x => new StreamDataKey(x.Key.Type, x.Key.Name),
|
||||
x => x.Select(fs => fs.GuildId).ToHashSet());
|
||||
{
|
||||
x.Type,
|
||||
Name = x.Username.ToLower()
|
||||
})
|
||||
.ToDictionary(x => new StreamDataKey(x.Key.Type, x.Key.Name),
|
||||
x => x.Select(fs => fs.GuildId).ToHashSet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +155,7 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
continue;
|
||||
|
||||
var deleteGroups = failingStreams.GroupBy(x => x.Type)
|
||||
.ToDictionary(x => x.Key, x => x.Select(y => y.Name).ToList());
|
||||
.ToDictionary(x => x.Key, x => x.Select(y => y.Name).ToList());
|
||||
|
||||
await using var uow = _db.GetDbContext();
|
||||
foreach (var kvp in deleteGroups)
|
||||
@@ -165,9 +168,9 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
string.Join(", ", kvp.Value));
|
||||
|
||||
var toDelete = uow.Set<FollowedStream>()
|
||||
.AsQueryable()
|
||||
.Where(x => x.Type == kvp.Key && kvp.Value.Contains(x.Username))
|
||||
.ToList();
|
||||
.AsQueryable()
|
||||
.Where(x => x.Type == kvp.Key && kvp.Value.Contains(x.Username))
|
||||
.ToList();
|
||||
|
||||
uow.RemoveRange(toDelete);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -246,17 +249,17 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
if (_shardTrackedStreams.TryGetValue(key, out var fss))
|
||||
{
|
||||
await fss
|
||||
// send offline stream notifications only to guilds which enable it with .stoff
|
||||
.SelectMany(x => x.Value)
|
||||
.Where(x => _offlineNotificationServers.Contains(x.GuildId))
|
||||
.Select(fs => _client.GetGuild(fs.GuildId)
|
||||
?.GetTextChannel(fs.ChannelId)
|
||||
?.EmbedAsync(GetEmbed(fs.GuildId, stream)))
|
||||
.WhenAll();
|
||||
// send offline stream notifications only to guilds which enable it with .stoff
|
||||
.SelectMany(x => x.Value)
|
||||
.Where(x => _offlineNotificationServers.Contains(x.GuildId))
|
||||
.Select(fs => _client.GetGuild(fs.GuildId)
|
||||
?.GetTextChannel(fs.ChannelId)
|
||||
?.EmbedAsync(GetEmbed(fs.GuildId, stream)))
|
||||
.WhenAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async ValueTask HandleStreamsOnline(List<StreamData> onlineStreams)
|
||||
{
|
||||
@@ -266,30 +269,30 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
if (_shardTrackedStreams.TryGetValue(key, out var fss))
|
||||
{
|
||||
var messages = await fss.SelectMany(x => x.Value)
|
||||
.Select(async fs =>
|
||||
{
|
||||
var textChannel = _client.GetGuild(fs.GuildId)?.GetTextChannel(fs.ChannelId);
|
||||
.Select(async fs =>
|
||||
{
|
||||
var textChannel = _client.GetGuild(fs.GuildId)?.GetTextChannel(fs.ChannelId);
|
||||
|
||||
if (textChannel is null)
|
||||
return default;
|
||||
if (textChannel is null)
|
||||
return default;
|
||||
|
||||
var rep = new ReplacementBuilder().WithOverride("%user%", () => fs.Username)
|
||||
.WithOverride("%platform%", () => fs.Type.ToString())
|
||||
.Build();
|
||||
var rep = new ReplacementBuilder().WithOverride("%user%", () => fs.Username)
|
||||
.WithOverride("%platform%", () => fs.Type.ToString())
|
||||
.Build();
|
||||
|
||||
var message = string.IsNullOrWhiteSpace(fs.Message) ? "" : rep.Replace(fs.Message);
|
||||
var message = string.IsNullOrWhiteSpace(fs.Message) ? "" : rep.Replace(fs.Message);
|
||||
|
||||
var msg = await textChannel.EmbedAsync(GetEmbed(fs.GuildId, stream, false), message);
|
||||
var msg = await textChannel.EmbedAsync(GetEmbed(fs.GuildId, stream, false), message);
|
||||
|
||||
// only cache the ids of channel/message pairs
|
||||
if (_deleteOnOfflineServers.Contains(fs.GuildId))
|
||||
return (textChannel.Id, msg.Id);
|
||||
else
|
||||
return default;
|
||||
})
|
||||
.WhenAll();
|
||||
|
||||
// only cache the ids of channel/message pairs
|
||||
if(_deleteOnOfflineServers.Contains(fs.GuildId))
|
||||
return (textChannel.Id, msg.Id);
|
||||
else
|
||||
return default;
|
||||
})
|
||||
.WhenAll();
|
||||
|
||||
|
||||
// push online stream messages to redis
|
||||
// when streams go offline, any server which
|
||||
// has the online stream message deletion feature
|
||||
@@ -297,16 +300,15 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
try
|
||||
{
|
||||
var pairs = messages
|
||||
.Where(x => x != default)
|
||||
.Select(x => (x.Item1, x.Item2))
|
||||
.ToList();
|
||||
.Where(x => x != default)
|
||||
.Select(x => (x.Item1, x.Item2))
|
||||
.ToList();
|
||||
|
||||
if (pairs.Count > 0)
|
||||
await OnlineMessagesSent(key.Type, key.Name, pairs);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,10 +386,10 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var fss = uow.Set<FollowedStream>()
|
||||
.AsQueryable()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.OrderBy(x => x.Id)
|
||||
.ToList();
|
||||
.AsQueryable()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.OrderBy(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
// out of range
|
||||
if (fss.Count <= index)
|
||||
@@ -450,7 +452,9 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
GuildId = guildId
|
||||
};
|
||||
|
||||
if (gc.FollowedStreams.Count >= 10)
|
||||
var config = _config.Data;
|
||||
if (config.FollowedStreams.MaxCount is not -1
|
||||
&& gc.FollowedStreams.Count >= config.FollowedStreams.MaxCount)
|
||||
return null;
|
||||
|
||||
gc.FollowedStreams.Add(fs);
|
||||
@@ -475,10 +479,10 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
public IEmbedBuilder GetEmbed(ulong guildId, StreamData status, bool showViewers = true)
|
||||
{
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(status.Name)
|
||||
.WithUrl(status.StreamUrl)
|
||||
.WithDescription(status.StreamUrl)
|
||||
.AddField(GetText(guildId, strs.status), status.IsLive ? "🟢 Online" : "🔴 Offline", true);
|
||||
.WithTitle(status.Name)
|
||||
.WithUrl(status.StreamUrl)
|
||||
.WithDescription(status.StreamUrl)
|
||||
.AddField(GetText(guildId, strs.status), status.IsLive ? "🟢 Online" : "🔴 Offline", true);
|
||||
|
||||
if (showViewers)
|
||||
{
|
||||
@@ -527,7 +531,7 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
|
||||
public bool ToggleStreamOnlineDelete(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
|
@@ -8,18 +8,18 @@ public partial class SearchesConfig : ICloneable<SearchesConfig>
|
||||
{
|
||||
[Comment("DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 0;
|
||||
|
||||
|
||||
[Comment(@"Which engine should .search command
|
||||
'google_scrape' - default. Scrapes the webpage for results. May break. Requires no api keys.
|
||||
'google' - official google api. Requires googleApiKey and google.searchId set in creds.yml
|
||||
'searx' - requires at least one searx instance specified in the 'searxInstances' property below")]
|
||||
public WebSearchEngine WebSearchEngine { get; set; } = WebSearchEngine.Google_Scrape;
|
||||
|
||||
|
||||
[Comment(@"Which engine should .image command use
|
||||
'google'- official google api. googleApiKey and google.imageSearchId set in creds.yml
|
||||
'searx' requires at least one searx instance specified in the 'searxInstances' property below")]
|
||||
public ImgSearchEngine ImgSearchEngine { get; set; } = ImgSearchEngine.Google;
|
||||
|
||||
|
||||
|
||||
[Comment(@"Which search provider will be used for the `.youtube` command.
|
||||
|
||||
@@ -55,6 +55,15 @@ Use a fully qualified url. Example: https://my-invidious-instance.mydomain.com
|
||||
Instances specified must have api available.
|
||||
You check that by opening an api endpoint in your browser. For example: https://my-invidious-instance.mydomain.com/api/v1/trending")]
|
||||
public List<string> InvidiousInstances { get; set; } = new List<string>();
|
||||
|
||||
[Comment("Maximum number of followed streams per server")]
|
||||
public FollowedStreamConfig FollowedStreams { get; set; } = new FollowedStreamConfig();
|
||||
}
|
||||
|
||||
public sealed class FollowedStreamConfig
|
||||
{
|
||||
[Comment("Maximum number of streams that each server can follow. -1 for infinite")]
|
||||
public int MaxCount { get; set; } = 10;
|
||||
}
|
||||
|
||||
public enum YoutubeSearcher
|
||||
|
@@ -17,17 +17,22 @@ public class SearchesConfigService : ConfigServiceBase<SearchesConfig>
|
||||
sc => sc.WebSearchEngine,
|
||||
ConfigParsers.InsensitiveEnum,
|
||||
ConfigPrinters.ToString);
|
||||
|
||||
|
||||
AddParsedProp("imgEngine",
|
||||
sc => sc.ImgSearchEngine,
|
||||
ConfigParsers.InsensitiveEnum,
|
||||
ConfigPrinters.ToString);
|
||||
|
||||
|
||||
AddParsedProp("ytProvider",
|
||||
sc => sc.YtProvider,
|
||||
ConfigParsers.InsensitiveEnum,
|
||||
ConfigPrinters.ToString);
|
||||
|
||||
AddParsedProp("followedStreams.maxCount",
|
||||
sc => sc.FollowedStreams.MaxCount,
|
||||
int.TryParse,
|
||||
ConfigPrinters.ToString);
|
||||
|
||||
Migrate();
|
||||
}
|
||||
|
||||
@@ -41,5 +46,13 @@ public class SearchesConfigService : ConfigServiceBase<SearchesConfig>
|
||||
c.WebSearchEngine = WebSearchEngine.Google_Scrape;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 2)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 2;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -259,8 +259,8 @@ public partial class Xp
|
||||
await ReplyConfirmLocalizedAsync(strs.club_applied(Format.Bold(club.ToString())));
|
||||
else if (result == ClubApplyResult.Banned)
|
||||
await ReplyErrorLocalizedAsync(strs.club_join_banned);
|
||||
else if (result == ClubApplyResult.InsufficientLevel)
|
||||
await ReplyErrorLocalizedAsync(strs.club_insuff_lvl);
|
||||
else if (result == ClubApplyResult.AlreadyApplied)
|
||||
await ReplyErrorLocalizedAsync(strs.club_already_applied);
|
||||
else if (result == ClubApplyResult.AlreadyInAClub)
|
||||
await ReplyErrorLocalizedAsync(strs.club_already_in);
|
||||
}
|
||||
|
@@ -146,7 +146,7 @@ public class ClubService : INService, IClubService
|
||||
return ClubApplyResult.Banned;
|
||||
|
||||
if (club.Applicants.Any(x => x.UserId == du.Id))
|
||||
return ClubApplyResult.InsufficientLevel;
|
||||
return ClubApplyResult.AlreadyApplied;
|
||||
|
||||
var app = new ClubApplicants
|
||||
{
|
||||
|
@@ -27,8 +27,7 @@ public interface IClubService
|
||||
public enum ClubApplyResult
|
||||
{
|
||||
Success,
|
||||
|
||||
AlreadyInAClub,
|
||||
Banned,
|
||||
InsufficientLevel
|
||||
AlreadyApplied
|
||||
}
|
@@ -27,7 +27,7 @@
|
||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="CsvHelper" Version="28.0.1" />
|
||||
<PackageReference Include="Discord.Net" Version="3.203.0" />
|
||||
<PackageReference Include="Discord.Net" Version="3.204.0" />
|
||||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
|
||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.62.1.3205" />
|
||||
@@ -58,6 +58,7 @@
|
||||
<PackageReference Include="Scrutor" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
|
||||
<PackageReference Include="SharpToken" Version="1.2.14" />
|
||||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta17" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
|
||||
|
@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
|
||||
|
||||
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
||||
{
|
||||
public const string BOT_VERSION = "4.3.18";
|
||||
public const string BOT_VERSION = "4.3.22";
|
||||
|
||||
public string Author
|
||||
=> "Kwoth#2452";
|
||||
|
@@ -167,8 +167,8 @@ public static class MessageChannelExtensions
|
||||
private const string BUTTON_LEFT = "BUTTON_LEFT";
|
||||
private const string BUTTON_RIGHT = "BUTTON_RIGHT";
|
||||
|
||||
private static readonly IEmote _arrowLeft = Emote.Parse("<:x:969658061805465651>");
|
||||
private static readonly IEmote _arrowRight = Emote.Parse("<:x:969658062220701746>");
|
||||
private static readonly IEmote _arrowLeft = Emote.Parse("<:x:1232256519844790302>");
|
||||
private static readonly IEmote _arrowRight = Emote.Parse("<:x:1232256515298295838>");
|
||||
|
||||
public static Task SendPaginatedConfirmAsync(
|
||||
this ICommandContext ctx,
|
||||
|
@@ -195,6 +195,8 @@ setnick:
|
||||
setavatar:
|
||||
- setavatar
|
||||
- setav
|
||||
setbanner:
|
||||
- setbanner
|
||||
setgame:
|
||||
- setgame
|
||||
send:
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# DO NOT CHANGE
|
||||
version: 2
|
||||
version: 3
|
||||
# Hangman related settings (.hangman command)
|
||||
hangman:
|
||||
# The amount of currency awarded to the winner of a hangman game
|
||||
@@ -57,14 +57,19 @@ raceAnimals:
|
||||
# Which chatbot API should bot use.
|
||||
# 'cleverbot' - bot will use Cleverbot API.
|
||||
# 'gpt3' - bot will use GPT-3 API
|
||||
chatBot: gpt3
|
||||
chatBot: Gpt3
|
||||
|
||||
chatGpt:
|
||||
# Which GPT-3 Model should bot use.
|
||||
# 'ada001' - cheapest and fastest
|
||||
# 'babbage001' - 2nd option
|
||||
# 'curie001' - 3rd option
|
||||
# 'davinci003' - Most expensive, slowest
|
||||
model: davinci003
|
||||
# Which GPT-3 Model should bot use.
|
||||
# gpt35turbo - cheapest
|
||||
# gpt4 - 30x more expensive, higher quality
|
||||
# gp432k - same model as above, but with a 32k token limit
|
||||
modelName: Gpt35Turbo
|
||||
# How should the chat bot behave, whats its personality? (Usage of this counts towards the max tokens)
|
||||
personalityPrompt: You are a chat bot willing to have a conversation with anyone about anything.
|
||||
# The maximum number of messages in a conversation that can be remembered. (This will increase the number of tokens used)
|
||||
chatHistory: 5
|
||||
# The maximum number of tokens to use per GPT-3 API call
|
||||
maxTokens: 100
|
||||
# The minimum number of tokens to use per GPT-3 API call, such that chat history is removed to make room.
|
||||
minTokens: 30
|
@@ -1,5 +1,5 @@
|
||||
# DO NOT CHANGE
|
||||
version: 1
|
||||
version: 2
|
||||
# Which engine should .search command
|
||||
# 'google_scrape' - default. Scrapes the webpage for results. May break. Requires no api keys.
|
||||
# 'google' - official google api. Requires googleApiKey and google.searchId set in creds.yml
|
||||
@@ -41,3 +41,7 @@ searxInstances: []
|
||||
# Instances specified must have api available.
|
||||
# You check that by opening an api endpoint in your browser. For example: https://my-invidious-instance.mydomain.com/api/v1/trending
|
||||
invidiousInstances: []
|
||||
# Maximum number of followed streams per server
|
||||
followedStreams:
|
||||
# Maximum number of streams that each server can follow. -1 for infinite
|
||||
maxCount: 10
|
||||
|
@@ -402,6 +402,10 @@ setavatar:
|
||||
desc: "Sets a new avatar image for the NadekoBot. Parameter is a direct link to an image."
|
||||
args:
|
||||
- "https://i.imgur.com/xTG3a1I.jpg"
|
||||
setbanner:
|
||||
desc: "Sets a new banner image for the NadekoBot. Parameter is a direct link to an image. Supports gifs."
|
||||
args:
|
||||
- "https://i.imgur.com/xTG3a1I.jpg"
|
||||
setgame:
|
||||
desc: "Sets the bots game status to either Playing, Listening, or Watching."
|
||||
args:
|
||||
|
@@ -184,6 +184,7 @@
|
||||
"setrole": "Successfully added role {0} to user {1}",
|
||||
"setrole_err": "Failed to add role. I have insufficient permissions.",
|
||||
"set_avatar": "New avatar set!",
|
||||
"set_banner": "New banner set!",
|
||||
"set_channel_name": "New channel name set.",
|
||||
"set_game": "New game set!",
|
||||
"set_stream": "New stream set!",
|
||||
@@ -838,7 +839,7 @@
|
||||
"server_leaderboard": "Server XP Leaderboard",
|
||||
"global_leaderboard": "Global XP Leaderboard",
|
||||
"modified": "Modified server XP of the user {0} by {1}",
|
||||
"club_insuff_lvl": "You're insufficient level to join that club.",
|
||||
"club_already_applied": "You've already applied to that club.",
|
||||
"club_join_banned": "You're banned from that club.",
|
||||
"club_already_in": "You are already a member of a club.",
|
||||
"club_create_error_name": "Failed creating the club. A club with that name already exists.",
|
||||
|
Reference in New Issue
Block a user