From 2c3ca777f9a7cafe05b2f7157798a80359c5bd22 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Mon, 9 Nov 2015 14:22:36 -0600 Subject: [PATCH] Clean up, notes --- discord.go | 3 ++- session.go | 16 +++++++++++----- structs.go | 2 ++ users.go | 2 ++ util.go | 4 ++++ wsapi.go | 2 +- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/discord.go b/discord.go index 4521e0d..3d1c29f 100644 --- a/discord.go +++ b/discord.go @@ -18,7 +18,7 @@ const ( servers = discordApi + "guilds" channels = discordApi + "channels" users = discordApi + "users" -) +) // TODO: make this do something, better names, move to restapi.go // A Discord structure represents a all-inclusive (hopefully) structure to // access the Discord REST API for a given authenticated user. @@ -31,6 +31,7 @@ type Discord struct { // New creates a new connection to Discord and returns a Discord structure. // This provides an easy entry where most commonly needed information is // automatically fetched. +// TODO add websocket code in here too func New(email string, password string) (d *Discord, err error) { session := Session{} diff --git a/session.go b/session.go index 0ab0d36..768a3de 100644 --- a/session.go +++ b/session.go @@ -10,14 +10,20 @@ import "github.com/gorilla/websocket" // Token : The authentication token returned from Discord // Debug : If set to ture debug logging will be displayed. type Session struct { - Token string - Gateway string - Debug bool - Websocket *websocket.Conn + Token string // Authentication token for this session + Gateway string // Websocket Gateway for this session + Debug bool // Debug for printing JSON request/responses + Cache int // number in X to cache some responses + Websocket *websocket.Conn // TODO: use this + //TODO, add bools for like. + // are we connnected to websocket? + // have we authenticated to login? + // lets put all the general session + // tracking and infos here.. clearly } /****************************************************************************** - * The below functions are "shortcut" methods for functions in client.go + * The below functions are "shortcut" methods for functions in restapi.go * Reference the client.go file for more documentation. */ func (session *Session) Login(email string, password string) (token string, err error) { diff --git a/structs.go b/structs.go index 7debc71..527d0c7 100644 --- a/structs.go +++ b/structs.go @@ -1,5 +1,7 @@ package discordgo +// TODO: Eventually everything here gets moved to a better place. + type Message struct { Id int `json:"id,string"` Author User `json:"author"` diff --git a/users.go b/users.go index ca4ced9..cab8a8c 100644 --- a/users.go +++ b/users.go @@ -15,3 +15,5 @@ type PrivateChannel struct { LastMessageId int `json:"last_message_id,string"` Recipient User `json:"recipient"` } + +// PM function to PM a user. diff --git a/util.go b/util.go index 4338606..149ac61 100644 --- a/util.go +++ b/util.go @@ -1,3 +1,6 @@ +// this file has small funcs used without the pacakge +// or, one.. util, maybe I'll have more later :) + package discordgo import ( @@ -6,6 +9,7 @@ import ( "fmt" ) +// convert to return as string func printJSON(body []byte) { var prettyJSON bytes.Buffer error := json.Indent(&prettyJSON, body, "", "\t") diff --git a/wsapi.go b/wsapi.go index f93d47c..d0657ad 100644 --- a/wsapi.go +++ b/wsapi.go @@ -2,7 +2,7 @@ * A Discord API for Golang. * See discord.go for more information. * - * This file contains functions low level functions for interacting + * This file contains low level functions for interacting * with the Discord Websocket interface. */