about summary refs log tree commit diff
path: root/MatrixRoomUtils.Bot/Bot/MRUBot.cs
diff options
context:
space:
mode:
authorEmma@Rory& <root@rory.gay>2023-07-27 18:19:13 +0200
committerEmma@Rory& <root@rory.gay>2023-07-27 18:19:13 +0200
commitad5c1364f2f8c4f50436da21b24d6a0b960da6ab (patch)
treed01f49bfe8f4fe97848e30f4f05ba6556db3e388 /MatrixRoomUtils.Bot/Bot/MRUBot.cs
parentMRU desktop start (diff)
downloadMatrixUtils-ad5c1364f2f8c4f50436da21b24d6a0b960da6ab.tar.xz
Add latest code before splitting projects
Diffstat (limited to 'MatrixRoomUtils.Bot/Bot/MRUBot.cs')
-rw-r--r--MatrixRoomUtils.Bot/Bot/MRUBot.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/MatrixRoomUtils.Bot/Bot/MRUBot.cs b/MatrixRoomUtils.Bot/Bot/MRUBot.cs
index 1bf5f67..bd24ec7 100644
--- a/MatrixRoomUtils.Bot/Bot/MRUBot.cs
+++ b/MatrixRoomUtils.Bot/Bot/MRUBot.cs
@@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Logging;
 
-namespace MatrixRoomUtils.Bot.Bot; 
+namespace MatrixRoomUtils.Bot.Bot;
 
 public class MRUBot : IHostedService {
     private readonly HomeserverProviderService _homeserverProviderService;
@@ -58,9 +58,10 @@ public class MRUBot : IHostedService {
                     x.Type == "m.room.member" && x.StateKey == hs.WhoAmI.UserId);
             _logger.LogInformation(
                 $"Got invite to {args.Key} by {inviteEvent.Sender} with reason: {(inviteEvent.TypedContent as RoomMemberEventData).Reason}");
-            if (inviteEvent.Sender == "@emma:rory.gay") {
+            if (inviteEvent.Sender.EndsWith(":rory.gay") || inviteEvent.Sender == "@mxidupwitch:the-apothecary.club" ) {
                 try {
-                    await (await hs.GetRoom(args.Key)).JoinAsync(reason: "I was invited by Emma (Rory&)!");
+                    var senderProfile = await hs.GetProfile(inviteEvent.Sender);
+                    await (await hs.GetRoom(args.Key)).JoinAsync(reason: $"I was invited by {senderProfile.DisplayName ?? inviteEvent.Sender}!");
                 }
                 catch (Exception e) {
                     _logger.LogError(e.ToString());
@@ -76,7 +77,7 @@ public class MRUBot : IHostedService {
             // _logger.LogInformation(eventResponse.ToJson(indent: false));
             if (@event is { Type: "m.room.message", TypedContent: RoomMessageEventData message }) {
                 if (message is { MessageType: "m.text" } && message.Body.StartsWith(_configuration.Prefix)) {
-                    
+
                     var command = _commands.FirstOrDefault(x => x.Name == message.Body.Split(' ')[0][_configuration.Prefix.Length..]);
                     if (command == null) {
                         await room.SendMessageEventAsync("m.room.message",
@@ -111,4 +112,4 @@ public class MRUBot : IHostedService {
     public async Task StopAsync(CancellationToken cancellationToken) {
         _logger.LogInformation("Shutting down bot!");
     }
-}
\ No newline at end of file
+}