Skip to content

Commit

Permalink
Update readme and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
RamblingCookieMonster committed May 15, 2016
1 parent d7f93df commit 7556081
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
Binary file added Media/FindMessage.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Media/FindMessageSelect.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions PSSlack/Private/ConvertFrom-UnixTime.ps1
@@ -0,0 +1,16 @@
#From http://powershell.com/cs/blogs/tips/archive/2012/03/09/converting-unix-time.aspx - Thanks!
function ConvertFrom-UnixTime {
param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
[Int32]
$UnixTime
)
begin {
$startdate = Get-Date –Date '01/01/1970'
}
process {
$timespan = New-Timespan -Seconds $UnixTime
$startdate + $timespan
}
}
1 change: 1 addition & 0 deletions PSSlack/Private/Parse-SlackMessage.ps1
Expand Up @@ -15,6 +15,7 @@ Function Parse-SlackMessage {
Channel = $Message.channel.name
Text = $Message.text
Attachments = $Message.Attachments
Timestamp = ConvertFrom-UnixTime $Message.ts
Permalink = $Message.permalink
Previous = Extract-Previous $Message.Previous
Previous_2 = Extract-Previous $Message.Previous_2
Expand Down
43 changes: 33 additions & 10 deletions README.md
Expand Up @@ -3,7 +3,7 @@ PSSlack

This is a quick and dirty module to interact with the Slack API.

This is a work in progress; it's not fully featured or tested, and there may be breaking changes.
This is a work in progress; it's not fully featured or tested, and there may be breaking changes. Silly blog post pending.

Pull requests and other contributions would be welcome!

Expand All @@ -15,9 +15,6 @@ Pull requests and other contributions would be welcome!
# Unblock the zip
# Extract the PSSlack folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\)
#Simple alternative, if you have PowerShell 5, or the PowerShellGet module:
Install-Module PSSlack
# Import the module.
Import-Module PSSlack #Alternatively, Import-Module \\Path\To\PSSlack
Expand All @@ -42,13 +39,39 @@ $Uri = "Some incoming webhook uri from Slack"
Send-SlackMessage -Uri $Uri `
-Channel '@wframe' `
-Parse full
-Parse full `
-Text 'Hello @wframe, join me in #devnull!'
# Send a message to @wframe (not a channel), parsing the text to linkify usernames and channels
```

![Simple Send-SlackMessage](/Media/SimpleMessage.png)
      ![Simple Send-SlackMessage](/Media/SimpleMessage.png)

### Search for a Slack Message

```powershell
# Search for a message containing PowerShell, sorting results by timestamp
Find-SlackMessage -Token $Token `
-Query 'PowerShell' `
-SortBy timestamp
```

      ![Find Message](/Media/FindMessage.png)

```powershell
# Search for a message containing PowerShell
# Results are sorted by best match by default
# Notice the extra properties and previous/next messages
Find-SlackMessage -Token $Token `
-Query 'PowerShell' |
Select-Object -Property *
```

      ![Find Message Select All](/Media/FindMessageSelect.png)

You could use this simply to search Slack from the CLI, or in an automated solution that might avoid posting if certain content is already found in Slack.

### Send a Richer Slack Message

Expand All @@ -72,7 +95,7 @@ New-SlackMessageAttachment -Color $([System.Drawing.Color]::red) `
Send-SlackMessage -Token $Token
```

![Rich messages](/Media/RichMessage.png)
      ![Rich messages](/Media/RichMessage.png)

Notice that the title is clickable. You might link to...

Expand Down Expand Up @@ -108,7 +131,7 @@ New-SlackMessageAttachment -Color $([System.Drawing.Color]::red) `
Send-SlackMessage -Token $Token
```

![Multiple Attachments](/Media/MultiAttachments.png)
      ![Multiple Attachments](/Media/MultiAttachments.png)

Notice that we can chain multiple New-SlackMessageAttachments together.

Expand Down Expand Up @@ -153,9 +176,9 @@ New-SlackMessageAttachment -Color $([System.Drawing.Color]::Orange) `
# Creates a message fromthat attachment and sents it with a uri
```

![Fields](/Media/Fields.png)
      ![Fields](/Media/Fields.png)

## Notes
# Notes

There are a good number of Slack functions out there, including jgigler's [PowerShell.Slack](https://github.com/jgigler/Powershell.Slack) and Steven Murawski's [Slack](https://github.com/smurawski/Slack). We borrowed some ideas and code from these - thank you!

Expand Down

0 comments on commit 7556081

Please sign in to comment.