2017-09-14 07:20:26 +02:00
|
|
|
# slackme
|
2018-09-15 22:23:05 +02:00
|
|
|
|
2017-09-14 07:20:26 +02:00
|
|
|
API abstraction for mojoio
|
|
|
|
|
|
|
|
## Availabililty
|
2018-09-15 22:23:05 +02:00
|
|
|
|
2017-09-14 07:20:26 +02:00
|
|
|
[](https://www.npmjs.com/package/slackme)
|
|
|
|
[](https://GitLab.com/mojoio/slackme)
|
|
|
|
[](https://github.com/mojoio/slackme)
|
|
|
|
[](https://mojoio.gitlab.io/slackme/)
|
|
|
|
|
|
|
|
## Status for master
|
2018-09-15 22:23:05 +02:00
|
|
|
|
2017-09-14 07:20:26 +02:00
|
|
|
[](https://GitLab.com/mojoio/slackme/commits/master)
|
|
|
|
[](https://GitLab.com/mojoio/slackme/commits/master)
|
|
|
|
[](https://www.npmjs.com/package/slackme)
|
|
|
|
[](https://david-dm.org/mojoio/slackme)
|
|
|
|
[](https://www.bithound.io/github/mojoio/slackme/master/dependencies/npm)
|
|
|
|
[](https://www.bithound.io/github/mojoio/slackme)
|
2018-01-10 22:10:09 +01:00
|
|
|
[](https://snyk.io/test/npm/slackme)
|
2017-09-14 07:20:26 +02:00
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
2018-01-10 22:10:09 +01:00
|
|
|
[](https://standardjs.com/)
|
2017-09-14 07:20:26 +02:00
|
|
|
|
|
|
|
## Usage
|
2018-09-15 22:23:05 +02:00
|
|
|
|
2017-09-14 07:20:26 +02:00
|
|
|
Use TypeScript for best in class instellisense.
|
|
|
|
|
2018-01-10 21:45:25 +01:00
|
|
|
```javascript
|
|
|
|
import * as slackme from 'slackme'
|
|
|
|
|
|
|
|
// First setup the hook
|
|
|
|
const mySlackme = new Slackme('https://some.slack.webhook.url')
|
|
|
|
mySlackme.sendMessage:{{
|
|
|
|
// MessageOptions here
|
|
|
|
}, 'myAwesomeChannel'}
|
|
|
|
```
|
|
|
|
|
2018-01-10 22:17:30 +01:00
|
|
|
The message interface follows [Slack's docs (click here)](https://api.slack.com/docs/message-formatting) and looks like this:
|
2018-01-10 21:45:25 +01:00
|
|
|
|
|
|
|
```javascript
|
|
|
|
interface IAttachmentField {
|
|
|
|
title: string
|
|
|
|
value: string
|
|
|
|
short?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IMessageOptions {
|
|
|
|
/**
|
|
|
|
* "Required plain-text summary of the attachment."
|
|
|
|
*/
|
|
|
|
fallback?: string,
|
|
|
|
/**
|
|
|
|
* a side color
|
|
|
|
*/
|
|
|
|
color?: string,
|
|
|
|
/**
|
|
|
|
* a message to show above
|
|
|
|
*/
|
|
|
|
pretext?: string,
|
|
|
|
/**
|
|
|
|
* author name of the attachment
|
|
|
|
*/
|
|
|
|
author_name?: string,
|
|
|
|
/**
|
|
|
|
* a link to the author
|
|
|
|
*/
|
|
|
|
author_link?: string,
|
|
|
|
/**
|
|
|
|
* a string to the author
|
|
|
|
*/
|
|
|
|
author_icon?: string,
|
|
|
|
/**
|
|
|
|
* a title for the attachment
|
|
|
|
*/
|
|
|
|
title?: string,
|
|
|
|
/**
|
|
|
|
* a link for the title
|
|
|
|
*/
|
|
|
|
title_link?: string,
|
|
|
|
/**
|
|
|
|
* the main text of the message
|
|
|
|
*/
|
|
|
|
text?: string,
|
|
|
|
fields?: IAttachmentField[],
|
|
|
|
image_url?: string,
|
|
|
|
thumb_url?: string,
|
|
|
|
footer?: string,
|
|
|
|
footer_icon?: string,
|
|
|
|
/**
|
|
|
|
* timestamp as epoch time
|
|
|
|
*/
|
|
|
|
ts?: number
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternatively, there is the option of specifying a SlackMessage class
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
const mySlackMessage = new SlackMessage({ /* message options here } */, mySlackme)
|
|
|
|
mySlackMessage.title = 'new Title' // modify message options
|
|
|
|
mySlackMessage.sendToRoom('general')
|
|
|
|
mySlackMessage.title = 'another Title'
|
|
|
|
mySlackMessage.sendToRoom('anotherroom')
|
|
|
|
```
|
|
|
|
|
2017-09-14 07:20:26 +02:00
|
|
|
For further information read the linked docs at the top of this README.
|
|
|
|
|
|
|
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
2018-09-15 22:23:05 +02:00
|
|
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
2017-09-14 07:20:26 +02:00
|
|
|
|
|
|
|
[](https://mojo.io)
|