Skip to content

Commit 2597ccc

Browse files
StartAutomatingStartAutomating
authored andcommitted
docs: More Get-WebSocket examples ( Fixes #27 )
1 parent 3fe73fd commit 2597ccc

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

docs/_data/Help/Get-WebSocket.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Synopsis": "WebSockets in PowerShell.",
3-
"Description": "Get-WebSocket allows you to connect to a websocket and handle the output.",
3+
"Description": "Get-WebSocket gets a websocket.\n\nThis will create a job that connects to a WebSocket and outputs the results.\n\nIf the `-Watch` parameter is provided, will output a continous stream of objects from the websocket.",
44
"Parameters": [
55
{
66
"Name": null,
@@ -33,32 +33,37 @@
3333
{
3434
"Title": "EXAMPLE 1",
3535
"Markdown": "Create a WebSocket job that connects to a WebSocket and outputs the results.",
36-
"Code": "Get-WebSocket -WebSocketUri \"wss://localhost:9669\""
36+
"Code": "Get-WebSocket -WebSocketUri \"wss://localhost:9669/\""
3737
},
3838
{
3939
"Title": "EXAMPLE 2",
40-
"Markdown": "Get is the default verb, so we can just say WebSocket.",
41-
"Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post"
40+
"Markdown": "Get is the default verb, so we can just say WebSocket.\n`-Watch` will output a continous stream of objects from the websocket.\nFor example, let's Watch BlueSky, but just the text. ",
41+
"Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n % { \n $_.commit.record.text\n }"
4242
},
4343
{
4444
"Title": "EXAMPLE 3",
45-
"Markdown": "",
46-
"Code": "websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+') {\n Write-Host $matches.0 -NoNewline\n }\n }"
45+
"Markdown": "Watch BlueSky, but just the text and spacing",
46+
"Code": "$blueSkySocketUrl = \"wss://jetstream2.us-$(\n 'east','west'|Get-Random\n).bsky.network/subscribe?$(@(\n \"wantedCollections=app.bsky.feed.post\"\n) -join '&')\"\nwebsocket $blueSkySocketUrl -Watch | \n % { Write-Host \"$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))\"}"
4747
},
4848
{
4949
"Title": "EXAMPLE 4",
5050
"Markdown": "",
51-
"Code": "$emojiPattern = '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}\\p{IsVariationSelectors}\\p{IsCombiningHalfMarks}]+)'\nwebsocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))\n if ($in.commit.record.text -match \"(?>(?:$emojiPattern|\\#\\w+)\") {\n $match = $matches.0 \n Write-Host $spacing,$match,$spacing -NoNewline\n }\n }"
51+
"Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post"
5252
},
5353
{
5454
"Title": "EXAMPLE 5",
55-
"Markdown": "",
56-
"Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n Where-Object {\n $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'\n } |\n Foreach-Object {\n $_.commit.record.embed.external.uri\n }"
55+
"Markdown": "Watch BlueSky, but just the emoji",
56+
"Code": "websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+') {\n Write-Host $matches.0 -NoNewline\n }\n }"
5757
},
5858
{
5959
"Title": "EXAMPLE 6",
6060
"Markdown": "",
61-
"Code": ""
61+
"Code": "$emojiPattern = '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}\\p{IsVariationSelectors}\\p{IsCombiningHalfMarks}]+)'\nwebsocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))\n if ($in.commit.record.text -match \"(?>(?:$emojiPattern|\\#\\w+)\") {\n $match = $matches.0 \n Write-Host $spacing,$match,$spacing -NoNewline\n }\n }"
62+
},
63+
{
64+
"Title": "EXAMPLE 7",
65+
"Markdown": "",
66+
"Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n Where-Object {\n $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'\n } |\n Foreach-Object {\n $_.commit.record.embed.external.uri\n }"
6267
}
6368
]
6469
}

0 commit comments

Comments
 (0)