|
@@ -3,7 +3,6 @@ package beaconfire
|
|
|
import (
|
|
import (
|
|
|
"errors"
|
|
"errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
- "time"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -11,35 +10,33 @@ var (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type BeaconParam struct {
|
|
type BeaconParam struct {
|
|
|
- From, Title, Content string
|
|
|
|
|
- Ts int64
|
|
|
|
|
- To []string
|
|
|
|
|
- Fmt string
|
|
|
|
|
|
|
+ Title string
|
|
|
|
|
+ Content string
|
|
|
|
|
+ Ts int64
|
|
|
|
|
+ Fmt string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func NewBeaconParam(from, title, content string, fmt string, to ...string) *BeaconParam {
|
|
|
|
|
|
|
+func NewBeaconParam(title, content string, ts int64, fmt string) *BeaconParam {
|
|
|
bp := &BeaconParam{
|
|
bp := &BeaconParam{
|
|
|
- From: from,
|
|
|
|
|
Title: title,
|
|
Title: title,
|
|
|
Content: content,
|
|
Content: content,
|
|
|
- Ts: time.Now().Unix(),
|
|
|
|
|
|
|
+ Ts: ts,
|
|
|
Fmt: fmt,
|
|
Fmt: fmt,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- bp.To = append(bp.To, to...)
|
|
|
|
|
return bp
|
|
return bp
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (bp BeaconParam) FormatMarkdown() string {
|
|
func (bp BeaconParam) FormatMarkdown() string {
|
|
|
- return fmt.Sprintf("### %v\n> %v\n> %v\n> %v", bp.Title, bp.From, Ts2Str(bp.Ts), bp.Content)
|
|
|
|
|
|
|
+ return fmt.Sprintf("### %v\n> %v\n> %v", bp.Title, Ts2Str(bp.Ts), bp.Content)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (bp BeaconParam) FormatHTML() string {
|
|
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)
|
|
|
|
|
|
|
+ return fmt.Sprintf("<b>%v</b>\n<i>%v</i>\n%v", bp.Title, Ts2Str(bp.Ts), bp.Content)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (bp BeaconParam) FormatPlainText() string {
|
|
func (bp BeaconParam) FormatPlainText() string {
|
|
|
- return fmt.Sprintf("%v\n%v\n%v\n%v", bp.Title, bp.From, Ts2Str(bp.Ts), bp.Content)
|
|
|
|
|
|
|
+ return fmt.Sprintf("%v\n%v\n%v", bp.Title, Ts2Str(bp.Ts), bp.Content)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type BeaconFire interface {
|
|
type BeaconFire interface {
|