slack/ts/index.ts

34 lines
745 B
TypeScript
Raw Normal View History

2017-09-14 05:20:26 +00:00
import * as plugins from './slackme.plugins'
import { SlackMessage } from './slackme.classes.slackmessage'
export interface ISlackmeMessage {
message: string,
author: string,
2017-09-14 05:20:26 +00:00
}
export {
SlackMessage
}
export class Slackme {
private baseUrl = 'https://hooks.slack.com/services/'
private postRoute: string
constructor (postRouteArg: string) {
this.postRoute = postRouteArg
}
sendMessage(messageArg: SlackMessage, channelArg: string = 'general') {
plugins.smartrequest.post(`${this.baseUrl}${this.postRoute}`,{
headers: {
'Content-Type': 'application/json'
},
requestBody: {
channel: channelArg,
attachments: [
messageArg.messageOptions
]
}
})
}
}