@@ -12,7 +12,7 @@ Get-WebSocket gets a websocket.
1212
1313This will create a job that connects to a WebSocket and outputs the results.
1414
15- If the ` -Watch ` parameter is provided, will output a continous stream of objects from the websocket .
15+ If the ` -Watch ` parameter is provided, will output a continous stream of objects.
1616
1717---
1818
@@ -84,6 +84,40 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.
8484 $_.commit.record.embed.external.uri
8585 }
8686```
87+ BlueSky, but just the hashtags
88+
89+ ``` PowerShell
90+ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{
91+ {$webSocketoutput.commit.record.text -match "\#\w+"}={
92+ $matches.0
93+ }
94+ }
95+ ```
96+ BlueSky, but just the hashtags (as links)
97+
98+ ``` PowerShell
99+ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{
100+ {$webSocketoutput.commit.record.text -match "\#\w+"}={
101+ if ($psStyle.FormatHyperlink) {
102+ $psStyle.FormatHyperlink($matches.0, "https://bsky.app/search?q=$([Web.HttpUtility]::UrlEncode($matches.0))")
103+ } else {
104+ $matches.0
105+ }
106+ }
107+ }
108+ ```
109+ > EXAMPLE 10
110+
111+ ``` PowerShell
112+ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{
113+ {$args.commit.record.text -match "\#\w+"}={
114+ $matches.0
115+ }
116+ {$args.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+'}={
117+ $matches.0
118+ }
119+ }
120+ ```
87121
88122---
89123
@@ -104,6 +138,7 @@ A ScriptBlock that will handle the output of the WebSocket.
104138
105139#### ** Variable**
106140Any variables to declare in the WebSocket job.
141+ These variables will also be added to the job as properties.
107142
108143| Type | Required| Position| PipelineInput|
109144| ---------------| --------| --------| -------------|
@@ -166,6 +201,15 @@ If set, will watch the output of the WebSocket job, outputting results continuou
166201| ----------| --------| --------| -------------| -------|
167202| ` [Switch] ` | false | named | false | Tail |
168203
204+ #### ** WatchFor**
205+ If set, will watch the output of a WebSocket job for one or more conditions.
206+ The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock.
207+ The values of the dictionary are what will happen when a match is found.
208+
209+ | Type | Required| Position| PipelineInput| Aliases |
210+ | ---------------| --------| --------| -------------| ----------------------|
211+ | ` [IDictionary] ` | false | named | false | WhereFor<br />Wherefore|
212+
169213#### ** TimeOut**
170214The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed.
171215
@@ -208,5 +252,5 @@ RunspacePools allow you to limit the scope of the handler to a pool of runspaces
208252
209253### Syntax
210254``` PowerShell
211- Get-WebSocket [[-WebSocketUri] <Uri>] [-Handler <ScriptBlock>] [-Variable <IDictionary>] [-Name <String>] [-InitializationScript <ScriptBlock>] [-BufferSize <Int32>] [-OnConnect <ScriptBlock>] [-OnError <ScriptBlock>] [-OnOutput <ScriptBlock>] [-OnWarning <ScriptBlock>] [-Watch] [-TimeOut <TimeSpan>] [-Maximum <Int64>] [-ConnectionTimeout <TimeSpan>] [-Runspace <Runspace>] [-RunspacePool <RunspacePool>] [<CommonParameters>]
255+ Get-WebSocket [[-WebSocketUri] <Uri>] [-Handler <ScriptBlock>] [-Variable <IDictionary>] [-Name <String>] [-InitializationScript <ScriptBlock>] [-BufferSize <Int32>] [-OnConnect <ScriptBlock>] [-OnError <ScriptBlock>] [-OnOutput <ScriptBlock>] [-OnWarning <ScriptBlock>] [-Watch] [-WatchFor <IDictionary>] [- TimeOut <TimeSpan>] [-Maximum <Int64>] [-ConnectionTimeout <TimeSpan>] [-Runspace <Runspace>] [-RunspacePool <RunspacePool>] [<CommonParameters>]
212256```
0 commit comments