twitchbot

package module
v0.0.0-...-5271b62 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 11 Imported by: 0

README

TwitchBot

The twitchbot package provides a set of functions that control a basic Twitch.tv chat bot. The package also exposes an interface which can be used to create a custom chat bot.

Installation

Run go get github.com/Furkan9015/twitchbot

Importing

Import this package by including github.com/Furkan9015/twitchbot in your import block.

e.g.

package main

import(
    ...
    "github.com/Furkan9015/twitchbot"
)

Usage

Basic usage:

package main

import (
	"github.com/Furkan9015/twitchbot"
	"time"
)

func main() {

	// Replace the channel name, bot name, and the path to the private directory with your respective
	// values.
	myBot := twitchbot.BasicBot{
		Channel:     "twitch",
		MsgRate:     time.Duration(20/30) * time.Millisecond,
		Name:        "TwitchBot",
		Port:        "6667",
		PrivatePath: "../private/oauth.json",
		Server:      "irc.chat.twitch.tv",
	}
	myBot.Start()
}

That's all, enjoy!

Documentation

Overview

The twitchbot package provides a set of functions that control a basic Twitch.tv chat bot. The package also exposes an interface which can be used to create a custom chat bot.

Basic usage:

``` package main

import (

"github.com/Furkan9015/twitchbot"
"time"

)

func main() {

	// Replace the channel name, bot name, and the path to the private directory with your respective
	// values.
	myBot := twitchbot.BasicBot{
		Channel:     "twitch",
		MsgRate:     time.Duration(20/30) * time.Millisecond,
		Name:        "TwitchBot",
		Port:        "6667",
		PrivatePath: "../private/oauth.json",
		Server:      "irc.chat.twitch.tv",
	}
	myBot.Start()
}

```

Index

Constants

View Source
const ISTFormat = "Jan 2 15:04:05 IST"

Variables

This section is empty.

Functions

func TimeStamp

func TimeStamp(format string) string

Types

type BasicBot

type BasicBot struct {
	Channel string

	Credentials *OAuthCred

	MsgRate time.Duration

	Name string

	Port string

	PrivatePath string

	Server string
	// contains filtered or unexported fields
}

func (*BasicBot) Connect

func (bb *BasicBot) Connect()

func (*BasicBot) Disconnect

func (bb *BasicBot) Disconnect()

func (*BasicBot) HandleChat

func (bb *BasicBot) HandleChat() error

func (*BasicBot) JoinChannel

func (bb *BasicBot) JoinChannel()

func (*BasicBot) ReadCredentials

func (bb *BasicBot) ReadCredentials() error

func (*BasicBot) Say

func (bb *BasicBot) Say(msg string) error

func (*BasicBot) Start

func (bb *BasicBot) Start()

type OAuthCred

type OAuthCred struct {
	Password string `json:"password,omitempty"`
}

type TwitchBot

type TwitchBot interface {
	Connect()
	Disconnect()
	HandleChat() error
	JoinChannel()
	ReadCredentials() error
	Say(msg string) error
	Start()
}

Jump to

Keyboard shortcuts

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