-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
tencent.go
43 lines (36 loc) · 951 Bytes
/
tencent.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
package anti_spam
import (
"fmt"
"github.com/ArtalkJS/Artalk/internal/cloud/qcloud"
)
var _ Checker = (*TencentChecker)(nil)
type TencentChecker struct {
SecretID string
SecretKey string
Region string
}
func NewTencentChecker(secretID, secretKey, region string) Checker {
return &TencentChecker{
SecretID: secretID,
SecretKey: secretKey,
Region: region,
}
}
func (*TencentChecker) Name() string {
return "tencent"
}
// 腾讯云文本内容安全 TMS
// @link https://cloud.tencent.com/document/product/1124/51860
// @link https://console.cloud.tencent.com/cms/text/overview
func (c *TencentChecker) Check(p *CheckerParams) (bool, error) {
return qcloud.TMS(qcloud.TmsConf{
SecretID: c.SecretID,
SecretKey: c.SecretKey,
Region: c.Region,
Content: p.Content,
DataID: fmt.Sprintf("comment-%d", p.CommentID),
UserID: fmt.Sprintf("%d", p.UserID),
UserName: p.UserName,
DeviceIP: p.UserIP,
})
}