package beaconfire import ( "errors" "fmt" "time" ) var ( ErrNoReceiver = errors.New("no receiver") ) type BeaconParam struct { From, Title, Content string Ts int64 To []string Fmt string } func NewBeaconParam(from, title, content string, fmt string, to ...string) *BeaconParam { bp := &BeaconParam{ From: from, Title: title, Content: content, Ts: time.Now().Unix(), Fmt: fmt, } bp.To = append(bp.To, to...) return bp } func (bp BeaconParam) FormatMarkdown() string { return fmt.Sprintf("### %v\n> %v\n> %v\n> %v", bp.Title, bp.From, Ts2Str(bp.Ts), bp.Content) } func (bp BeaconParam) FormatHTML() string { return fmt.Sprintf("%v\n%v\n%v\n%v", bp.Title, bp.From, Ts2Str(bp.Ts), bp.Content) } func (bp BeaconParam) FormatPlainText() string { return fmt.Sprintf("%v\n%v\n%v\n%v", bp.Title, bp.From, Ts2Str(bp.Ts), bp.Content) } type BeaconFire interface { Name() string Send(*BeaconParam) error }