Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 1c80c55

Browse files
authored
Merge pull request #338 from JustHumanz/blacklist-fanart
Blacklist fanart
2 parents 5b89ba8 + 790ddc7 commit 1c80c55

5 files changed

Lines changed: 78 additions & 46 deletions

File tree

config.toml.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ DonationLink = "#DonationLink"
77
Domain = "humanz.tech"
88
LowResources = true
99

10+
[BannFanartAccount]
11+
Twitter = ["VtuberAnlysBot"]
12+
1013
YoutubeToken = [
1114
"#GoogleAPI",
1215
"#GoogleAPI"

pkg/config/config.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,24 @@ const (
151151

152152
//ConfigFile config file struct for config.toml
153153
type ConfigFile struct {
154-
Discord string `toml:"Discord"`
155-
BiliSess string `toml:"BiliSess"`
156-
PixivSession string `toml:"PixivSess"`
157-
SauceAPI string `toml:"SauceAPI"`
158-
InviteLog string `toml:"InviteLog"`
159-
PilotReporting string `toml:"PilotReporting"`
160-
MultiTOR string `toml:"Multitor"`
161-
DonationLink string `toml:"DonationLink"`
162-
TopGG string `toml:"TOPGG"`
163-
Domain string `toml:"Domain"`
164-
PrometheusURL string `toml:"PrometheusURL"`
165-
Metric bool `toml:"Metric"`
166-
Twitch struct {
154+
Discord string `toml:"Discord"`
155+
BiliSess string `toml:"BiliSess"`
156+
PixivSession string `toml:"PixivSess"`
157+
SauceAPI string `toml:"SauceAPI"`
158+
InviteLog string `toml:"InviteLog"`
159+
PilotReporting string `toml:"PilotReporting"`
160+
MultiTOR string `toml:"Multitor"`
161+
DonationLink string `toml:"DonationLink"`
162+
TopGG string `toml:"TOPGG"`
163+
Domain string `toml:"Domain"`
164+
PrometheusURL string `toml:"PrometheusURL"`
165+
Metric bool `toml:"Metric"`
166+
BannFanartAccount struct {
167+
Twitter []string `toml:"Twitter"`
168+
BiliBili []string `toml:"BiliBili"`
169+
Pixiv []string `toml:"Pixiv"`
170+
} `toml:"BannFanartAccount"`
171+
Twitch struct {
167172
ClientID string `toml:"ClientID"`
168173
ClientSecret string `toml:"ClientSecret"`
169174
} `toml:"Twitch"`

pkg/database/fanart.go

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -555,40 +555,50 @@ func (Member Member) ScrapTwitterFanart(Scraper *twitterscraper.Scraper, Lewd bo
555555
continue
556556
}
557557

558-
for _, TweetHashtag := range tweet.Hashtags {
559-
if (strings.EqualFold("#"+TweetHashtag, Member.TwitterHashtag) || strings.EqualFold("#"+TweetHashtag, Member.TwitterLewd)) && !tweet.IsQuoted && !tweet.IsReply && len(tweet.Photos) > 0 {
560-
TweetArt := DataFanart{
561-
PermanentURL: tweet.PermanentURL,
562-
Author: tweet.Username,
563-
AuthorAvatar: func() string {
564-
profile, err := Scraper.GetProfile(tweet.Username)
565-
if err != nil {
566-
log.Error(err)
567-
}
568-
return strings.Replace(profile.Avatar, "normal.jpg", "400x400.jpg", -1)
569-
}(),
570-
TweetID: tweet.ID,
571-
Text: func() string {
572-
return regexp.MustCompile(`(?m)^(.*?)https:\/\/t.co\/.+`).ReplaceAllString(tweet.Text, "${1}$2")
573-
}(),
574-
Photos: tweet.Photos,
575-
Likes: tweet.Likes,
576-
Member: Member,
577-
State: config.TwitterArt,
578-
Lewd: Lewd,
579-
Group: Member.Group,
580-
}
581-
if tweet.Videos != nil {
582-
TweetArt.Videos = tweet.Videos[0].Preview
583-
}
584-
585-
New, err := TweetArt.CheckTweetFanArt(update)
586-
if err != nil {
587-
return nil, err
588-
}
558+
for _, Ban := range config.GoSimpConf.BannFanartAccount.Twitter {
559+
if strings.EqualFold(Ban, tweet.Username) {
560+
continue
561+
}
562+
}
589563

590-
if New {
591-
FanartList = append(FanartList, TweetArt)
564+
if !tweet.IsQuoted && !tweet.IsReply && len(tweet.Photos) > 0 {
565+
for _, TweetHashtag := range tweet.Hashtags {
566+
if strings.EqualFold("#"+TweetHashtag, Member.TwitterHashtag) || strings.EqualFold("#"+TweetHashtag, Member.TwitterLewd) {
567+
TweetArt := DataFanart{
568+
PermanentURL: tweet.PermanentURL,
569+
Author: tweet.Username,
570+
AuthorAvatar: func() string {
571+
profile, err := Scraper.GetProfile(tweet.Username)
572+
if err != nil {
573+
log.Error(err)
574+
}
575+
return strings.Replace(profile.Avatar, "normal.jpg", "400x400.jpg", -1)
576+
}(),
577+
TweetID: tweet.ID,
578+
Text: func() string {
579+
return regexp.MustCompile(`(?m)^(.*?)https:\/\/t.co\/.+`).ReplaceAllString(tweet.Text, "${1}$2")
580+
}(),
581+
Photos: tweet.Photos,
582+
Likes: tweet.Likes,
583+
Member: Member,
584+
State: config.TwitterArt,
585+
Lewd: Lewd,
586+
Group: Member.Group,
587+
}
588+
if tweet.Videos != nil {
589+
TweetArt.Videos = tweet.Videos[0].Preview
590+
}
591+
592+
New, err := TweetArt.CheckTweetFanArt(update)
593+
if err != nil {
594+
return nil, err
595+
}
596+
597+
if New {
598+
FanartList = append(FanartList, TweetArt)
599+
}
600+
601+
break
592602
}
593603
}
594604
}

service/fanart/bilibili/bilibili.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"flag"
77
"net/url"
8+
"strings"
89
"sync"
910
"time"
1011

@@ -216,6 +217,13 @@ func (k *checkBlJob) Run() {
216217
"Vtuber": Member.Name,
217218
}).Error(err)
218219
}
220+
221+
for _, Ban := range config.GoSimpConf.BannFanartAccount.BiliBili {
222+
if strings.EqualFold(Ban, v.Desc.UserProfile.Info.Uname) {
223+
continue
224+
}
225+
}
226+
219227
if STB.Item.Pictures != nil && v.Desc.Type == 2 { //type 2 is picture post (prob,heheheh)
220228
for _, pic := range STB.Item.Pictures {
221229
img = append(img, pic.ImgSrc)

service/fanart/pixiv/pixiv.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ func Pixiv(p string, FixFanArt *database.DataFanart, l bool) error {
212212
TextFix string
213213
)
214214

215+
for _, Ban := range config.GoSimpConf.BannFanartAccount.Pixiv {
216+
if strings.EqualFold(Ban, v2["userName"].(string)) {
217+
continue
218+
}
219+
}
220+
215221
if IsVtuber {
216222
if v2["xRestrict"].(float64) == 0 && !l {
217223
illusbyte, err := network.Curl(config.PixivIllustsEnd+v2["id"].(string), nil)

0 commit comments

Comments
 (0)