diff --git a/Commands/BanMediaCommand.cs b/Commands/BanMediaCommand.cs
index b891932..ca9f12c 100644
--- a/Commands/BanMediaCommand.cs
+++ b/Commands/BanMediaCommand.cs
@@ -13,7 +13,9 @@ namespace ModerationBot.Commands;
public class BanMediaCommand(HomeserverResolverService hsResolver, PolicyEngine engine, ModerationBotRoomProvider roomProvider) : ICommand {
public string Name { get; } = "banmedia";
+ public string[]? Aliases { get; }
public string Description { get; } = "Create a policy banning a piece of media, must be used in reply to a message";
+ public bool Unlisted { get; }
public async Task<bool> CanInvoke(CommandContext ctx) {
//check if user is admin in control room
diff --git a/Commands/DbgAllRoomsArePolicyListsCommand.cs b/Commands/DbgAllRoomsArePolicyListsCommand.cs
index cd0bf6b..78e1979 100644
--- a/Commands/DbgAllRoomsArePolicyListsCommand.cs
+++ b/Commands/DbgAllRoomsArePolicyListsCommand.cs
@@ -10,7 +10,9 @@ namespace ModerationBot.Commands;
public class DbgAllRoomsArePolicyListsCommand
(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "dbg-allroomsarepolicy";
+ public string[]? Aliases { get; }
public string Description { get; } = "[Debug] mark all rooms as trusted policy rooms";
+ public bool Unlisted { get; }
private GenericRoom logRoom { get; set; }
public async Task<bool> CanInvoke(CommandContext ctx) {
diff --git a/Commands/DbgAniRainbowTest.cs b/Commands/DbgAniRainbowTest.cs
index b2216d1..eed6fa5 100644
--- a/Commands/DbgAniRainbowTest.cs
+++ b/Commands/DbgAniRainbowTest.cs
@@ -10,7 +10,9 @@ namespace ModerationBot.Commands;
public class DbgAniRainbowTest(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "dbg-ani-rainbow";
+ public string[]? Aliases { get; }
public string Description { get; } = "[Debug] animated rainbow :)";
+ public bool Unlisted { get; }
private GenericRoom logRoom { get; set; }
public async Task<bool> CanInvoke(CommandContext ctx) {
diff --git a/Commands/DbgDumpActivePoliciesCommand.cs b/Commands/DbgDumpActivePoliciesCommand.cs
index 285d792..81e81a0 100644
--- a/Commands/DbgDumpActivePoliciesCommand.cs
+++ b/Commands/DbgDumpActivePoliciesCommand.cs
@@ -7,10 +7,11 @@ using ModerationBot.AccountData;
namespace ModerationBot.Commands;
-public class DbgDumpActivePoliciesCommand
- (IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
+public class DbgDumpActivePoliciesCommand(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "dbg-dumppolicies";
+ public string[]? Aliases { get; }
public string Description { get; } = "[Debug] Dump all active policies";
+ public bool Unlisted { get; }
private GenericRoom logRoom { get; set; }
public async Task<bool> CanInvoke(CommandContext ctx) {
@@ -35,4 +36,4 @@ public class DbgDumpActivePoliciesCommand
await ctx.Room.SendFileAsync("all.json", new MemoryStream(engine.ActivePolicies.ToJson().AsBytes().ToArray()), contentType: "application/json");
await ctx.Room.SendFileAsync("by-type.json", new MemoryStream(engine.ActivePoliciesByType.ToJson().AsBytes().ToArray()), contentType: "application/json");
}
-}
+}
\ No newline at end of file
diff --git a/Commands/DbgDumpAllStateTypesCommand.cs b/Commands/DbgDumpAllStateTypesCommand.cs
index 7563cac..ac2036a 100644
--- a/Commands/DbgDumpAllStateTypesCommand.cs
+++ b/Commands/DbgDumpAllStateTypesCommand.cs
@@ -8,10 +8,11 @@ using ModerationBot.AccountData;
namespace ModerationBot.Commands;
-public class DbgDumpAllStateTypesCommand
- (IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
+public class DbgDumpAllStateTypesCommand(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "dbg-dumpstatetypes";
+ public string[]? Aliases { get; }
public string Description { get; } = "[Debug] Dump all state types we can find";
+ public bool Unlisted { get; }
private GenericRoom logRoom { get; set; }
public async Task<bool> CanInvoke(CommandContext ctx) {
@@ -36,7 +37,6 @@ public class DbgDumpAllStateTypesCommand
var botData = await ctx.Homeserver.GetAccountDataAsync<BotData>("gay.rory.moderation_bot_data");
logRoom = ctx.Homeserver.GetRoom(botData.LogRoom ?? botData.ControlRoom);
-
var joinedRooms = await ctx.Homeserver.GetJoinedRooms();
var tasks = joinedRooms.Select(GetStateTypes).ToAsyncEnumerable();
@@ -66,4 +66,4 @@ public class DbgDumpAllStateTypesCommand
html += "</table>";
return (raw, html);
}
-}
+}
\ No newline at end of file
diff --git a/Commands/JoinRoomCommand.cs b/Commands/JoinRoomCommand.cs
index eb22a70..e604a4e 100644
--- a/Commands/JoinRoomCommand.cs
+++ b/Commands/JoinRoomCommand.cs
@@ -8,7 +8,9 @@ namespace ModerationBot.Commands;
public class JoinRoomCommand(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "join";
+ public string[]? Aliases { get; }
public string Description { get; } = "Join arbitrary rooms";
+ public bool Unlisted { get; }
public async Task<bool> CanInvoke(CommandContext ctx) {
//check if user is admin in control room
@@ -25,7 +27,6 @@ public class JoinRoomCommand(IServiceProvider services, HomeserverProviderServic
}
public async Task Invoke(CommandContext ctx) {
-
var botData = await ctx.Homeserver.GetAccountDataAsync<BotData>("gay.rory.moderation_bot_data");
var policyRoom = ctx.Homeserver.GetRoom(botData.DefaultPolicyRoom ?? botData.ControlRoom);
var logRoom = ctx.Homeserver.GetRoom(botData.LogRoom ?? botData.ControlRoom);
@@ -33,9 +34,7 @@ public class JoinRoomCommand(IServiceProvider services, HomeserverProviderServic
await logRoom.SendMessageEventAsync(MessageFormatter.FormatSuccess($"Joining room {ctx.Args[0]} with reason: {string.Join(' ', ctx.Args[1..])}"));
var roomId = ctx.Args[0];
var servers = new List<string>() { ctx.Homeserver.ServerName };
- if (roomId.StartsWith('[')) {
-
- }
+ if (roomId.StartsWith('[')) { }
if (roomId.StartsWith('#')) {
var res = await ctx.Homeserver.ResolveRoomAliasAsync(roomId);
@@ -46,4 +45,4 @@ public class JoinRoomCommand(IServiceProvider services, HomeserverProviderServic
await ctx.Homeserver.JoinRoomAsync(roomId, servers, string.Join(' ', ctx.Args[1..]));
await logRoom.SendMessageEventAsync(MessageFormatter.FormatSuccess($"Resolved room {ctx.Args[0]} to {roomId} with servers: {string.Join(", ", servers)}"));
}
-}
+}
\ No newline at end of file
diff --git a/Commands/JoinSpaceMembersCommand.cs b/Commands/JoinSpaceMembersCommand.cs
index 6564e71..86ecf7e 100644
--- a/Commands/JoinSpaceMembersCommand.cs
+++ b/Commands/JoinSpaceMembersCommand.cs
@@ -10,7 +10,9 @@ namespace ModerationBot.Commands;
public class JoinSpaceMembersCommand(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "joinspacemembers";
+ public string[]? Aliases { get; }
public string Description { get; } = "Join all rooms in space";
+ public bool Unlisted { get; }
private GenericRoom logRoom { get; set; }
public async Task<bool> CanInvoke(CommandContext ctx) {
@@ -30,14 +32,12 @@ public class JoinSpaceMembersCommand(IServiceProvider services, HomeserverProvid
public async Task Invoke(CommandContext ctx) {
var botData = await ctx.Homeserver.GetAccountDataAsync<BotData>("gay.rory.moderation_bot_data");
logRoom = ctx.Homeserver.GetRoom(botData.LogRoom ?? botData.ControlRoom);
- var currentRooms = (await ctx.Homeserver.GetJoinedRooms()).Select(x=>x.RoomId).ToList();
+ var currentRooms = (await ctx.Homeserver.GetJoinedRooms()).Select(x => x.RoomId).ToList();
await logRoom.SendMessageEventAsync(MessageFormatter.FormatSuccess($"Joining space children of {ctx.Args[0]} with reason: {string.Join(' ', ctx.Args[1..])}"));
var roomId = ctx.Args[0];
var servers = new List<string>() { ctx.Homeserver.ServerName };
- if (roomId.StartsWith('[')) {
-
- }
+ if (roomId.StartsWith('[')) { }
if (roomId.StartsWith('#')) {
var res = await ctx.Homeserver.ResolveRoomAliasAsync(roomId);
@@ -70,4 +70,4 @@ public class JoinSpaceMembersCommand(IServiceProvider services, HomeserverProvid
return true;
}
-}
+}
\ No newline at end of file
diff --git a/Commands/ReloadPoliciesCommand.cs b/Commands/ReloadPoliciesCommand.cs
index b876145..2934185 100644
--- a/Commands/ReloadPoliciesCommand.cs
+++ b/Commands/ReloadPoliciesCommand.cs
@@ -8,7 +8,9 @@ namespace ModerationBot.Commands;
public class ReloadPoliciesCommand(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
public string Name { get; } = "reloadpolicies";
+ public string[]? Aliases { get; }
public string Description { get; } = "Reload policies";
+ public bool Unlisted { get; }
public async Task<bool> CanInvoke(CommandContext ctx) {
if (ctx.MessageEvent.Sender == "@cadence:cadence.moe") return true;
@@ -26,12 +28,11 @@ public class ReloadPoliciesCommand(IServiceProvider services, HomeserverProvider
}
public async Task Invoke(CommandContext ctx) {
-
var botData = await ctx.Homeserver.GetAccountDataAsync<BotData>("gay.rory.moderation_bot_data");
var policyRoom = ctx.Homeserver.GetRoom(botData.DefaultPolicyRoom ?? botData.ControlRoom);
var logRoom = ctx.Homeserver.GetRoom(botData.LogRoom ?? botData.ControlRoom);
-
+
await logRoom.SendMessageEventAsync(MessageFormatter.FormatSuccess($"Reloading policy lists due to manual invocation!!!!"));
await engine.ReloadActivePolicyLists();
}
-}
+}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index d783af1..67403c1 100644
--- a/Program.cs
+++ b/Program.cs
@@ -31,7 +31,7 @@ var host = builder.ConfigureServices((_, services) => {
services.AddSingleton<ModerationBotConfiguration>();
services.AddRoryLibMatrixServices();
- services.AddBot(withCommands: true);
+ services.AddMatrixBot().AddCommandHandler().DiscoverAllCommands();
services.AddSingleton<PolicyEngine>();
services.AddSingleton<ModerationBotRoomProvider>();
|