-
Notifications
You must be signed in to change notification settings - Fork 1
/
account.go
42 lines (34 loc) · 1.27 KB
/
account.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
package tg_channel
import (
"github.com/Crossbell-Box/OperatorSync/app/worker/config"
"github.com/Crossbell-Box/OperatorSync/app/worker/global"
"github.com/Crossbell-Box/OperatorSync/app/worker/utils"
commonConsts "github.com/Crossbell-Box/OperatorSync/common/consts"
"strings"
)
func Account(username string, validateString string) (bool, uint, string, bool) {
global.Logger.Debug("Validate string: ", validateString)
// RSSHub will index userinfo, so we need to parse their feeds
collectLink := commonConsts.SUPPORTED_PLATFORM["tg_channel"].FeedLink
collectLink =
strings.ReplaceAll(
collectLink,
"{{rsshub_stateless}}",
config.Config.RSSHubEndpointStateless,
)
if rawFeed, errCode, err := utils.RSSFeedRequestJson(
strings.ReplaceAll(collectLink, "{{username}}", username),
true,
); err != nil {
global.Logger.Error("Failed to collect tg_channel feeds of user ", username, " for account validate with error: ", err.Error())
return false, errCode, err.Error(), false
} else {
if strings.Contains(strings.ToLower(rawFeed.Description), validateString) {
global.Logger.Debug("Account verify succeeded")
return true, 0, "", true
} else {
global.Logger.Debug("No validate string found: ", rawFeed.Description)
return true, 0, "", false
}
}
}