slack/ts/slack.classes.slackme.ts

23 lines
630 B
TypeScript
Raw Normal View History

2018-09-15 20:23:05 +00:00
import * as plugins from './slack.plugins';
import { IMessageOptions } from './slack.classes.slackmessage';
export class Slackme {
private baseUrl = 'https://hooks.slack.com/services/';
private postRoute: string;
constructor(postRouteArg: string) {
this.postRoute = postRouteArg;
}
sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
plugins.smartrequest.post(`${this.baseUrl}${this.postRoute}`, {
headers: {
'Content-Type': 'application/json'
},
requestBody: {
channel: channelArg,
attachments: [messageOptionsArg]
}
});
}
}