about summary refs log tree commit diff
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
parentMRU desktop start (diff)
downloadMatrixUtils-ad5c1364f2f8c4f50436da21b24d6a0b960da6ab.tar.xz
Add latest code before splitting projects
-rw-r--r--MatrixRoomUtils.Bot/Bot/MRUBot.cs11
-rw-r--r--MatrixRoomUtils.Bot/MatrixRoomUtils.Bot.csproj2
-rw-r--r--MatrixRoomUtils.Core/Helpers/SyncHelper.cs2
3 files changed, 8 insertions, 7 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
+}
diff --git a/MatrixRoomUtils.Bot/MatrixRoomUtils.Bot.csproj b/MatrixRoomUtils.Bot/MatrixRoomUtils.Bot.csproj
index 5eba4fd..d9b2931 100644
--- a/MatrixRoomUtils.Bot/MatrixRoomUtils.Bot.csproj
+++ b/MatrixRoomUtils.Bot/MatrixRoomUtils.Bot.csproj
@@ -28,7 +28,7 @@
     <Content Include="appsettings*.json">

       <CopyToOutputDirectory>Always</CopyToOutputDirectory>

     </Content>

-    <Content Update="appsettings.Local.json">

+    <Content Update="appsettings.Local.emmalocal.json">

       <CopyToOutputDirectory>Always</CopyToOutputDirectory>

     </Content>

   </ItemGroup>

diff --git a/MatrixRoomUtils.Core/Helpers/SyncHelper.cs b/MatrixRoomUtils.Core/Helpers/SyncHelper.cs
index ea9317e..e12164c 100644
--- a/MatrixRoomUtils.Core/Helpers/SyncHelper.cs
+++ b/MatrixRoomUtils.Core/Helpers/SyncHelper.cs
@@ -42,7 +42,7 @@ public class SyncHelper {
 
             // var res = await JsonSerializer.DeserializeAsync<SyncResult>(await req.Content.ReadAsStreamAsync());
 
-#if DEBUG
+#if DEBUG && false
             var jsonObj = await req.Content.ReadFromJsonAsync<JsonElement>();
             try {
                 await _homeServer._httpClient.PostAsJsonAsync(