| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package beaconfire
- import (
- "errors"
- "fmt"
- )
- const (
- BEACON_FMT_HTML = "html"
- BEACON_FMT_MARKDOWN = "markdown"
- BEACON_FMT_PLAIN = "plain"
- )
- var (
- ErrNoReceiver = errors.New("no receiver")
- )
- type BeaconMessage struct {
- Title string // Message Title
- Content string // Message Content
- Ts int64 //..
- Fmt string
- }
- func NewBeaconMessage(title, content string, ts int64, fmt string) *BeaconMessage {
- bp := &BeaconMessage{
- Title: title,
- Content: content,
- Ts: ts,
- Fmt: fmt,
- }
- return bp
- }
- func (bp BeaconMessage) FormatMarkdown() string {
- return fmt.Sprintf("### %v\n> %v\n> %v", bp.Title, Ts2Str(bp.Ts), bp.Content)
- }
- func (bp BeaconMessage) FormatHTML() string {
- return fmt.Sprintf("<b>%v</b>\n<i>%v</i>\n%v", bp.Title, Ts2Str(bp.Ts), bp.Content)
- }
- func (bp BeaconMessage) FormatPlainText() string {
- return fmt.Sprintf("%v\n%v\n%v", bp.Title, Ts2Str(bp.Ts), bp.Content)
- }
- // Interface of BeaconFire
- type BeaconFire interface {
- Name() string
- Send(*BeaconMessage) error
- }
|