All Projects → gempir → Go Twitch Irc

gempir / Go Twitch Irc

Licence: mit
go irc client for twitch.tv

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Twitch Irc

Irslackd
Self-hosted IRC gateway to Slack
Stars: ✭ 128 (-17.42%)
Mutual labels:  hacktoberfest, irc, irc-client
TwitchPy
This is a package you can use to connect with the Twitch API, manage a channel, create bots, etc
Stars: ✭ 22 (-85.81%)
Mutual labels:  twitch, irc, irc-client
Kittehircclientlib
An IRC client library in Java
Stars: ✭ 116 (-25.16%)
Mutual labels:  hacktoberfest, irc, irc-client
Thelounge
💬 ‎ Modern, responsive, cross-platform, self-hosted web IRC client
Stars: ✭ 4,618 (+2879.35%)
Mutual labels:  hacktoberfest, irc, irc-client
Java Twirk
Small, basic library for communication via the Twitch chat. Java 8 compatible
Stars: ✭ 36 (-76.77%)
Mutual labels:  twitch, irc
Sopel
🤖💬 An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
Stars: ✭ 894 (+476.77%)
Mutual labels:  hacktoberfest, irc
Girc
💣 girc is a flexible IRC library for Go 👌
Stars: ✭ 59 (-61.94%)
Mutual labels:  irc, irc-client
Irc
A simple go irc library meant to be a building block for other projects
Stars: ✭ 90 (-41.94%)
Mutual labels:  irc, irc-client
Kiwiirc
🥝 Next generation of the Kiwi IRC web client
Stars: ✭ 488 (+214.84%)
Mutual labels:  irc, irc-client
Twitchirc Unity
lightweight IRC client component for use with the Unity Engine.
Stars: ✭ 81 (-47.74%)
Mutual labels:  twitch, irc
Trains.net
A simple 2D game written in C# with .NET Core. Development is streamed live on https://twitch.tv/davidwengier and past streams available on YouTube at http://bit.ly/trains-net-videos
Stars: ✭ 92 (-40.65%)
Mutual labels:  hacktoberfest, twitch
Convos
Convos 👥 is the simplest way to use IRC in your browser
Stars: ✭ 789 (+409.03%)
Mutual labels:  irc, irc-client
Dispatch
Web-based IRC client in Go.
Stars: ✭ 595 (+283.87%)
Mutual labels:  irc, irc-client
Alectro
A terminal IRC client in Rust.
Stars: ✭ 47 (-69.68%)
Mutual labels:  irc, irc-client
Quassel
Quassel IRC: Chat comfortably. Everywhere.
Stars: ✭ 589 (+280%)
Mutual labels:  irc, irc-client
Localslackirc
IRC gateway for slack, running on localhost for one user
Stars: ✭ 84 (-45.81%)
Mutual labels:  irc, irc-client
Twitch Bot
🤖 Easily create chat bots for Twitch.tv
Stars: ✭ 111 (-28.39%)
Mutual labels:  twitch, irc
Rirc
A terminal IRC client in C
Stars: ✭ 115 (-25.81%)
Mutual labels:  irc, irc-client
Kirc
A tiny IRC client written in POSIX C99.
Stars: ✭ 416 (+168.39%)
Mutual labels:  irc, irc-client
Lax
IRC client built with Electron & React
Stars: ✭ 95 (-38.71%)
Mutual labels:  hacktoberfest, irc

go-twitch-irc Coverage Status

This is an irc client for connecting to twitch. It handles the annoying stuff like irc tag parsing. I highly recommend reading the documentation below, but this readme gives a basic overview of the functionality.

Documentation: https://pkg.go.dev/github.com/gempir/go-twitch-irc/v2?tab=doc

Getting Started

package main

import (
	"fmt"

	"github.com/gempir/go-twitch-irc/v2"
)

func main() {
	// or client := twitch.NewAnonymousClient() for an anonymous user (no write capabilities)
	client := twitch.NewClient("yourtwitchusername", "oauth:123123123")

	client.OnPrivateMessage(func(message twitch.PrivateMessage) {
		fmt.Println(message.Message)
	})

	client.Join("gempir")

	err := client.Connect()
	if err != nil {
		panic(err)
	}
}

Available Data

The twitch.User and MessageType structs reflect the data Twitch provides, minus any fields that have been marked as deprecated:

type User struct {
	ID          string
	Name        string
	DisplayName string
	Color       string
	Badges      map[string]int
}

