Files
artalkjs/internal/anti_spam/aliyun.go
T
qwqcode cf7725edba refactor(go): bump the module version and support go install (#979)
BREAKING CHANGE: The original Go module name was `github.com/ArtalkJS/Artalk`, which has now been modified to `github.com/artalkjs/artalk/v2` (all lowercase). This change may affect the CI pipeline or other areas if you are compiling the Artalk server and have specified the fixed Go module name. Regarding the original `-ldflags -X github.com/ArtalkJS/Artalk/internal/config.Version` and `CommitHash` definitions, please remove them, as they are now obsolete. The `Version` has been hardcoded into the Go code, and the `CommitHash` is now read from the Go build info via runtime/debug’s vcs.revision value. This change only affects the server developers and does not impact the frontend UI client.
2024-09-18 21:43:43 +08:00

41 lines
959 B
Go

package anti_spam
import (
"fmt"
"github.com/artalkjs/artalk/v2/internal/cloud/aliyun"
)
var _ Checker = (*AliyunChecker)(nil)
type AliyunChecker struct {
AccessKeyID string
AccessKeySecret string
Region string
}
func NewAliyunChecker(accessKeyID, accessKeySecret, region string) Checker {
return &AliyunChecker{
AccessKeyID: accessKeyID,
AccessKeySecret: accessKeySecret,
Region: region,
}
}
func (*AliyunChecker) Name() string {
return "aliyun"
}
// 阿里云反垃圾
// @link https://help.aliyun.com/document_detail/70409.html
// @link https://help.aliyun.com/document_detail/107743.html 接入地址
func (c *AliyunChecker) Check(p *CheckerParams) (bool, error) {
return aliyun.GreenText(aliyun.GreenTextConf{
AccessKeyId: c.AccessKeyID,
AccessKeySecret: c.AccessKeySecret,
Region: c.Region,
Content: p.Content,
DataID: fmt.Sprintf("comment-%d", p.CommentID),
})
}