nu_plugin_twitch 0.1.1

A Nu Shell plugin to interact with Twitch IRC and API, making scripting easier.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def main [
    channel: string,
    --emote (-e): string = "<3",
] {
    twitch notices $channel | where event_type =~ SUB | each {
        insert sub ($in.event.to?) |
        default $in.sender sub |
        insert gifter ($in.event.from?)
    } | select sub gifter timestamp |
    reduce --fold (date now) {|$it, $acc|
        if ($acc < $it.timestamp) {
            sleep ((random int 5..15) * 1sec) |
            [(seq 0 (random int 0..5) | each { $emote } | str join " ")] |
            twitch say $channel;
            $it.timestamp + 1min
        } else $acc
    }
}