Clean up, notes

This commit is contained in:
Bruce Marriner 2015-11-09 14:22:36 -06:00
parent 778a62b747
commit 2c3ca777f9
6 changed files with 22 additions and 7 deletions

View file

@ -18,7 +18,7 @@ const (
servers = discordApi + "guilds" servers = discordApi + "guilds"
channels = discordApi + "channels" channels = discordApi + "channels"
users = discordApi + "users" users = discordApi + "users"
) ) // TODO: make this do something, better names, move to restapi.go
// A Discord structure represents a all-inclusive (hopefully) structure to // A Discord structure represents a all-inclusive (hopefully) structure to
// access the Discord REST API for a given authenticated user. // 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. // New creates a new connection to Discord and returns a Discord structure.
// This provides an easy entry where most commonly needed information is // This provides an easy entry where most commonly needed information is
// automatically fetched. // automatically fetched.
// TODO add websocket code in here too
func New(email string, password string) (d *Discord, err error) { func New(email string, password string) (d *Discord, err error) {
session := Session{} session := Session{}

View file

@ -10,14 +10,20 @@ import "github.com/gorilla/websocket"
// Token : The authentication token returned from Discord // Token : The authentication token returned from Discord
// Debug : If set to ture debug logging will be displayed. // Debug : If set to ture debug logging will be displayed.
type Session struct { type Session struct {
Token string Token string // Authentication token for this session
Gateway string Gateway string // Websocket Gateway for this session
Debug bool Debug bool // Debug for printing JSON request/responses
Websocket *websocket.Conn 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. * Reference the client.go file for more documentation.
*/ */
func (session *Session) Login(email string, password string) (token string, err error) { func (session *Session) Login(email string, password string) (token string, err error) {

View file

@ -1,5 +1,7 @@
package discordgo package discordgo
// TODO: Eventually everything here gets moved to a better place.
type Message struct { type Message struct {
Id int `json:"id,string"` Id int `json:"id,string"`
Author User `json:"author"` Author User `json:"author"`

View file

@ -15,3 +15,5 @@ type PrivateChannel struct {
LastMessageId int `json:"last_message_id,string"` LastMessageId int `json:"last_message_id,string"`
Recipient User `json:"recipient"` Recipient User `json:"recipient"`
} }
// PM function to PM a user.

View file

@ -1,3 +1,6 @@
// this file has small funcs used without the pacakge
// or, one.. util, maybe I'll have more later :)
package discordgo package discordgo
import ( import (
@ -6,6 +9,7 @@ import (
"fmt" "fmt"
) )
// convert to return as string
func printJSON(body []byte) { func printJSON(body []byte) {
var prettyJSON bytes.Buffer var prettyJSON bytes.Buffer
error := json.Indent(&prettyJSON, body, "", "\t") error := json.Indent(&prettyJSON, body, "", "\t")

View file

@ -2,7 +2,7 @@
* A Discord API for Golang. * A Discord API for Golang.
* See discord.go for more information. * 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. * with the Discord Websocket interface.
*/ */