twitchircgo

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 8 Imported by: 0

README

Go Twitch IRC Client

This repository contains a Go client for interacting with Twitch IRC channels.

Example

main.go contains the following example which will receive each message in my channel (supcole) and log information about it and the user who sent it to the console. To be able to run this, you must have Twitch API credentials.


chatToken := refreshAuth("refresh token goes here","client id goes here", "client secret goes here")

bot := newBot(chatToken, "#supcole", "supcole")
bot.Connect()

for {
    message := <-bot.onMessage["default"]
    fmt.Printf("got message %+v\n",message)
}


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Badge

type Badge struct {
	Name  string
	Value string
}

Badge represents badges sent in twitch chat

type Bot

type Bot struct {

	// oauth token containing chat:read and chat:write scopes
	AuthToken string
	// Event listeners
	OnMessage chan *Message
	// contains filtered or unexported fields
}

The Bot object which stores irc info

func NewBot

func NewBot(token string, channels []string, nick string) *Bot

NewBot is a Bot constructor

func (*Bot) Connect

func (bot *Bot) Connect()

Connect and connect bot to IRC server

func (*Bot) Message

func (bot *Bot) Message(channel string, message string)

Message to IRC channel

func (*Bot) ReadLoop

func (bot *Bot) ReadLoop()

ReadLoop for Bot

type Message

type Message struct {
	Channel  string
	User     User
	Contents string
}

Message represents message received

type User

type User struct {
	// Username of sender
	Username string
	// Moderator is true if sender is a Moderator
	Moderator bool
	// Badges contains user's badges
	Badges []Badge
	// ID represents the unique user id (static where username can change)
	ID string
	// Color represents the user's chosen chat color
	Color string
	// Subscriber represents whether user is subbed to channel
	Subscriber bool
	// Turbo represents whether user is a Turbo user
	Turbo bool
	// Owner represents whether user is the owner of the channel, owners are NOT moderators
	Owner bool
}

User represents user sending message

Jump to

Keyboard shortcuts

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