diff -r b8994b5bf91c helper.go --- a/helper.go Sat Nov 17 01:01:45 2018 -0600 +++ b/helper.go Wed Dec 12 22:19:39 2018 -0700 @@ -1,9 +1,11 @@ package main import ( + "io" "log" "os" "os/exec" + "runtime" "strings" "time" "fmt" @@ -67,6 +69,9 @@ //Notify uses Notify-Send from libnotify to send a notification when a mention arrives. func Notify(m *discordgo.Message) { + if *enableNotify == false { + return + } Channel, err := State.Session.DiscordGo.Channel(m.ChannelID) if err != nil { Msg(ErrorMsg, "(NOT) Channel Error: %s\n", err) @@ -76,24 +81,43 @@ Msg(ErrorMsg, "(NOT) Guild Error: %s\n", err) } Title := "@" + m.Author.Username + " : " + Guild.Name + "/" + Channel.Name - cmd := exec.Command("notify-send", Title, m.ContentWithMentionsReplaced()) - err = cmd.Start() - if err != nil { - Msg(ErrorMsg, "(NOT) Check if libnotify is installed, or disable notifications.\n") + switch runtime.GOOS { + case "plan9": + pr, pw := io.Pipe() + cmd := exec.Command("/bin/aux/statusmsg", "-k", *notifyFlag, Title) + cmd.Stdin = pr + go func() { + defer pw.Close() + fmt.Fprintf(pw, "%s\n", m.ContentWithMentionsReplaced()) + cmd.Wait() + }() + err = cmd.Start() + if err != nil { + Msg(ErrorMsg, "%s\n", err) + } + + default: + cmd := exec.Command("notify-send", Title, m.ContentWithMentionsReplaced()) + err = cmd.Start() + if err != nil { + Msg(ErrorMsg, "(NOT) Check if libnotify is installed, or disable notifications.\n") + } } + } //MessagePrint prints one correctly formatted Message to stdout func MessagePrint(Time, Username, Content string) { //var Color color.Attribute log.SetFlags(0) - if *timeStamp { + if *hideTimeStamp { + log.Printf("%s > %s\n", Username, Content) + } else { 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) } diff -r b8994b5bf91c main.go --- a/main.go Sat Nov 17 01:01:45 2018 -0600 +++ b/main.go Wed Dec 12 22:19:39 2018 -0700 @@ -34,7 +34,9 @@ //MsgType is a string containing global message type type MsgType string -var timeStamp = flag.Bool("t", true, "Hide timestamps in channel log") +var hideTimeStamp = flag.Bool("t", false, "Hide timestamps in channel log") +var enableNotify = flag.Bool("n", false, "Enable notifications") +var notifyFlag = flag.String("w", "10,10,260,90", "Dimensions to pass through to statusmsg") func main() { @@ -43,6 +45,9 @@ flag.Usage() os.Exit(1) } + if flag.Lookup("w") != nil { + *notifyFlag = fmt.Sprintf("-w %s", *notifyFlag) + } //Initialize Config GetConfig() CheckState()