M TODO => TODO +11 -5
@@ 6,6 6,8 @@ Commands:
:d [n] [file] -- dump backlog of last 'n' msgs to a file 'file'
+:c [n] and :c ? to switch and list channels, respectively
+
Features:
* remove JSON config
@@ 14,16 16,20 @@ Features:
* delete disco.cfg on failure to log in for 400 bad request: password does not match
-* ensure proper permissions -rw------- 0600 for discord.cfg
+* verify proper permissions -rw------- 0600 for discord.cfg
* if ``` entered, allow multi-line message (composition)
* replace <:emoji:3lk4j12:> garbage with :emoji:
-* clean up @'s
-
-* replace libnotify shenanigans, add a goroutine to check for pings
+* fix @'s
* flag for larger backlog loading
-* CAPTCHA solution
+* CAPTCHA solution -- http-proxy is a bad one
+
+* change > to → or whtever desired
+
+* fix pm's
+
+* aux/statusmsg backgrounds and doesn't steal input
M helper.go => helper.go +31 -7
@@ 1,9 1,11 @@
package main
import (
+ "io"
"log"
"os"
"os/exec"
+ "runtime"
"strings"
"time"
"fmt"
@@ 67,6 69,9 @@ func PrintMessages(Amount int) {
//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 @@ func Notify(m *discordgo.Message) {
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)
}
M main.go => main.go +6 -1
@@ 34,7 34,9 @@ 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")
+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 @@ func main() {
flag.Usage()
os.Exit(1)
}
+ if flag.Lookup("w") != nil {
+ *notifyFlag = fmt.Sprintf("-w %s", *notifyFlag)
+ }
//Initialize Config
GetConfig()
CheckState()