Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Latest commit

 

History

History
46 lines (33 loc) · 1.36 KB

README.md

File metadata and controls

46 lines (33 loc) · 1.36 KB

dart-slack

Dartlang interface to the Slack Webhook API

API Documentation available on Pub

Simple Start

import 'package:slack/html/slack';
// or 
import 'package:slack/io/slack';

main() {
  Slack slack = new Slack('webhook-url');
  Message message = new Message('foo message',username:'bar-user');      
  slack.send(message);
}

Attachment Support

Minimally attachments require a 'fallback' [String], in the first field.

Attachment bugReport = new Attachment("I can't use Slack!",
   pretext: 'A Critical Bug Reported',
   text   : "I can't use Slack!",
   color  : 'danger');

Message message = new Message('Bug Report:', username: 'bugBot', attachments: [bugReport]);
slack.send(message);

Cascades

Messages, Attachments, and Fields are mostly just data containers. This means that you have a choice between setting their values in the constructor or setting them in a cascade. For example, Attachments could be defined like so:

Attachment bugReport = new Attachment("I can't use Slack!")
   ..pretext = 'A Critical Bug Reported'
   ..text   = "I can't use Slack!"
   ..color  = 'danger';

Message message = new Message('Bug Report:')
    ..username    = 'bugBot'
    ..attachments = [bugReport];
slack.send(message);