Basic provisioning api

Includes: login, logout, and ping.
This commit is contained in:
Gary Kramlich
2022-02-21 06:49:44 -06:00
parent a51b1074ba
commit d883befee5
10 changed files with 429 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package bridge
import (
"errors"
"fmt"
"strings"
"github.com/bwmarrin/discordgo"
@@ -184,6 +185,10 @@ func (u *User) uploadQRCode(code string) (id.ContentURI, error) {
}
func (u *User) Login(token string) error {
if token == "" {
return fmt.Errorf("No token specified")
}
err := u.User.NewSession(token)
if err != nil {
return err
@@ -192,6 +197,10 @@ func (u *User) Login(token string) error {
return u.Connect()
}
func (u *User) LoggedIn() bool {
return u.Session != nil
}
func (u *User) Connect() error {
u.log.Debugln("connecting to discord")