GithubHelp home page GithubHelp logo

dogegarden / dogehousego Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 68 KB

A wrapper for DogeHouse made in Go

Home Page: https://wiki.dogegarden.net

License: Mozilla Public License 2.0

Go 100.00%
golang dogehouse wrapper

dogehousego's Introduction

DogeGarden logo

A wrapper for DogeHouse made in Go 馃挩

discord - users online


Need help or support?
Join our Discord.

Done:

  • Websocket connection
  • Api key authentication
  • Event subscription
  • Query ws events
  • About 50% of mutations

TODO:

  • The rest of mutations
  • Whole audio module
  • Docs

Example usage:

package main

import (
	"fmt"
	"github.com/dogegarden/dogehousego"
)

func main() {
	retval, err := dogehousego.Auth("your-api-key")
	if err != nil {
		fmt.Println(err.Error())
		return;
	}

	con := dogehousego.Connection{
		AccessToken:  retval.AccessToken,
		RefreshToken: retval.RefreshToken,
	}

	con.OnNewChatMessage(func(event dogehousego.OnNewMessageEvent, err error) {
		if err != nil {
			fmt.Println("New chat message error! " + err.Error());
			return;
		}

		message := dogehousego.TokensToString(event.Msg.Tokens)

		fmt.Println(message)
	});

	con.OnReady(func(event dogehousego.OnReadyEvent, err error) {

		if err != nil {
			fmt.Println("Error while logging in!: " + err.Error())
		}

		fmt.Println("Logged in as: " + event.User.Username)
		rooms, err := con.GetTopPublicRooms(0)
		if err != nil {
			fmt.Println(err.Error())
			return
		}

		info, err := con.JoinRoomAndGetInfo(rooms.Rooms[0].Id)

		if err != nil {
			fmt.Println("Error while joining the room! " + err.Error())
			return
		}

		fmt.Printf("Joined room: %s | User count: %d\n", info.Room.Name, len(info.Users));
	});

	fmt.Println(con.Start())
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google 鉂わ笍 Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.