| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package beaconfire
- import (
- "errors"
- "fmt"
- )
- var (
- ErrNoReceiver = errors.New("no receiver")
- )
- type BeaconParam struct {
- Title string
- Content string
- Ts int64
- Fmt string
- }
- func NewBeaconParam(title, content string, ts int64, fmt string) *BeaconParam {
- bp := &BeaconParam{
- Title: title,
- Content: content,
- Ts: ts,
- Fmt: fmt,
- }
- return bp
- }
- func (bp BeaconParam) FormatMarkdown() string {
- return fmt.Sprintf("### %v\n> %v\n> %v", bp.Title, Ts2Str(bp.Ts), bp.Content)
- }
- func (bp BeaconParam) FormatHTML() string {
- return fmt.Sprintf("<b>%v</b>\n<i>%v</i>\n%v", bp.Title, Ts2Str(bp.Ts), bp.Content)
- }
- func (bp BeaconParam) FormatPlainText() string {
- return fmt.Sprintf("%v\n%v\n%v", bp.Title, Ts2Str(bp.Ts), bp.Content)
- }
- type BeaconFire interface {
- Name() string
- Send(*BeaconParam) error
- }
|