kahoot-hack: github.com/unixpickle/kahoot-hack/kahoot Index | Files

package kahoot

import "github.com/unixpickle/kahoot-hack/kahoot"


Package Files

conn.go eval.go info.go quiz.go sessions.go


var ErrConnClosed = errors.New("connection closed")
var ErrNotSubscribed = errors.New("not subscribed to channel")

func AccessToken Uses

func AccessToken(email, password string) (string, error)

AccessToken returns an access token from the kahoot rest api.

type Conn Uses

type Conn struct {
    // contains filtered or unexported fields

func NewConn Uses

func NewConn(gameId string) (*Conn, error)

NewConn connects to the kahoot server and performs a handshake using a given game pin.

func (*Conn) Close Uses

func (c *Conn) Close()

Close terminates the connection, waiting synchronously for the incoming channels to close.

func (*Conn) GracefulClose Uses

func (c *Conn) GracefulClose()

GracefulClose closes the connection gracefully, telling the other end that we are disconnecting.

func (*Conn) Login Uses

func (c *Conn) Login(nickname string) error

Login tells the server our nickname.

func (*Conn) Receive Uses

func (c *Conn) Receive(channel string) (Message, error)

Receive returns the next message on a given channel. You must Subscribe() to the channel before Receiving on it.

func (*Conn) Send Uses

func (c *Conn) Send(channel string, m Message) error

Send transmits a message to the server over a channel.

func (*Conn) Subscribe Uses

func (c *Conn) Subscribe(name string) error

Subscribe tells the server that we wish to receive messages on a given channel.

type Message Uses

type Message map[string]interface{}

type Quiz Uses

type Quiz struct {
    // contains filtered or unexported fields

func NewQuiz Uses

func NewQuiz(c *Conn) *Quiz

func (*Quiz) Receive Uses

func (q *Quiz) Receive() (*QuizAction, error)

Receive receives the next QuizAction. This may be a QuestionIntro, indicating a new question is starting, or QuestionAnswers, indicating that the user may now submit an answer.

func (*Quiz) Send Uses

func (q *Quiz) Send(index int) error

Send responds to a server's QuestionAnswers action with an answer index.

type QuizAction Uses

type QuizAction struct {
    Type       QuizActionType
    NumAnswers int
    Index      int
    AnswerMap  map[int]int

type QuizActionType Uses

type QuizActionType int
const (
    QuestionIntro QuizActionType = iota

type QuizChoice Uses

type QuizChoice struct {
    Answer  string `json:"answer"`
    Correct bool   `json:"correct"`

QuizChoice represents a possible answer for a QuizQuestion.

type QuizInfo Uses

type QuizInfo struct {
    Uuid                string         `json:"uuid"`
    QuizType            string         `json:"quizType"`
    Cover               string         `json:"cover"`
    Modified            int64          `json:"modified"`
    Creator             string         `json:"creator"`
    Audience            string         `json:"audience"`
    Title               string         `json:"title"`
    Description         string         `json:"description"`
    Type                string         `json:"type"`
    Created             int64          `json:"created"`
    Language            string         `json:"language"`
    CreatorPrimaryUsage string         `json:"creator_primary_usage"`
    Questions           []QuizQuestion `json:"questions"`
    Image               string         `json:"image"`
    Video               QuizVideo      `json:"video"`
    Metadata            QuizMetadata   `json:"metadata"`
    Resources           string         `json:"resources"`
    CreatorUsername     string         `json:"creator_username"`
    Visibility          int64          `json:"visibility"`

QuizInfo stores information about a quiz, including the correct answers.

func QuizInformation Uses

func QuizInformation(token, quizid string) (*QuizInfo, error)

QuizInformation returns all quiz information for a specific kahoot id.

type QuizMetadata Uses

type QuizMetadata struct {
    Resolution string         `json:"resolution"`
    Moderation QuizModeration `json:"moderation"`

QuizMetadata stores metadata about a quiz.

type QuizModeration Uses

type QuizModeration struct {
    FlaggedTimestamp    float64 `json:"flaggedTimestamp"`
    TimestampResolution float64 `json:"timestampResolution"`
    Resolution          string  `json:"resolution"`

QuizModeration stores moderator information for a quiz.

type QuizQuestion Uses

type QuizQuestion struct {
    NumberOfAnswers int          `json:"numberOfAnswers"`
    Image           string       `json:"image"`
    Video           QuizVideo    `json:"video"`
    Question        string       `json:"question"`
    QuestionFormat  int          `json:"questionFormat"`
    Time            int          `json:"time"`
    Points          bool         `json:"points"`
    Choices         []QuizChoice `json:"choices"`
    Resources       string       `json:"resources"`
    Type            string       `json:"type"`

QuizQuestion is a question in a quiz.

type QuizVideo Uses

type QuizVideo struct {
    FullUrl   string  `json:"fullUrl"`
    Id        string  `json:"id"`
    StartTime float64 `json:"startTime"`
    EndTime   float64 `json:"endTime"`
    Service   string  `json:"service"`

QuizVideo is an optional video for a QuizQuestion.

Package kahoot imports 15 packages (graph) and is imported by 13 packages. Updated 2019-04-10. Refresh now. Tools for package owners.