slack/ts/slack.classes.slackme.ts
2019-09-08 19:37:13 +02:00

21 lines
615 B
TypeScript

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;
}
async sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
const response = await plugins.smartrequest.postJson(`${this.baseUrl}${this.postRoute}`, {
requestBody: {
channel: channelArg,
attachments: [messageOptionsArg]
}
});
return response;
}
}