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

Commit

Permalink
Add NSFW checker
Browse files Browse the repository at this point in the history
  • Loading branch information
JustHumanz committed Mar 27, 2021
1 parent 6b62f99 commit 6824a0e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 74 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v3.4.1
- Add NSFW checker

v3.4.0
- Remove Danbooru lewd
- Add pixiv R18
Expand Down
157 changes: 83 additions & 74 deletions service/frontend/general_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,79 +145,56 @@ func Lewd(s *discordgo.Session, m *discordgo.MessageCreate) {
)

if strings.HasPrefix(m.Content, Prefix) {
SendNude := func(Data *database.DataFanart) bool {
Color, err := engine.GetColor(config.TmpDir, m.Author.AvatarURL("128"))
if err != nil {
log.Error(err)
}

if Data.State == config.PixivArt {
embed = engine.NewEmbed().
SetAuthor(m.Author.Username, m.Author.AvatarURL("128")).
SetTitle(Data.Author).
SetDescription(RemovePic(Data.Text)).
SetURL(Data.PermanentURL).
SetImage(config.PixivProxy+Pic).
SetColor(Color).
InlineAllFields().
SetFooter(Msg, config.PixivIMG).MessageEmbed
} else {
embed = engine.NewEmbed().
SetAuthor(m.Author.Username, m.Author.AvatarURL("128")).
SetTitle(Data.Author).
SetThumbnail(engine.GetAuthorAvatar(Data.Author)).
SetDescription(RemovePic(Data.Text)).
SetURL(Data.PermanentURL).
SetImage(Pic).
SetColor(Color).
InlineAllFields().
SetFooter(Msg, config.TwitterIMG).MessageEmbed
}
msg, err := s.ChannelMessageSendEmbed(m.ChannelID, embed)
if err != nil {
log.Error(err, msg)
}
err = engine.Reacting(map[string]string{
"ChannelID": m.ChannelID,
"Content": m.Content,
"Prefix": Prefix,
}, s)
if err != nil {
log.Error(err)
}
return true
ChannelRaw, err := s.Channel(m.ChannelID)
if err != nil {
log.Error(err)
}
for _, GroupData := range Payload.VtuberData {
if m.Content == strings.ToLower(Prefix+GroupData.GroupName) {
FanArtData, err := database.GetLewd(GroupData.ID, 0)
if ChannelRaw.NSFW {
SendNude := func(Data *database.DataFanart) bool {
Color, err := engine.GetColor(config.TmpDir, m.Author.AvatarURL("128"))
if err != nil {
log.Error(err)
s.ChannelMessageSend(m.ChannelID, "Opps,something goes worng,like dev life\n"+err.Error())
return
}

if FanArtData.Videos != "" {
Msg = "Video type,check original post"
Pic = config.NotFound
} else if len(FanArtData.Photos) > 0 {
Pic = FanArtData.Photos[0]
Msg = "1/" + strconv.Itoa(len(FanArtData.Photos)) + " Photos"
if Data.State == config.PixivArt {
embed = engine.NewEmbed().
SetAuthor(m.Author.Username, m.Author.AvatarURL("128")).
SetTitle(Data.Author).
SetDescription(RemovePic(Data.Text)).
SetURL(Data.PermanentURL).
SetImage(config.PixivProxy+Pic).
SetColor(Color).
InlineAllFields().
SetFooter(Msg, config.PixivIMG).MessageEmbed
} else {
embed = engine.NewEmbed().
SetAuthor(m.Author.Username, m.Author.AvatarURL("128")).
SetTitle(Data.Author).
SetThumbnail(engine.GetAuthorAvatar(Data.Author)).
SetDescription(RemovePic(Data.Text)).
SetURL(Data.PermanentURL).
SetImage(Pic).
SetColor(Color).
InlineAllFields().
SetFooter(Msg, config.TwitterIMG).MessageEmbed
}

for _, v := range GroupData.Members {
if v.ID == FanArtData.Member.ID {
FanArtData.AddMember(v)
break
}
msg, err := s.ChannelMessageSendEmbed(m.ChannelID, embed)
if err != nil {
log.Error(err, msg)
}

Group = SendNude(FanArtData)
break
err = engine.Reacting(map[string]string{
"ChannelID": m.ChannelID,
"Content": m.Content,
"Prefix": Prefix,
}, s)
if err != nil {
log.Error(err)
}
return true
}

for _, MemberData := range GroupData.Members {
if m.Content == strings.ToLower(Prefix+MemberData.Name) || m.Content == strings.ToLower(Prefix+MemberData.JpName) {
FanArtData, err := database.GetLewd(0, MemberData.ID)
for _, GroupData := range Payload.VtuberData {
if m.Content == strings.ToLower(Prefix+GroupData.GroupName) {
FanArtData, err := database.GetLewd(GroupData.ID, 0)
if err != nil {
log.Error(err)
s.ChannelMessageSend(m.ChannelID, "Opps,something goes worng,like dev life\n"+err.Error())
Expand All @@ -228,23 +205,55 @@ func Lewd(s *discordgo.Session, m *discordgo.MessageCreate) {
Msg = "Video type,check original post"
Pic = config.NotFound
} else if len(FanArtData.Photos) > 0 {
Msg = "1/" + strconv.Itoa(len(FanArtData.Photos)) + " Photos"
Pic = FanArtData.Photos[0]
Msg = "1/" + strconv.Itoa(len(FanArtData.Photos)) + " Photos"
}

FanArtData.AddMember(MemberData)
Member = SendNude(FanArtData)
for _, v := range GroupData.Members {
if v.ID == FanArtData.Member.ID {
FanArtData.AddMember(v)
break
}
}

Group = SendNude(FanArtData)
break
}

for _, MemberData := range GroupData.Members {
if m.Content == strings.ToLower(Prefix+MemberData.Name) || m.Content == strings.ToLower(Prefix+MemberData.JpName) {
FanArtData, err := database.GetLewd(0, MemberData.ID)
if err != nil {
log.Error(err)
s.ChannelMessageSend(m.ChannelID, "Opps,something goes worng,like dev life\n"+err.Error())
return
}

if FanArtData.Videos != "" {
Msg = "Video type,check original post"
Pic = config.NotFound
} else if len(FanArtData.Photos) > 0 {
Msg = "1/" + strconv.Itoa(len(FanArtData.Photos)) + " Photos"
Pic = FanArtData.Photos[0]
}

FanArtData.AddMember(MemberData)
Member = SendNude(FanArtData)
break
}
}
}
}

if Member || Group {
return
}
if Member || Group {
return
}

if !Group && !Member {
s.ChannelMessageSend(m.ChannelID, "`"+m.Content[len(Prefix):]+"` was invalid name")
if !Group && !Member {
s.ChannelMessageSend(m.ChannelID, "`"+m.Content[len(Prefix):]+"` was invalid name")
}
} else {
s.ChannelMessageSend(m.ChannelID, "i know you horny,but this channel was not a NSFW channel")
return
}
}
}
Expand Down

0 comments on commit 6824a0e

Please sign in to comment.