slack/ts/slack.classes.slackme.ts

21 lines
615 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;
}
2019-09-05 11:08:42 +00:00
async sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
2019-09-08 17:37:13 +00:00
const response = await plugins.smartrequest.postJson(`${this.baseUrl}${this.postRoute}`, {
2018-09-15 20:23:05 +00:00
requestBody: {
channel: channelArg,
attachments: [messageOptionsArg]
}
});
2019-09-08 17:37:13 +00:00
return response;
2018-09-15 20:23:05 +00:00
}
}