|
|
@@ -5,19 +5,25 @@ import (
|
|
|
"fmt"
|
|
|
)
|
|
|
|
|
|
+const (
|
|
|
+ BEACON_FMT_HTML = "html"
|
|
|
+ BEACON_FMT_MARKDOWN = "markdown"
|
|
|
+ BEACON_FMT_PLAIN = "plain"
|
|
|
+)
|
|
|
+
|
|
|
var (
|
|
|
ErrNoReceiver = errors.New("no receiver")
|
|
|
)
|
|
|
|
|
|
-type BeaconParam struct {
|
|
|
- Title string
|
|
|
- Content string
|
|
|
- Ts int64
|
|
|
+type BeaconMessage struct {
|
|
|
+ Title string // Message Title
|
|
|
+ Content string // Message Content
|
|
|
+ Ts int64 //..
|
|
|
Fmt string
|
|
|
}
|
|
|
|
|
|
-func NewBeaconParam(title, content string, ts int64, fmt string) *BeaconParam {
|
|
|
- bp := &BeaconParam{
|
|
|
+func NewBeaconMessage(title, content string, ts int64, fmt string) *BeaconMessage {
|
|
|
+ bp := &BeaconMessage{
|
|
|
Title: title,
|
|
|
Content: content,
|
|
|
Ts: ts,
|
|
|
@@ -27,19 +33,20 @@ func NewBeaconParam(title, content string, ts int64, fmt string) *BeaconParam {
|
|
|
return bp
|
|
|
}
|
|
|
|
|
|
-func (bp BeaconParam) FormatMarkdown() string {
|
|
|
+func (bp BeaconMessage) FormatMarkdown() string {
|
|
|
return fmt.Sprintf("### %v\n> %v\n> %v", bp.Title, Ts2Str(bp.Ts), bp.Content)
|
|
|
}
|
|
|
|
|
|
-func (bp BeaconParam) FormatHTML() string {
|
|
|
+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 BeaconParam) FormatPlainText() string {
|
|
|
+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(*BeaconParam) error
|
|
|
+ Send(*BeaconMessage) error
|
|
|
}
|