From 7fb042d7283879fb3eac8723637d13b14c95915c Mon Sep 17 00:00:00 2001 From: henesy Date: Sat, 5 Oct 2019 03:17:50 -0700 Subject: [PATCH] =?UTF-8?q?.hgignore=20=E2=86=92=20.gitignore=20;;=20add?= =?UTF-8?q?=20usage=20to=20readme=20;;=20make=20vet=20tool=20pass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hgignore => .gitignore | 1 - README.md | 31 +++++++++++++++++++++---------- config.go | 2 +- main.go | 18 +++++++++--------- menu.go | 4 ++-- 5 files changed, 33 insertions(+), 23 deletions(-) rename .hgignore => .gitignore (61%) diff --git a/.hgignore b/.gitignore similarity index 61% rename from .hgignore rename to .gitignore index 4811dab221b8c1a5f6bf7f874df85f0c351d5b9c..bac634065350e16ec382d599c13fdfd17236f9b8 100644 --- a/.hgignore +++ b/.gitignore @@ -1,4 +1,3 @@ -syntax: glob *.patch *.diff disco diff --git a/README.md b/README.md index a3a65b094de81d3f2ba1b3dbf19104250b13af06..d90000f0a431b6df96cd0779e2c336ae0678ca9c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # disco: [Discord](https://discord.gg) client for 9front -Fork of theboxmage's [discord-cli](https://github.com/theboxmage/discordcli) +Fork of theboxmage's [discord-cli](https://github.com/theboxmage/discordcli). -NDB config is in `$home/lib/disco.ndb` for setting password, should be made automatically after first run. +Ndb config is in `$home/lib/disco.ndb` for setting password, should be made automatically after first run. Alternatively, you may use factotum. ## Install @@ -18,17 +18,23 @@ NDB config is in `$home/lib/disco.ndb` for setting password, should be made auto ### Installation ``` -go get github.com/henesy/disco -go install github.com/henesy/disco +% go get github.com/henesy/disco +% go install github.com/henesy/disco ``` -## Problems - -* Does not create accounts for you, this still needs to be done in a browser/app +## Usage -* Does not support 2FA (Discord API explicitly does not allow this) +``` +% disco -h +Usage of disco: + -n Enable notifications + -t Hide timestamps in channel log + -w string + Dimensions to pass through to statusmsg (default "10,10,260,90") +``` ## Commands + Commands available in chat: | Command | Function | @@ -48,7 +54,7 @@ You can regex the last message sent using a format such as: ## Config -A basic $home/lib/disco.ndb looks something like: +A basic `$home/lib/disco.ndb` looks something like: ``` auth=pass @@ -57,7 +63,7 @@ messages=10 promptchar=→ timestampchar=> -username=cooldude@mycooldomain.com password=somepassword1 +username=coolperson@mycooldomain.com password=somepassword1 ``` Note that the auth= tuple accepts @@ -88,3 +94,8 @@ Q: What if I get an error about signing in from a new location? A: Discord has sent you an e-mail with a location confirmation link, click it, no js should be required. +## Problems + +* Does not create accounts for you, this still needs to be done in a browser/app +* Does not support 2FA (Discord API explicitly does not allow this) + diff --git a/config.go b/config.go index 1a5c1c5ca5f7277101ad58b2589cad57ecbf238a..13e7e6a4b5e4096a571eedb14104e92907af4b90 100644 --- a/config.go +++ b/config.go @@ -1,9 +1,9 @@ package main import ( - "github.com/Plan9-Archive/libauth" "bufio" "fmt" + "github.com/Plan9-Archive/libauth" "github.com/mischief/ndb" "log" "os" diff --git a/main.go b/main.go index 89a018ddb024930c85ef562adbb3d3bb4395d3b2..f9779ff7f53300331bdd3641e515f3c38a1bb9d5 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,10 @@ package main import ( - "github.com/henesy/disco/DiscordState" "bufio" "flag" "fmt" + "github.com/henesy/disco/DiscordState" "io" "log" "os" @@ -23,7 +23,7 @@ const ( ) // Version is current version const -const Version = "2.3" +const Version = "2.3" // Session is global Session var Session *DiscordState.Session @@ -161,7 +161,7 @@ func ParseForMentions(line string) string { r, err := regexp.Compile("@\\w+") if err != nil { - Msg(ErrorMsg, "Regex Error: ", err) + Msg(ErrorMsg, "Regex Error: %s\n", err) } lineByte := r.ReplaceAllStringFunc(line, ReplaceMentions) @@ -174,18 +174,18 @@ func ReplaceMentions(input string) string { if len(input) < 2 { return input } - + name := input[1:] - + // Get up to 1000 members as per documented max starting from the top members, err := Session.DiscordGo.GuildMembers(State.Guild.ID, "", 1000) if err != nil { - Msg(ErrorMsg, "Could not Lookup Members: ", err) + Msg(ErrorMsg, "Could not Lookup Members: %s\n", err) return input } // Check for guild members that match - for _, member := range members { + for _, member := range members { if strings.HasPrefix(member.Nick, name) { return member.User.Mention() } @@ -194,7 +194,7 @@ func ReplaceMentions(input string) string { return member.User.Mention() } } - + // Walk all PM channels userChannels, err := Session.DiscordGo.UserChannels() @@ -218,7 +218,7 @@ func ParseForEmoji(line string) string { r, err := regexp.Compile("<(:\\w+:)[0-9]+>") if err != nil { - Msg(ErrorMsg, "Regex Error: ", err) + Msg(ErrorMsg, "Regex Error: %s\n", err) } return r.ReplaceAllString(line, "$1") diff --git a/menu.go b/menu.go index 8576e799295277dd7fc6dc2e45f75e8e247a3881..f11632f4b1bff84255d3186d0ccc50b94f4784dc 100644 --- a/menu.go +++ b/menu.go @@ -173,11 +173,11 @@ Start: SelectPrivate() } else { State, err = Session.NewState(SelectMap[0], Config.Messages) - + if err != nil { log.Fatal(err) } - + SelectPrivate() } } else {