Drn 2 роки тому
батько
коміт
b688b4d637
6 змінених файлів з 12 додано та 17 видалено
  1. 2 8
      discord.go
  2. 1 4
      downloads.go
  3. 3 3
      go.mod
  4. 4 0
      go.sum
  5. 1 1
      handlers.go
  6. 1 1
      history.go

+ 2 - 8
discord.go

@@ -156,13 +156,7 @@ func filenameKeyReplacement(channelConfig configurationChannel, download downloa
 				filenameDateFormat = *channelConfig.OverwriteFilenameDateFormat
 			}
 		}
-		messageTime := time.Now()
-		if download.Message.Timestamp != "" {
-			messageTimestamp, err := download.Message.Timestamp.Parse()
-			if err == nil {
-				messageTime = messageTimestamp
-			}
-		}
+		messageTime := download.Message.Timestamp
 
 		shortID, err := shortid.Generate()
 		if err != nil && config.DebugOutput {
@@ -513,7 +507,7 @@ func isLocalAdmin(m *discordgo.Message) bool {
 	return botSelf || botAdmin || guildOwner || guildAdmin || localManageMessages
 }
 
-func hasPerms(channelID string, permission int) bool {
+func hasPerms(channelID string, permission int64) bool {
 	if !config.CheckPermissions {
 		return true
 	}

+ 1 - 4
downloads.go

@@ -387,10 +387,7 @@ func getDownloadLinks(inputURL string, channelID string) map[string]string {
 func getFileLinks(m *discordgo.Message) []*fileItem {
 	var fileItems []*fileItem
 
-	linkTime, err := m.Timestamp.Parse()
-	if err != nil {
-		linkTime = time.Now()
-	}
+	linkTime := m.Timestamp
 
 	rawLinks := getRawLinks(m)
 	for _, rawLink := range rawLinks {

+ 3 - 3
go.mod

@@ -10,9 +10,9 @@ require (
 	github.com/Necroforger/dgrouter v0.0.0-20200517224846-e66453b957c1
 	github.com/PuerkitoBio/goquery v1.6.1
 	github.com/aidarkhanov/nanoid/v2 v2.0.5
+	github.com/bwmarrin/discordgo v0.22.0
 	github.com/fatih/color v1.10.0
 	github.com/fsnotify/fsnotify v1.4.9
-	github.com/bwmarrin/discordgo v0.22.0
 	github.com/hako/durafmt v0.0.0-20210316092057-3a2c319c1acd
 	github.com/hashicorp/go-version v1.3.0
 	github.com/kennygrant/sanitize v1.2.4
@@ -37,7 +37,7 @@ require (
 	github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
 	github.com/golang/protobuf v1.5.2 // indirect
 	github.com/googleapis/gax-go/v2 v2.0.5 // indirect
-	github.com/gorilla/websocket v1.4.0 // indirect
+	github.com/gorilla/websocket v1.4.2 // indirect
 	github.com/mattn/go-colorable v0.1.8 // indirect
 	github.com/mattn/go-isatty v0.0.12 // indirect
 	github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
@@ -54,4 +54,4 @@ require (
 
 replace github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.1
 
-replace github.com/bwmarrin/discordgo => github.com/get-got/discordgo v0.22.0-1
+replace github.com/bwmarrin/discordgo => github.com/get-got/discordgo v0.26.1-9

+ 4 - 0
go.sum

@@ -105,6 +105,10 @@ github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 h1:GOfMz6cRgTJ9j
 github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17/go.mod h1:HfkOCN6fkKKaPSAeNq/er3xObxTW4VLeY6UUK895gLQ=
 github.com/get-got/discordgo v0.22.0-1 h1:vsI3ized27PXc0CklH79ifRZF0gdUstEsilePpKATnk=
 github.com/get-got/discordgo v0.22.0-1/go.mod h1:V55L1D794gP9/0C53HxVDj7iKDwcn9lLeiWSatdzxTg=
+github.com/get-got/discordgo v0.26.1-8 h1:DGABQHN+4EpLAG6HTN+kmdvFiMTUPDM8/on6zKUAdxY=
+github.com/get-got/discordgo v0.26.1-8/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
+github.com/get-got/discordgo v0.26.1-9 h1:tBrsEubZAuWAXBN4jPLtcUZ3U38yeA2Q3zzTY5uZP/k=
+github.com/get-got/discordgo v0.26.1-9/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=
 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=

+ 1 - 1
handlers.go

@@ -34,7 +34,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
 }
 
 func messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) {
-	if m.EditedTimestamp != discordgo.Timestamp("") {
+	if m.EditedTimestamp.IsZero() {
 		handleMessage(m.Message, true, false)
 	}
 }

+ 1 - 1
history.go

@@ -191,7 +191,7 @@ func handleHistory(commandingMessage *discordgo.Message, subjectChannelID string
 				}
 				// Go Back
 				beforeID = messages[len(messages)-1].ID
-				beforeTime, err = messages[len(messages)-1].Timestamp.Parse()
+				beforeTime = messages[len(messages)-1].Timestamp
 				if err != nil {
 					log.Println(logPrefixHistory, color.RedString(logPrefix+"Failed to fetch message timestamp:\t%s", err))
 				}