mirror of
https://github.com/get-got/discord-downloader-go.git
synced 2025-10-29 19:46:49 +00:00
Compare commits
2 Commits
36b6b96960
...
0fcf018b72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fcf018b72 | ||
|
|
3b5e1ebd08 |
33
config.go
33
config.go
@ -145,10 +145,12 @@ func defaultConfiguration() configuration {
|
||||
StickersFilenameFormat: "{{ID}} {{name}}",
|
||||
|
||||
// Source Setup Defaults
|
||||
Save: true,
|
||||
AllowCommands: true,
|
||||
ScanEdits: true,
|
||||
IgnoreBots: true,
|
||||
Save: true,
|
||||
AllowCommands: true,
|
||||
ScanEdits: true,
|
||||
IgnoreBots: true,
|
||||
IgnoreEmojis: true,
|
||||
IgnoreStickers: true,
|
||||
|
||||
SendErrorMessages: false,
|
||||
SendFileToChannel: "",
|
||||
@ -266,6 +268,9 @@ type configuration struct {
|
||||
DownloadTimeout int `json:"downloadTimeout" yaml:"downloadTimeout"`
|
||||
DownloadRetryMax int `json:"downloadRetryMax" yaml:"downloadRetryMax"`
|
||||
SendErrorMessages bool `json:"sendErrorMessages" yaml:"sendErrorMessages"`
|
||||
IgnoreEmojis bool `json:"ignoreEmojis" yaml:"ignoreEmojis"`
|
||||
IgnoreStickers bool `json:"ignoreStickers" yaml:"ignoreStickers"`
|
||||
IgnoreEmojisWEBP *bool `json:"ignoreEmojisWEBP" yaml:"ignoreEmojisWEBP"`
|
||||
|
||||
// Discord Emojis & Stickers
|
||||
EmojisServers *[]string `json:"emojisServers" yaml:"emojisServers"`
|
||||
@ -373,12 +378,14 @@ type configurationSource struct {
|
||||
Aliases *[]string `json:"aliases,omitempty" yaml:"aliases,omitempty"`
|
||||
|
||||
// Setup
|
||||
Enabled *bool `json:"enabled" yaml:"enabled"`
|
||||
Save *bool `json:"save" yaml:"save"`
|
||||
AllowCommands *bool `json:"allowCommands" yaml:"allowCommands"`
|
||||
ScanEdits *bool `json:"scanEdits" yaml:"scanEdits"`
|
||||
IgnoreBots *bool `json:"ignoreBots" yaml:"ignoreBots"`
|
||||
CommandPrefix *string `json:"commandPrefix" yaml:"commandPrefix"`
|
||||
Enabled *bool `json:"enabled" yaml:"enabled"`
|
||||
Save *bool `json:"save" yaml:"save"`
|
||||
AllowCommands *bool `json:"allowCommands" yaml:"allowCommands"`
|
||||
ScanEdits *bool `json:"scanEdits" yaml:"scanEdits"`
|
||||
IgnoreBots *bool `json:"ignoreBots" yaml:"ignoreBots"`
|
||||
CommandPrefix *string `json:"commandPrefix" yaml:"commandPrefix"`
|
||||
IgnoreEmojis *bool `json:"ignoreEmojis" yaml:"ignoreEmojis"`
|
||||
IgnoreStickers *bool `json:"ignoreStickers" yaml:"ignoreStickers"`
|
||||
|
||||
SendErrorMessages *bool `json:"sendErrorMessages" yaml:"sendErrorMessages"`
|
||||
SendFileToChannel *string `json:"sendFileToChannel" yaml:"sendFileToChannel"`
|
||||
@ -1022,6 +1029,12 @@ func sourceDefault(source *configurationSource) {
|
||||
if source.IgnoreBots == nil {
|
||||
source.IgnoreBots = &config.IgnoreBots
|
||||
}
|
||||
if source.IgnoreEmojis == nil {
|
||||
source.IgnoreEmojis = &config.IgnoreEmojis
|
||||
}
|
||||
if source.IgnoreStickers == nil {
|
||||
source.IgnoreStickers = &config.IgnoreStickers
|
||||
}
|
||||
|
||||
if source.SendErrorMessages == nil {
|
||||
source.SendErrorMessages = &config.SendErrorMessages
|
||||
|
||||
42
downloads.go
42
downloads.go
@ -482,12 +482,6 @@ func getParsedLinks(inputURL string, m *discordgo.Message) map[string]string {
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore Discord emojis / stickers
|
||||
if strings.HasPrefix(inputURL, "https://cdn.discordapp.com/emojis/") ||
|
||||
strings.HasPrefix(inputURL, "https://media.discordapp.net/stickers/") {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Try without queries
|
||||
/*parsedURL, err := url.Parse(inputURL)
|
||||
if err == nil {
|
||||
@ -527,6 +521,42 @@ func getLinksByMessage(m *discordgo.Message) []*fileItem {
|
||||
}
|
||||
}
|
||||
|
||||
// Scrape Emojis from message
|
||||
for _, emoji := range m.GetCustomEmojis() {
|
||||
emojisWEBP := false
|
||||
if config.IgnoreEmojisWEBP != nil {
|
||||
emojisWEBP = *config.IgnoreEmojisWEBP
|
||||
}
|
||||
|
||||
link := "https://cdn.discordapp.com/emojis/" + emoji.ID + ".png"
|
||||
if emojisWEBP {
|
||||
link = "https://cdn.discordapp.com/emojis/" + emoji.ID + ".webp"
|
||||
}
|
||||
if emoji.Animated {
|
||||
link = "https://cdn.discordapp.com/emojis/" + emoji.ID + ".gif"
|
||||
if emojisWEBP {
|
||||
link = "https://cdn.discordapp.com/emojis/" + emoji.ID + ".webp?animated=true"
|
||||
}
|
||||
}
|
||||
|
||||
fileItems = append(fileItems, &fileItem{
|
||||
Link: link,
|
||||
Filename: "Emoji " + emoji.Name,
|
||||
Time: linkTime,
|
||||
AttachmentID: "",
|
||||
})
|
||||
}
|
||||
|
||||
// Scrape Stickers from message
|
||||
for _, sticker := range m.StickerItems {
|
||||
fileItems = append(fileItems, &fileItem{
|
||||
Link: "https://media.discordapp.net/stickers/" + sticker.ID + ".png",
|
||||
Filename: "Sticker " + sticker.Name,
|
||||
Time: linkTime,
|
||||
AttachmentID: "",
|
||||
})
|
||||
}
|
||||
|
||||
return trimDuplicateLinks(fileItems)
|
||||
}
|
||||
|
||||
|
||||
@ -391,6 +391,10 @@ func handleMessage(m *discordgo.Message, c *discordgo.Channel, edited bool, hist
|
||||
if file.Link == "" {
|
||||
continue
|
||||
}
|
||||
if (*sourceConfig.IgnoreEmojis && strings.HasPrefix(file.Link, "https://cdn.discordapp.com/emojis/")) ||
|
||||
(*sourceConfig.IgnoreStickers && strings.HasPrefix(file.Link, "https://media.discordapp.net/stickers/")) {
|
||||
continue
|
||||
}
|
||||
// Filter Checks
|
||||
shouldAbort := false
|
||||
if sourceConfig.Filters.BlockedLinkContent != nil {
|
||||
|
||||
2
vars.go
2
vars.go
@ -10,7 +10,7 @@ var (
|
||||
projectRepoBase = "get-got/discord-downloader-go"
|
||||
projectRepoURL = "https://github.com/" + projectRepoBase
|
||||
projectIcon = "https://cdn.discordapp.com/icons/780985109608005703/9dc25f1b91e6d92664590254e0797fad.webp?size=256"
|
||||
projectVersion = "2.5.4-dev" // follows Semantic Versioning, (http://semver.org/)
|
||||
projectVersion = "2.6.0-dev" // follows Semantic Versioning, (http://semver.org/)
|
||||
|
||||
pathCache = "cache"
|
||||
pathCacheHistory = pathCache + string(os.PathSeparator) + "history"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user