| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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("<b>%v</b>\n<i>%v</i>\n<i>%v</i>\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
- }
|