type WhisperMessage struct {
	User User

	Raw       string
	Type      MessageType
	RawType   string
	Tags      map[string]string
	Message   string
	Target    string
	MessageID string
	ThreadID  string
	Emotes    []*Emote
	Action    bool
}

type PrivateMessage struct {
	User User

	Raw     string
	Type    MessageType
	RawType string
	Tags    map[string]string
	Message string
	Channel string
	RoomID  string
	ID      string
	Time    time.Time
	Emotes  []*Emote
	Bits    int
	Action  bool
}

type ClearChatMessage struct {
	Raw            string
	Type           MessageType
	RawType        string
	Tags           map[string]string
	Message        string
	Channel        string
	RoomID         string
	Time           time.Time
	BanDuration    int
	TargetUserID   string
	TargetUsername string
}

type ClearMessage struct {
	Raw         string
	Type        MessageType
	RawType     string
	Tags        map[string]string
	Message     string
	Channel     string
	Login       string
	TargetMsgID string
}

type RoomStateMessage struct {
	Raw     string
	Type    MessageType
	RawType string
	Tags    map[string]string
	Message string
	Channel string
	RoomID  string
	State   map[string]int
}

type UserNoticeMessage struct {
	User User

	Raw       string
	Type      MessageType
	RawType   string
	Tags      map[string]string
	Message   string
	Channel   string
	RoomID    string
	ID        string
	Time      time.Time
	Emotes    []*Emote
	MsgID     string
	MsgParams map[string]string
	SystemMsg string
}

type UserStateMessage struct {
	User User

	Raw       string
	Type      MessageType
	RawType   string
	Tags      map[string]string
	Message   string
	Channel   string
	EmoteSets []string
}

type GlobalUserStateMessage struct {
	User User

	Raw       string
	Type      MessageType
	RawType   string
	Tags      map[string]string
	EmoteSets []string
}

type NoticeMessage struct {
	Raw     string
	Type    MessageType
	RawType string
	Tags    map[string]string
	Message string
	Channel string
	MsgID   string
}

type UserJoinMessage struct {
	// Channel name
	Channel string

	// User name
	User string
}

type UserPartMessage struct {
	// Channel name
	Channel string

	// User name
	User string
}

For unsupported message types, we return RawMessage:

type RawMessage struct {
	Raw     string
	Type    MessageType
	RawType string
	Tags    map[string]string
	Message string
}

Available Methods

ParseMessage parses a raw Twitch IRC message into a User and a message object. User can be nil.

func ParseMessage(line string) (*User, interface{})

Client Methods

These are the available methods of the client so you can get your bot going:

func (c *Client) Say(channel, text string)
func (c *Client) Whisper(username, text string)
func (c *Client) Join(channel string)
func (c *Client) Depart(channel string)
func (c *Client) Userlist(channel string) ([]string, error)
func (c *Client) Connect() error
func (c *Client) Disconnect() error

Options

On your client you can configure multiple options:

client.IrcAddress = "127.0.0.1:3030" // for custom irc server
client.TLS = false // enabled by default, will connect to non TLS server of twitch when off or the given client.IrcAddress
client.SetupCmd = "LOGIN custom_command_here" // Send a custom command on successful IRC connection, before authentication.
client.Capabilities = []string{twitch.TagsCapability, twitch.CommandsCapability} // Customize which capabilities are sent

Option modifications must be done before calling Connect on the client.

Capabilities

By default, the client sends along all 3 Twitch capabilities (Tags, Commands, Membership).

Callbacks

These callbacks are available to pass to the client:

client.OnConnect(func() {})
client.OnPrivateMessage(func(message PrivateMessage) {})
client.OnWhisperMessage(func(message WhisperMessage) {})
client.OnClearChatMessage(func(message ClearChatMessage) {})
client.OnClearMessage(func(message ClearMessage) {})
client.OnRoomStateMessage(func(message RoomStateMessage) {})
client.OnUserNoticeMessage(func(message UserNoticeMessage) {})
client.OnUserStateMessage(func(message UserStateMessage) {})
client.OnGlobalUserStateMessage(func(message GlobalUserStateMessage) {})
client.OnNoticeMessage(func(message NoticeMessage) {})
client.OnUserJoinMessage(func(message UserJoinMessage) {})
client.OnUserPartMessage(func(message UserPartMessage) {})

Message Types

If you ever need more than basic PRIVMSG, this might be for you. These are the message types currently supported:

WHISPER
PRIVMSG
CLEARCHAT
CLEARMSG
ROOMSTATE
USERNOTICE
USERSTATE
GLOBALUSERSTATE
NOTICE
JOIN
PART
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].