update to first properly working version
This commit is contained in:
32
ts/index.ts
32
ts/index.ts
@ -1,3 +1,33 @@
|
||||
import * as plugins from './slackme.plugins'
|
||||
import { SlackMessage } from './slackme.classes.slackmessage'
|
||||
export interface ISlackmeMessage {
|
||||
message: string,
|
||||
author: string,
|
||||
|
||||
export let standardExport = 'Hi there! :) This is a exported string'
|
||||
}
|
||||
|
||||
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
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
47
ts/slackme.classes.slackmessage.ts
Normal file
47
ts/slackme.classes.slackmessage.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import * as plugins from './slackme.plugins'
|
||||
|
||||
export interface IMessageOptions {
|
||||
/**
|
||||
* "Required plain-text summary of the attachment."
|
||||
*/
|
||||
fallback?: string,
|
||||
/**
|
||||
* a side color
|
||||
*/
|
||||
color?: string,
|
||||
/**
|
||||
* a message to show above
|
||||
*/
|
||||
pretext?: string,
|
||||
"author_name"?: "Bobby Tables",
|
||||
"author_link"?: "http://flickr.com/bobby/",
|
||||
"author_icon"?: "http://flickr.com/icons/bobby.jpg",
|
||||
"title"?: "Slack API Documentation",
|
||||
"title_link"?: "https://api.slack.com/",
|
||||
/**
|
||||
* the main text of the message
|
||||
*/
|
||||
text?: string,
|
||||
"fields"?: [
|
||||
{
|
||||
"title"?: "Priority",
|
||||
"value"?: "High",
|
||||
"short"?: false
|
||||
}
|
||||
],
|
||||
"image_url"?: "http://my-website.com/path/to/image.jpg",
|
||||
"thumb_url"?: "http://example.com/path/to/thumb.png",
|
||||
"footer"?: "Slack API",
|
||||
"footer_icon"?: "https://platform.slack-edge.com/img/default_application_icon.png",
|
||||
/**
|
||||
* timestamp as epoch time
|
||||
*/
|
||||
ts?: number
|
||||
}
|
||||
|
||||
export class SlackMessage {
|
||||
messageOptions: IMessageOptions
|
||||
constructor(messageOptions: IMessageOptions) {
|
||||
this.messageOptions = messageOptions
|
||||
}
|
||||
}
|
@ -1 +1,7 @@
|
||||
import 'typings-global'
|
||||
|
||||
import * as smartrequest from 'smartrequest'
|
||||
|
||||
export {
|
||||
smartrequest
|
||||
}
|
||||
|
Reference in New Issue
Block a user