fix(core): update
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
export * from './slackme.classes.slackme'
|
||||
export * from './slackme.classes.slackmessage'
|
||||
export * from './slack.classes.slackme';
|
||||
export * from './slack.classes.slackmessage';
|
||||
|
22
ts/slack.classes.slackme.ts
Normal file
22
ts/slack.classes.slackme.ts
Normal file
@ -0,0 +1,22 @@
|
||||
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]
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,72 +1,72 @@
|
||||
import * as plugins from './slackme.plugins'
|
||||
import { Slackme } from './slackme.classes.slackme'
|
||||
import * as plugins from './slack.plugins';
|
||||
import { Slackme } from './slack.classes.slackme';
|
||||
|
||||
export interface IAttachmentField {
|
||||
title: string
|
||||
value: string
|
||||
short?: boolean
|
||||
title: string;
|
||||
value: string;
|
||||
short?: boolean;
|
||||
}
|
||||
|
||||
export interface IMessageOptions {
|
||||
/**
|
||||
* "Required plain-text summary of the attachment."
|
||||
*/
|
||||
fallback?: string,
|
||||
fallback?: string;
|
||||
/**
|
||||
* a side color
|
||||
*/
|
||||
color?: string,
|
||||
color?: string;
|
||||
/**
|
||||
* a message to show above
|
||||
*/
|
||||
pretext?: string,
|
||||
pretext?: string;
|
||||
/**
|
||||
* author name of the attachment
|
||||
*/
|
||||
author_name?: string,
|
||||
author_name?: string;
|
||||
/**
|
||||
* a link to the author
|
||||
*/
|
||||
author_link?: string,
|
||||
author_link?: string;
|
||||
/**
|
||||
* a string to the author
|
||||
*/
|
||||
author_icon?: string,
|
||||
author_icon?: string;
|
||||
/**
|
||||
* a title for the attachment
|
||||
*/
|
||||
title?: string,
|
||||
title?: string;
|
||||
/**
|
||||
* a link for the title
|
||||
*/
|
||||
title_link?: string,
|
||||
title_link?: string;
|
||||
/**
|
||||
* the main text of the message
|
||||
*/
|
||||
text?: string,
|
||||
fields?: IAttachmentField[],
|
||||
image_url?: string,
|
||||
thumb_url?: string,
|
||||
footer?: string,
|
||||
footer_icon?: string,
|
||||
text?: string;
|
||||
fields?: IAttachmentField[];
|
||||
image_url?: string;
|
||||
thumb_url?: string;
|
||||
footer?: string;
|
||||
footer_icon?: string;
|
||||
/**
|
||||
* timestamp as epoch time
|
||||
*/
|
||||
ts?: number
|
||||
ts?: number;
|
||||
}
|
||||
|
||||
export class SlackMessage {
|
||||
slackmeRef: Slackme
|
||||
messageOptions: IMessageOptions
|
||||
slackmeRef: Slackme;
|
||||
messageOptions: IMessageOptions;
|
||||
constructor(messageOptionsArg: IMessageOptions, slackmeArg?: Slackme) {
|
||||
if (slackmeArg) {
|
||||
this.slackmeRef = slackmeArg
|
||||
this.slackmeRef = slackmeArg;
|
||||
}
|
||||
this.messageOptions = messageOptionsArg
|
||||
this.messageOptions = messageOptionsArg;
|
||||
}
|
||||
sendToRoom(roomNameArg: string) {
|
||||
if(this.slackmeRef) {
|
||||
this.slackmeRef.sendMessage(this.messageOptions, roomNameArg)
|
||||
if (this.slackmeRef) {
|
||||
this.slackmeRef.sendMessage(this.messageOptions, roomNameArg);
|
||||
}
|
||||
}
|
||||
}
|
3
ts/slack.plugins.ts
Normal file
3
ts/slack.plugins.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as smartrequest from 'smartrequest';
|
||||
|
||||
export { smartrequest };
|
@ -1,24 +0,0 @@
|
||||
import * as plugins from './slackme.plugins'
|
||||
import { IMessageOptions } from './slackme.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
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
import * as smartrequest from 'smartrequest'
|
||||
|
||||
export {
|
||||
smartrequest
|
||||
}
|
Reference in New Issue
Block a user