Compare commits
No commits in common. "18a07ec828d51c02a42a2a725c3518b84342bd56" and "c5015145b2e72d336dc1388445cec79b4e9d096d" have entirely different histories.
18a07ec828
...
c5015145b2
1 changed files with 1 additions and 44 deletions
|
@ -26,7 +26,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
urls := rxStrict.FindAllString(message.Content, -1)
|
||||
if len(urls) > 0 {
|
||||
response := discordgo.MessageSend {
|
||||
Content: "Woah there partner! I detect some services that aren't very privacy friendly. Let me help you with that!",
|
||||
Content: "Woah there partner! I detect some services that aren't very privacy friendly. Let me help you with that!\n",
|
||||
Reference: message.Reference(),
|
||||
Files: []*discordgo.File{},
|
||||
}
|
||||
|
@ -218,49 +218,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
}
|
||||
}
|
||||
|
||||
respond = true
|
||||
} else if output, _ := regexp.MatchString("(http.*reddit\\.com/r/\\.*)", url); output {
|
||||
log.Println("Reddit detected.")
|
||||
|
||||
response.Content = response.Content + fmt.Sprintf("\n<%s>", regexp.MustCompile("http.*reddit\\.com").ReplaceAllString(url, "https://libreddit.spike.codes"))
|
||||
|
||||
// Reddit's native format is 'mpegts', which Discord cannot preview. This code however does produce a usable video with audio.
|
||||
/*
|
||||
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
||||
if err != nil {
|
||||
// If it's complaining due to a lack of videos, don't care.
|
||||
if noVideo, _ := regexp.MatchString(".*No media found.*", err.Error()); noVideo {
|
||||
respond = true
|
||||
} else {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
continue
|
||||
} else {
|
||||
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
|
||||
log.Printf("Choice: %s+%s | Size: %fM\n", videoChoice.FormatID, audioChoice.FormatID, (videoChoice.FilesizeApprox+audioChoice.FilesizeApprox)/1024/1024)
|
||||
if err == nil {
|
||||
session.ChannelTyping(message.ChannelID)
|
||||
downloadResult, err := result.Download(context.Background(), fmt.Sprintf("%s+%s", videoChoice.FormatID, audioChoice.FormatID))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
//session.ChannelMessageSend(message.ChannelID, err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
response.Files = append(response.Files, &discordgo.File {
|
||||
Name: fmt.Sprintf("%s.%s", result.Info.ID, videoChoice.Ext),
|
||||
ContentType: "text/plain", // This is of course not true, but Discord doesn't give a shit
|
||||
Reader: downloadResult,
|
||||
})
|
||||
|
||||
defer downloadResult.Close()
|
||||
} else {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
respond = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue