From 699a5e0c8c1c69047ba9f5b8156b6d34375037af Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 21 Jan 2023 00:33:07 +0100 Subject: [PATCH] Added bot_owner_only attribute to medusa system. Upped version to 4..3.11 --- CHANGELOG.md | 32 ++++ .../Attributes/bot_owner_onlyAttribute.cs | 7 + .../Common/Medusa/MedusaLoaderService.cs | 4 + src/NadekoBot/Common/Medusa/TypeWrapper.cs | 143 ------------------ src/NadekoBot/Services/Impl/StatsService.cs | 2 +- 5 files changed, 44 insertions(+), 144 deletions(-) create mode 100644 src/Nadeko.Medusa/Attributes/bot_owner_onlyAttribute.cs delete mode 100644 src/NadekoBot/Common/Medusa/TypeWrapper.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b21f852f..abeadcce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,38 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o +## [4.3.11] - 21.01.2023 + +### Added + +- Added `.doas` Bot owner only command +- Added `.stickeradd` command + +### Changed + +- `.waifuinfo` optimized +- You can now specify an optional custom message in `.feed` and `.yun` which will be posted along with an update +- Greet/bye messages will now get disabled if they're set to a deleted/unknown channel +- Updated response strings +- `.translate` now supports many more languages +- `.translangs` prettier output + +### Fixed + +- Added logging for thread events +- Fixed a bug for `.quotedeleteauthor` causing the executing user to delete own messages +- Fixed TimeOut punishment not alklowing duration +- Fixed a nullref in streamrole service +- Fixed some potential causes for ratelimit due to default message retry settings +- Fixed a patron rewards bug caused by monthly donation checking not accounting for year increase +- Fixed a patron rewards bug for users who connected the same discord account with multiple patreon accounts +- `.deletecurrency` will now also reset banked currency +- Fixed DMHelpText reply +- `.h` command show now properly show both channel and server user permission requirements +- Many fixes and improvements to medusa system +- Fixed trivia --nohint +- `.joinrace` will no longer fail if the user isn't in the database yet + ## [4.3.10] - 10.11.2022 ### Added diff --git a/src/Nadeko.Medusa/Attributes/bot_owner_onlyAttribute.cs b/src/Nadeko.Medusa/Attributes/bot_owner_onlyAttribute.cs new file mode 100644 index 000000000..a49727bd1 --- /dev/null +++ b/src/Nadeko.Medusa/Attributes/bot_owner_onlyAttribute.cs @@ -0,0 +1,7 @@ +namespace Nadeko.Snake; + +[AttributeUsage(AttributeTargets.Method)] +public sealed class bot_owner_onlyAttribute : MedusaPermAttribute +{ + +} \ No newline at end of file diff --git a/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs b/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs index f7ee6a98e..4fca69e72 100644 --- a/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs +++ b/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs @@ -434,6 +434,10 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, else if (bp.ChannelPerm is { } cp) cb.AddPrecondition(new BotPermAttribute(cp)); } + else if (ubp is bot_owner_onlyAttribute) + { + cb.AddPrecondition(new OwnerOnlyAttribute()); + } } cb.WithPriority(cmd.Priority); diff --git a/src/NadekoBot/Common/Medusa/TypeWrapper.cs b/src/NadekoBot/Common/Medusa/TypeWrapper.cs deleted file mode 100644 index fb6b3e1a5..000000000 --- a/src/NadekoBot/Common/Medusa/TypeWrapper.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System.Globalization; -using System.Reflection; - -namespace Nadeko.Medusa; - -public sealed class TypeWrapper : Type -{ - private readonly int _hashCode; - - public TypeWrapper(Type t) - { - _hashCode = t.GetHashCode(); - Namespace = t.Namespace; - Name = t.Name; - FullName = t.FullName; - IsGenericType = t.IsGenericType; - IsConstructedGenericType = t.IsConstructedGenericType; - } - - public override bool IsGenericType { get; } - public override bool IsConstructedGenericType { get; } - - public override object[] GetCustomAttributes(bool inherit) - => throw new NotImplementedException(); - - public override object[] GetCustomAttributes(Type attributeType, bool inherit) - => throw new NotImplementedException(); - - public override bool IsDefined(Type attributeType, bool inherit) - => throw new NotImplementedException(); - - public override Module Module { get; } - public override string? Namespace { get; } - public override string Name { get; } - - protected override TypeAttributes GetAttributeFlagsImpl() - => throw new NotImplementedException(); - - protected override ConstructorInfo? GetConstructorImpl( - BindingFlags bindingAttr, - Binder? binder, - CallingConventions callConvention, - Type[] types, - ParameterModifier[]? modifiers) - => throw new NotImplementedException(); - - public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override Type? GetElementType() - => throw new NotImplementedException(); - - public override EventInfo? GetEvent(string name, BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override EventInfo[] GetEvents(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override FieldInfo? GetField(string name, BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override FieldInfo[] GetFields(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override MemberInfo[] GetMembers(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - protected override MethodInfo? GetMethodImpl( - string name, - BindingFlags bindingAttr, - Binder? binder, - CallingConventions callConvention, - Type[]? types, - ParameterModifier[]? modifiers) - => throw new NotImplementedException(); - - public override MethodInfo[] GetMethods(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override object? InvokeMember( - string name, - BindingFlags invokeAttr, - Binder? binder, - object? target, - object?[]? args, - ParameterModifier[]? modifiers, - CultureInfo? culture, - string[]? namedParameters) - => throw new NotImplementedException(); - - public override Type UnderlyingSystemType { get; } - - protected override bool IsArrayImpl() - => throw new NotImplementedException(); - - protected override bool IsByRefImpl() - => throw new NotImplementedException(); - - protected override bool IsCOMObjectImpl() - => throw new NotImplementedException(); - - protected override bool IsPointerImpl() - => throw new NotImplementedException(); - - protected override bool IsPrimitiveImpl() - => throw new NotImplementedException(); - - public override Assembly Assembly { get; } - public override string? AssemblyQualifiedName { get; } - public override Type? BaseType { get; } - public override string? FullName { get; } - public override Guid GUID { get; } - - protected override PropertyInfo? GetPropertyImpl( - string name, - BindingFlags bindingAttr, - Binder? binder, - Type? returnType, - Type[]? types, - ParameterModifier[]? modifiers) - => throw new NotImplementedException(); - - protected override bool HasElementTypeImpl() - => throw new NotImplementedException(); - - public override Type? GetNestedType(string name, BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override Type[] GetNestedTypes(BindingFlags bindingAttr) - => throw new NotImplementedException(); - - public override int GetHashCode() - => _hashCode; - - public override Type? GetInterface(string name, bool ignoreCase) - => throw new NotImplementedException(); - - public override Type[] GetInterfaces() - => throw new NotImplementedException(); -} \ No newline at end of file diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index e0224139a..4427fadcd 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Services; public sealed class StatsService : IStatsService, IReadyExecutor, INService { - public const string BOT_VERSION = "4.3.10"; + public const string BOT_VERSION = "4.3.11"; public string Author => "Kwoth#2452";