This commit is contained in:
2019-12-19 03:16:08 +00:00
parent f0257e1792
commit 9f159ebde5
4 changed files with 193 additions and 9 deletions
+22 -6
View File
@@ -2,12 +2,10 @@ package eve
import (
"fmt"
"time"
"strings"
"time"
)
// GetActiveChannels will parse a list of files for ones with today's timestamps
// This really just returns a list of human-readable channel names so
// there will be some eve specific logic to guess the channel name
@@ -35,7 +33,6 @@ func GetActiveChannels(fileList []string) []string {
}
}
for _, file := range candidateFiles {
fmt.Println(file)
chanList = append(chanList, chatNameFromFile(file))
@@ -46,10 +43,30 @@ func GetActiveChannels(fileList []string) []string {
return chanList
}
// IsCurrentLog will return True if the logfile has a timestamp that looks like
// Today or Yesterdays (there is an assumption that the eve client won't be run for more than 24hrs strait)
func IsCurrentLog(file string) bool {
timeToday := time.Now()
timeYesterday := time.Now().Add(-24 * time.Hour)
layout := "20060102"
todayString := fmt.Sprintf(timeToday.Format(layout))
yesterdayString := fmt.Sprintf(timeYesterday.Format(layout))
fileNameSplit := strings.Split(file, "/")
fileName := fileNameSplit[len(fileNameSplit)-1] // returns file name without any "/" prefixes
if strings.Contains(fileName, todayString) {
return true
}
if strings.Contains(fileName, yesterdayString) {
return true
}
return false
}
func chatNameFromFile(fname string) string {
a := strings.Split(fname, "/")
b := a[len(a)-1] // returns file name without any "/" prefixes
b := a[len(a)-1] // returns file name without any "/" prefixes
// create a rune of the file name only
c := []rune(b)
@@ -64,7 +81,6 @@ func chatNameFromFile(fname string) string {
return myShortString
}
// TODO: run a uniq pass on the list of channels maybe
//func unique(intSlice []int) []int {
// keys := make(map[int]bool)