about summary refs log tree commit diff
path: root/ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs')
-rw-r--r--ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs b/ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs
index 0bd2bbf..231af95 100644
--- a/ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs
+++ b/ExampleBots/PluralContactBotPoC/Bot/PluralContactBot.cs
@@ -38,14 +38,16 @@ public class PluralContactBot(AuthenticatedHomeserverGeneric hs, ILogger<PluralC
 
         _logRoom = hs.GetRoom(botConfiguration.LogRoom);
 
-        hs.SyncHelper.InviteReceivedHandlers.Add(async Task (args) => {
+        var syncHelper = new SyncHelper(hs);
+
+        syncHelper.InviteReceivedHandlers.Add(async Task (args) => {
             var inviteEvent =
                 args.Value.InviteState.Events.FirstOrDefault(x =>
                     x.Type == "m.room.member" && x.StateKey == hs.UserId);
             logger.LogInformation("Got invite to {} by {} with reason: {}", args.Key, inviteEvent.Sender, (inviteEvent.TypedContent as RoomMemberEventContent).Reason);
 
             try {
-                var accountData = await hs.GetAccountData<SystemData>($"gay.rory.plural_contact_bot.system_data#{inviteEvent.StateKey}");
+                var accountData = await hs.GetAccountDataAsync<SystemData>($"gay.rory.plural_contact_bot.system_data#{inviteEvent.StateKey}");
                 if (accountData.Members.Contains(inviteEvent.Sender)) {
                     await (hs.GetRoom(args.Key)).JoinAsync(reason: "I was invited by a system member!");
 
@@ -74,7 +76,7 @@ public class PluralContactBot(AuthenticatedHomeserverGeneric hs, ILogger<PluralC
             }
         });
 
-        hs.SyncHelper.TimelineEventHandlers.Add(async @event => {
+        syncHelper.TimelineEventHandlers.Add(async @event => {
             var room = hs.GetRoom(@event.RoomId);
             try {
                 logger.LogInformation(
@@ -87,7 +89,7 @@ public class PluralContactBot(AuthenticatedHomeserverGeneric hs, ILogger<PluralC
                 await _logRoom.SendMessageEventAsync(
                     MessageFormatter.FormatException($"Exception handling event {@event.EventId} by {@event.Sender} in {MessageFormatter.HtmlFormatMention(room.RoomId)}", e));
                 await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(e.ToString()));
-                await _logRoom.SendFileAsync("m.file", "error.log.cs", stream);
+                await _logRoom.SendFileAsync("error.log.cs", stream);
             }
         });
     }