about summary refs log tree commit diff
path: root/Commands/DbgAniRainbowTest.cs
blob: eed6fa5fac3d8ef2d07e39842a4f1365f2d12428 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Diagnostics;
using LibMatrix.EventTypes.Spec;
using LibMatrix.Helpers;
using LibMatrix.RoomTypes;
using LibMatrix.Services;
using LibMatrix.Utilities.Bot.Interfaces;
using ModerationBot.AccountData;

namespace ModerationBot.Commands;

public class DbgAniRainbowTest(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver, PolicyEngine engine) : ICommand {
    public string Name { get; } = "dbg-ani-rainbow";
    public string[]? Aliases { get; }
    public string Description { get; } = "[Debug] animated rainbow :)";
    public bool Unlisted { get; }
    private GenericRoom logRoom { get; set; }

    public async Task<bool> CanInvoke(CommandContext ctx) {
        return ctx.Room.RoomId == "!DoHEdFablOLjddKWIp:rory.gay";
    }

    public async Task Invoke(CommandContext ctx) {
        //255 long string
        // var rainbow = "🟥🟧🟨🟩🟦🟪";
        var rainbow = "M";
        var chars = rainbow;
        for (var i = 0; i < 76; i++) {
            chars += rainbow[i%rainbow.Length];
        }

        var msg = new MessageBuilder(msgType: "m.notice").WithRainbowString(chars).Build();
        var msgEvent = await ctx.Room.SendMessageEventAsync(msg);
        
        Task.Run(async () => {

            int i = 0;
            while (true) {
                msg = new MessageBuilder(msgType: "m.notice").WithRainbowString(chars, offset: i+=5).Build();
                    // .SetReplaceRelation<RoomMessageEventContent>(msgEvent.EventId);
                // msg.Body = "";
                // msg.FormattedBody = "";
                var sw = Stopwatch.StartNew();
                await ctx.Room.SendMessageEventAsync(msg);
                await Task.Delay(sw.Elapsed);
            }
            
        });

    }
}