about summary refs log tree commit diff
path: root/ExampleBots/LibMatrix.ExampleBot
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
commite5591eef3850a9796cc87386128651a828b70697 (patch)
tree7e501ec749229a3d96838265289266bb6f6ce208 /ExampleBots/LibMatrix.ExampleBot
parentUnit tests, small refactors (diff)
downloadLibMatrix-e5591eef3850a9796cc87386128651a828b70697.tar.xz
Small refactors
Diffstat (limited to 'ExampleBots/LibMatrix.ExampleBot')
-rw-r--r--ExampleBots/LibMatrix.ExampleBot/Bot/MRUBot.cs9
1 files changed, 6 insertions, 3 deletions
diff --git a/ExampleBots/LibMatrix.ExampleBot/Bot/MRUBot.cs b/ExampleBots/LibMatrix.ExampleBot/Bot/MRUBot.cs
index 0211f74..8cf4f1f 100644
--- a/ExampleBots/LibMatrix.ExampleBot/Bot/MRUBot.cs
+++ b/ExampleBots/LibMatrix.ExampleBot/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>