Skip to content

Commit

Permalink
[refactor] close #12
Browse files Browse the repository at this point in the history
  • Loading branch information
ronething-bot committed Apr 2, 2022
1 parent ac9afd8 commit 2570988
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 350 deletions.
3 changes: 3 additions & 0 deletions config/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ notify:
pushdeer:
enable: true
token: xxx
feishu:
enable: true
token: xxx

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ require (
github.com/JohannesKaufmann/html-to-markdown v1.3.3
github.com/antchfx/htmlquery v1.2.3 // indirect
github.com/antchfx/xmlquery v1.3.2 // indirect
github.com/cloud-org/msgpush v0.0.2
github.com/go-resty/resty/v2 v2.7.0
github.com/gobwas/glob v0.2.3 // indirect
github.com/gocolly/colly v1.2.0
github.com/imroc/req v0.3.0
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
Expand Down
53 changes: 0 additions & 53 deletions server/dingtalk.go

This file was deleted.

23 changes: 0 additions & 23 deletions server/dingtalk_test.go

This file was deleted.

22 changes: 11 additions & 11 deletions server/infra.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package server

import "fmt"
import (
"fmt"
"github.com/cloud-org/msgpush"
)

const timeFormat = "2006-01-02"

type NotifyPush interface {
Send(string) error
String() string
}

type TokenEnable struct {
Enable bool `json:"enable"`
Token string `json:"token"`
}

func GetNotify(software, token string) (NotifyPush, error) {
func GetNotify(software, token string) (msgpush.NotifyPush, error) {
switch software {
case "dingtalk": // 钉钉推送
return NewDingTalk(token, ""), nil
return msgpush.NewDingTalk(token), nil
case "wecom": // 企业微信推送
return NewWeCom(token, ""), nil
return msgpush.NewWeCom(token), nil
case "slack": // slack 推送
return NewSlack(token, ""), nil
return msgpush.NewSlack(token), nil
case "pushdeer":
return NewPushDeer(token), nil
return msgpush.NewPushDeer(token), nil
case "feishu":
return msgpush.NewFeiShu(token), nil
default:
return nil, fmt.Errorf("暂时不支持类型 %v", software)
}
Expand Down
3 changes: 2 additions & 1 deletion server/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"encoding/json"
"github.com/cloud-org/msgpush"
"log"
"strings"
"time"
Expand All @@ -13,7 +14,7 @@ import (

type NewsPush struct {
Pre string
Notifys []NotifyPush
Notifys []msgpush.NotifyPush
}

func (n *NewsPush) InitNotifys() error {
Expand Down
40 changes: 0 additions & 40 deletions server/pushdeer.go

This file was deleted.

63 changes: 0 additions & 63 deletions server/pushdeer_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion server/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"github.com/cloud-org/msgpush"
"log"
"os"

Expand Down Expand Up @@ -33,7 +34,7 @@ func (s *Scheduler) InitJob() {

cronSpec := config.Config.GetString("cron")
pre := config.Config.GetString("pre")
n := NewsPush{Pre: pre, Notifys: make([]NotifyPush, 0)}
n := NewsPush{Pre: pre, Notifys: make([]msgpush.NotifyPush, 0)}
//n := NewsPush{Pre: pre} 效果相同
err := n.InitNotifys()
if err != nil {
Expand Down
37 changes: 0 additions & 37 deletions server/slack.go

This file was deleted.

23 changes: 0 additions & 23 deletions server/slack_test.go

This file was deleted.

Loading

0 comments on commit 2570988

Please sign in to comment.