~kris/9p

disco

3173d640b4857b321b377e3ab41e60db3243bf91 — Sean Hinchee 7 years ago dfe598e
add all sorts of fixes, factotum support, etc. all thanks to halfwit ?
4 files changed, 24 insertions(+), 41 deletions(-)

M TODO
M commands.go
M config.go
M main.go
M TODO => TODO +3 -3
@@ 16,7 16,7 @@ Features:

* verify proper permissions -rw------- 0600 for discord.cfg

* if ``` entered, allow multi-line message (composition)
* [done] if ``` entered, allow multi-line message (composition)

* flag for larger backlog loading



@@ 25,7 25,7 @@ Features:
* [done-ish] fix pm's
	* when opening a pm, drops back to channel dialogue

* aux/statusmsg backgrounds and doesn't steal input
* [done] aux/statusmsg backgrounds and doesn't steal input

* fix :m not displaying more than loaded backlog



@@ 33,5 33,5 @@ Features:

* add [b] go back to pm's menu from within pm's

* fix :n printing to chat
* [done] fix :n printing to chat


M commands.go => commands.go +4 -2
@@ 80,7 80,7 @@ func ParseForCommands(line string) string {
		Msg(InfoMsg, "Printing last %d messages!\n", Amount)
		State.RetrieveMessages(Amount)
		PrintMessages(Amount)
		return line
		return ""
	case ":u":
		session := State.Session
		user := session.User


@@ 88,8 88,10 @@ func ParseForCommands(line string) string {
		_, err := State.Session.DiscordGo.UserUpdate(user.Email, session.Password, newName, user.Avatar, "")
		if err != nil {
			Msg(ErrorMsg, "[:u] Argument Error: %s\n", err)
			return ""
		}
		return line
		Msg(TextMsg, "name -> %s\n", newName)
		return ""
	}	
	return line
}

M config.go => config.go +6 -33
@@ 8,16 8,17 @@ import (
	"os"
	"os/user"
	//	"golang.org/x/crypto/ssh/terminal"
	"bitbucket.org/mischief/libauth"
)

//Configuration is a struct that contains all configuration fields
type Configuration struct {
	Username       string `json:"username"`
	Password       string `json:"password"`
	MessageDefault bool   `json:"messagedefault"`
	Messages       int    `json:"messages"`
	CompletionChar string `json:"completionchar"`
	TimeCompChar   string `json:"timecompchar"`
	password       string
}

// Config is the global configuration of discord-cli


@@ 64,34 65,6 @@ func CreateConfig() {
	scan.Scan()

	EmptyStruct.Username = scan.Text()
	fmt.Print("Input your password: ")
	//password, err := terminal.ReadPassword(0)

	plan9 := true
	/* Plan 9 raw mode for rio */
	consctl, err := Rawon()
	if err != nil {
		fmt.Println("Failed to set rawon")
		plan9 = false
	}

	password := ""

	if plan9 {

		password = GetCons()

		err = RawOff(consctl)
		if err != nil {
			fmt.Println("\nFailed to set rawoff")
			fmt.Print(err, "\n")
		}
	} else {
		/* Maybe put linux terminal raw mode in here one day */
		fmt.Println("Skipping raw input for Plan 9")
	}

	EmptyStruct.Password = string(password)
	EmptyStruct.Messages = 10
	EmptyStruct.MessageDefault = true
	EmptyStruct.CompletionChar = ">"


@@ 131,9 104,9 @@ func CheckState() {
	if Config.Username == "" {
		log.Fatalln("No Username Specified, please edit " + usr.HomeDir + "/lib/disco.cfg")
	}

	if Config.Password == "" {
		log.Fatalln("No Password Specified, please edit " + usr.HomeDir + "/lib/disco.cfg")
	userPwd, err := libauth.Getuserpasswd("proto=pass service=discord user=%s server=discordapp.com", Config.Username)
	if err != nil {
		log.Fatal(err)
	}

	Config.password = userPwd.Password
}

M main.go => main.go +11 -3
@@ 7,6 7,7 @@ import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"log"
	"os"
	"regexp"


@@ 55,7 56,7 @@ func main() {
	Msg(HeaderMsg, "disco version: %s\n\n", Version)

	//NewSession
	Session = DiscordState.NewSession(Config.Username, Config.Password) //Please don't abuse
	Session = DiscordState.NewSession(Config.Username, Config.password) //Please don't abuse
	err := Session.Start()
	if err != nil {
		log.Println("Session Failed")


@@ 77,7 78,11 @@ func main() {
	for {
		//fmt.Print("> ")
		//line, _ := rl.Readline()
		line, _ := reader.ReadString('\n')
		line, err := reader.ReadString('\n')
		
		if err == io.EOF {
			break
		}

		// ```
		if strings.HasPrefix(line, "```") {


@@ 95,7 100,10 @@ func main() {
			continue
		}

		line = line[:len(line)-1]
		n := len(line)
		if n > 0 {
			line = line[:n-1]
		}

		//QUIT
		if line == ":q" {