-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinit.go
56 lines (48 loc) · 1.43 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package onebyone
import (
"encoding/json"
"strings"
"github.com/cdle/sillyGirl/core"
"github.com/gin-gonic/gin"
)
type AutoGenerated struct {
PtPin string `json:"pt_pin"`
Message string `json:"message"`
}
func init() {
core.Server.POST("/onebyone/push", func(c *gin.Context) {
data, _ := c.GetRawData()
ag := &AutoGenerated{}
json.Unmarshal(data, ag)
ptPin := ag.PtPin
message := ag.Message
for _, tp := range []string{
"qq", "tg", "wx",
} {
core.Bucket("pin" + strings.ToUpper(tp)).Foreach(func(k, v []byte) error {
translateEmoji(&message, tp == "wx")
if string(k) == ptPin && ptPin != "" {
if push, ok := core.Pushs[tp]; ok {
push(string(v), message, nil, nil)
}
}
return nil
})
}
c.String(200, "ok")
})
}
func translateEmoji(str *string, isWechat bool) {
if !isWechat {
return
}
*str = strings.Replace(*str, "⭕", "[emoji=\\u2b55]", -1)
*str = strings.Replace(*str, "🧧", "[emoji=\\uD83E\\uDDE7]", -1)
*str = strings.Replace(*str, "🥚", "[emoji=\\ud83e\\udd5a]", -1)
*str = strings.Replace(*str, "💰", "[emoji=\\ud83d\\udcb0]", -1)
*str = strings.Replace(*str, "⏰", "[emoji=\\u23f0]", -1)
*str = strings.Replace(*str, "🍒", "[emoji=\\ud83c\\udf52]", -1)
*str = strings.Replace(*str, "🐶", "[emoji=\\ud83d\\udc36]", -1)
*str = strings.Replace(*str, "🎰", "[emoji=\\ud83c\\udfb0]", -1)
*str = strings.Replace(*str, "🌂", "[emoji=\\ud83c\\udf02]", -1)
}