Categorygithub.com/alaingilbert/ttapi
modulepackage
0.0.0-20240820075349-0161a9a84ab4
Repository: https://github.com/alaingilbert/ttapi.git
Documentation: pkg.go.dev

# README

Turntable API


Join us on Discord https://discord.gg/4AA2DqWpVc


A simple go wrapper for the turntable API.
You'll need to find your AUTH, USERID and ROOMID information with this bookmarklet.

Installation

go get github.com/alaingilbert/ttapi

Examples

Chat bot

This bot responds to anybody who writes "/hello" in the chat.

package main

import (
    "os"
    "github.com/alaingilbert/ttapi"
)

func main() {
    auth := os.Getenv("TTAPI_AUTH")
    userID := os.Getenv("TTAPI_USER_ID")
    roomID := os.Getenv("TTAPI_ROOM_ID")
    bot := ttapi.NewBot(auth, userID, roomID)
    bot.OnSpeak(func(evt ttapi.SpeakEvt) {
        if evt.Text == "/hello" {
            _ = bot.Speakf("Hey! How are you @%s ?", evt.Name)
        }
    })
    bot.Start()
}

More examples here -> https://github.com/alaingilbert/ttapi/tree/master/examples

Debugging

Add the following line in your main function

logrus.SetLevel(logrus.DebugLevel)

That will print on the terminal all the data that you get and all the data that you send.

# Packages

No description provided by the author

# Functions

GenerateToken generate a random 32 bytes hex token.
NewBot creates a new bot.
Or return "a" if it is non-zero otherwise "b".
SGo stands for Safe Go or Shit Go depending how you feel about goroutine panic handling Basically just a wrapper around the built-in keyword "go" with crash recovery.
Sha1 returns sha1 hex sum as a string.
Ternary ...

# Structs

AddDJEvt ...
BaseRes ...
BootedUserEvt ...
Bot is a thread safe client for turntable \o/ To get the auth, user id and room id, you can use the following bookmarklet http://alaingilbert.github.io/Turntable-API/bookmarklet.html.
DeregisteredEvt ...
DirectoryGraphRes ...
DjEvt ...
No description provided by the author
GetFanOfRes ...
GetFansRes ...
GetFavoritesRes ...
GetPresenceRes ...
GetProfileRes ...
GetUserIDRes ...
No description provided by the author
NewModeratorEvt ..
NewSongEvt ...
NoSongEvt ...
PlaylistAllRes ...
PlaylistListAllRes ...
PmmedEvt ...
RegisteredEvt ...
RemDJEvt ...
RemModeratorEvt ..
RoomInfoRes ...
RxMsg ...
Search store any searches currently in progress.
SearchRes ...
SnaggedEvt ...
SpeakEvt struct received when someone speak in the public chat.
TxMsg ...
UnackMsg store information about a message we sent that is not ack yet.
UpdateVotesEvt ..
UserAvailableAvatarsRes ...
UserInfoRes ...

# Interfaces

IBaseRes ...
IBot ...

# Type aliases

H is a hashmap.