bot

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 20 Imported by: 0

README

Big Blue Button Bot Prototype

Overview

This project serves as a prototype for a bot designed specifically for Big Blue Button. The primary objective is to develop a highly performant bot that interfaces with the backend APIs of Big Blue Button without the need to initiate a headless browser.

The bot aims to utilize all the functionalities that a regular Big Blue Button user can access. If possible, the code should be written using Go (Golang).

Prerequisites

Node.js
Installation:

Windows:

  1. Visit the official Node.js download page.
  2. Download the Windows Installer.
  3. Run the installer and follow the on-screen instructions.

Linux:

  1. Open your terminal.
  2. Use Node Version Manager to install Node.js:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
    nvm install node
    

macOS:

  1. Visit the official Node.js download page.
  2. Download the macOS Installer.
  3. Run the installer and follow the on-screen instructions.
Go (Golang)
Installation:

Windows:

  1. Visit the official Go download page.
  2. Download the Windows Installer.
  3. Run the installer and follow the on-screen instructions.

Linux:

  1. Open your terminal.
  2. Use the following commands to download and install Go:
    wget https://dl.google.com/go/go1.xx.x.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go1.xx.x.linux-amd64.tar.gz
    

Replace 1.xx.x with the latest version number. You can find the latest version number on the official Go download page.

  1. Add Go to your PATH:
    echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
    source ~/.bashrc
    

macOS:

  1. Visit the official Go download page.
  2. Download the macOS Installer.
  3. Run the installer and follow the on-screen instructions.
Configuration

Create a config.json file and insert the following configuration:

{
    "bbb": {
        "api": {
            "url": "https://example.com/bigbluebutton/api/",
            "secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "sha": "SHA256"
        },
        "client": {
            "url": "https://example.com/html5client/",
            "ws": "wss://example.com/html5client/websocket"
        },
        "pad": {
            "url": "https://example.com/pad/",
            "ws": "wss://example.com/pad/"
        },
        "webrtc": {
            "ws": "wss://example.com/bbb-webrtc-sfu"
        }
    }
}

To retrieve the Big Blue Button secret/salt, execute the following command on the Big Blue Button server: bbb-conf --secret. For more details, refer to the official documentation.

Setup and Execution
  1. Copy the example.go file from the _example directory.
  2. Execute the following commands:
    go mod init bbb-bot
    go mod tidy
    go run .
    

Upon execution, the bot will create a new meeting room and join it. It will then initiate an English capture and write "Hello World" into it. Additionally, the bot will respond to messages sent in the main chat. For instance, if "ping" is written, the bot will reply with "pong".

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractChannelsFromSDP

func ExtractChannelsFromSDP(sdpStr string) (uint16, error)

func ExtractClockRateFromSDP

func ExtractClockRateFromSDP(sdpStr string) (uint32, error)

func ExtractFmtpFromSDP

func ExtractFmtpFromSDP(sdpStr string) (string, error)

func ExtractRTCPFeedbackFromSDP

func ExtractRTCPFeedbackFromSDP(sdpStr string) ([]webrtc.RTCPFeedback, error)

Types

type AudioClient

type AudioClient struct {
	Client
	// contains filtered or unexported fields
}

func (*AudioClient) Close

func (c *AudioClient) Close() error

func (*AudioClient) GetStunTurnServers

func (c *AudioClient) GetStunTurnServers() ([]stunServers, []turnServers, error)

GetStunTurnServers returns the STUN and TURN servers of the bbb server.

func (*AudioClient) ListenToAudio

func (c *AudioClient) ListenToAudio() error

ListenToAudio joins the audio channel of the meeting and starts listening to the audio stream.

func (*AudioClient) OnTrack

func (c *AudioClient) OnTrack(onfunc func(*StatusType, *webrtc.TrackRemote, *webrtc.RTPReceiver)) error

type Client

type Client struct {
	// Status is the current connection status of the client
	Status StatusType

	// BBB-urls the client is connected to
	ClientURL   string
	ClientWSURL string
	PadURL      string
	PadWSURL    string
	WebRTCWSURL string
	// to make api requests to the BBB-server
	API *api.ApiRequest

	// after join there are the following informations
	JoinURL           string
	SessionCookie     []*http.Cookie
	InternalUserID    string
	UserName          string
	AuthToken         string
	SessionToken      string
	ExternalMeetingID string
	InternalMeetingID string
	// contains filtered or unexported fields
}

Client represents a BigBlueButton client connection. The BigBlueButton client establish a BigBlueButton session and acts as a message pump for other tools.

func NewClient

func NewClient(clientURL string, clientWSURL string, padURL string, padWSURL string, apiURL string, apiSecret string, webRTCWSURL string) (*Client, error)

func (*Client) CreateAudioChannel

func (c *Client) CreateAudioChannel() *AudioClient

func (*Client) CreateCapture

func (c *Client) CreateCapture(language string, external bool, host string, port int) (*pad.Pad, error)

func (*Client) Join

func (c *Client) Join(meetingID string, userName string, moderator bool) error

Join a meeting

func (*Client) Leave

func (c *Client) Leave() error

Leave the joined meeting

func (*Client) OnCapture

func (c *Client) OnCapture(language string, listener captureListener) error

OnCapture in order to receive Capture changes.

func (*Client) OnGroupChatMsg

func (c *Client) OnGroupChatMsg(listener groupChatMsgListener) error

OnGroupChatMsg in order to receive GroupChatMsg changes.

func (*Client) OnStatus

func (c *Client) OnStatus(listener statusListener)

OnStatus in order to receive status changes.

func (*Client) SendChatMsg

func (c *Client) SendChatMsg(message string, chatId string) error

type StatusType

type StatusType string
const (
	DISCONNECTING StatusType = "disconnecting"
	DISCONNECTED  StatusType = "disconnected"
	CONNECTING    StatusType = "connecting"
	CONNECTED     StatusType = "connected"
	RECONNECTING  StatusType = "reconnecting"
)

Directories

Path Synopsis
pad

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL