Skip to content

Commit 5fd644b

Browse files
StartAutomatingStartAutomating
StartAutomating
authored and
StartAutomating
committed
docs: Generating WebSocket README with PipeScript ( Fixes #27 )
1 parent ccda061 commit 5fd644b

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ It has a single command: Get-WebSocket.
1212

1313
Because `Get` is the default verb in PowerShell, you can just call it `WebSocket`.
1414

15+
## WebSocket Container
16+
17+
You can use the WebSocket module within a container:
18+
19+
~~~powershell
20+
docker pull ghcr.io/powershellweb/websocket
21+
docker run -it ghcr.io/powershellweb/websocket
22+
~~~
1523

1624
### Installing and Importing
1725

@@ -30,4 +38,61 @@ To connect to a websocket and start listening for results, use [Get-WebSocket](G
3038
websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch
3139
~~~
3240

33-
To stop watching a websocket, simply stop the background job.
41+
To stop watching a websocket, simply stop the background job.
42+
43+
### More Examples
44+
45+
#### Get-WebSocket Example 1
46+
47+
~~~powershell
48+
# Create a WebSocket job that connects to a WebSocket and outputs the results.
49+
Get-WebSocket -WebSocketUri "wss://localhost:9669"
50+
~~~
51+
#### Get-WebSocket Example 2
52+
53+
~~~powershell
54+
# Get is the default verb, so we can just say WebSocket.
55+
websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
56+
~~~
57+
#### Get-WebSocket Example 3
58+
59+
~~~powershell
60+
websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
61+
Foreach-Object {
62+
$in = $_
63+
if ($in.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+') {
64+
Write-Host $matches.0 -NoNewline
65+
}
66+
}
67+
~~~
68+
#### Get-WebSocket Example 4
69+
70+
~~~powershell
71+
$emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)'
72+
websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
73+
Foreach-Object {
74+
$in = $_
75+
$spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))
76+
if ($in.commit.record.text -match "(?>(?:$emojiPattern|\#\w+)") {
77+
$match = $matches.0
78+
Write-Host $spacing,$match,$spacing -NoNewline
79+
}
80+
}
81+
~~~
82+
#### Get-WebSocket Example 5
83+
84+
~~~powershell
85+
websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
86+
Where-Object {
87+
$_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'
88+
} |
89+
Foreach-Object {
90+
$_.commit.record.embed.external.uri
91+
}
92+
~~~
93+
#### Get-WebSocket Example 6
94+
95+
~~~powershell
96+
97+
~~~
98+

0 commit comments

Comments
 (0)