~kris/9p

disco

34b871c516e51f6e1e6f74393465edf87eaf85f2 — Sean Hinchee 7 years ago 77142a2
Add -t flag to hide timestamps in message prints (thanks halfwit)
2 files changed, 16 insertions(+), 4 deletions(-)

M helper.go
M main.go
M helper.go => helper.go +7 -4
@@ 87,11 87,14 @@ func Notify(m *discordgo.Message) {
//MessagePrint prints one correctly formatted Message to stdout
func MessagePrint(Time, Username, Content string) {
	//var Color color.Attribute
	TimeStamp, _ := time.Parse(time.RFC3339, Time)
	LocalTime := TimeStamp.Local().Format("2006/01/02 15:04:05")

	log.SetFlags(0)
	log.Printf("%s > %s > %s\n", LocalTime, Username, Content)
	if *timeStamp {
		TimeStamp, _ := time.Parse(time.RFC3339, Time)
		LocalTime := TimeStamp.Local().Format("2006/01/02 15:04:05")
		log.Printf("%s > %s > %s\n", LocalTime, Username, Content)
	} else {
		log.Printf("%s > %s\n", Username, Content)
	}
	log.SetFlags(log.LstdFlags)
}


M main.go => main.go +9 -0
@@ 3,6 3,7 @@
package main

import (
	"flag"
	"log"
	"regexp"
	"bitbucket.org/henesy/disco/DiscordState"


@@ 33,7 34,15 @@ var State *DiscordState.State
//MsgType is a string containing global message type
type MsgType string

var timeStamp = flag.Bool("t", true, "Hide timestamps in channel log")

func main() {

	flag.Parse()
	if flag.Lookup("h") != nil {
		flag.Usage()
		os.Exit(1)
	}
	//Initialize Config
	GetConfig()
	CheckState()