update to first properly working version

This commit is contained in:
2017-09-17 14:53:00 +02:00
parent e99fb08674
commit 3fc712af8a
13 changed files with 439 additions and 10 deletions

View File

@ -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
]
}
})
}
}

View 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
}
}

View File

@ -1 +1,7 @@
import 'typings-global'
import * as smartrequest from 'smartrequest'
export {
smartrequest
}