about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-06 18:29:15 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-06 18:29:15 +0200
commita2e5c9dcb8f686c74410f418b172d673ff376472 (patch)
tree66184cfa0f382e7941bb5a94d59e7c4de80c8bfa
parentUnit tests, small refactors (diff)
downloadLibMatrix.ExampleBot-a2e5c9dcb8f686c74410f418b172d673ff376472.tar.xz
Small refactors
-rw-r--r--Bot/MRUBot.cs9
1 files changed, 6 insertions, 3 deletions
diff --git a/Bot/MRUBot.cs b/Bot/MRUBot.cs
index 0211f74..8cf4f1f 100644
--- a/Bot/MRUBot.cs
+++ b/Bot/MRUBot.cs
@@ -4,6 +4,7 @@ using LibMatrix.EventTypes.Spec;
 using LibMatrix.EventTypes.Spec.State;
 using LibMatrix.ExampleBot.Bot.Interfaces;
 using LibMatrix.Extensions;
+using LibMatrix.Helpers;
 using LibMatrix.Homeservers;
 using LibMatrix.Services;
 using Microsoft.Extensions.DependencyInjection;
@@ -44,6 +45,8 @@ public class MRUBot : IHostedService {
             throw;
         }
 
+        var syncHelper = new SyncHelper(hs);
+
         await (hs.GetRoom("!DoHEdFablOLjddKWIp:rory.gay")).JoinAsync();
 
         // foreach (var room in await hs.GetJoinedRooms()) {
@@ -54,7 +57,7 @@ public class MRUBot : IHostedService {
         //     _logger.LogInformation($"Got room state for {room.RoomId}!");
         // }
 
-        hs.SyncHelper.InviteReceivedHandlers.Add(async Task (args) => {
+        syncHelper.InviteReceivedHandlers.Add(async Task (args) => {
             var inviteEvent =
                 args.Value.InviteState.Events.FirstOrDefault(x =>
                     x.Type == "m.room.member" && x.StateKey == hs.UserId);
@@ -71,7 +74,7 @@ public class MRUBot : IHostedService {
                 }
             }
         });
-        hs.SyncHelper.TimelineEventHandlers.Add(async @event => {
+        syncHelper.TimelineEventHandlers.Add(async @event => {
             _logger.LogInformation(
                 "Got timeline event in {}: {}", @event.RoomId, @event.ToJson(indent: false, ignoreNull: true));
 
@@ -100,7 +103,7 @@ public class MRUBot : IHostedService {
                 }
             }
         });
-        await hs.SyncHelper.RunSyncLoop(cancellationToken: cancellationToken);
+        await syncHelper.RunSyncLoopAsync(cancellationToken: cancellationToken);
     }
 
     /// <summary>Triggered when the application host is performing a graceful shutdown.</summary>