irc

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const UTCFormat = "Jan 2 15:04:05 UTC"

Variables

View Source
var CmdRegex *regexp.Regexp = regexp.MustCompile(`^!(\w+)\s?(\w+)?`)

Regex for parsing user commands, from already parsed PRIVMSG strings.

First matched group is the command name and the second matched group is the argument for the command.

View Source
var ConnectRegex *regexp.Regexp = regexp.MustCompile(`^:tmi.twitch.tv 001 ([^ ]+) .*`)

Regex for parsing connection messages

First matched group is our real username - twitch doesn't complain at using NICK command but doesn't honor it.

View Source
var DirectMsgRegex *regexp.Regexp = regexp.MustCompile(`^:(\w+)!\w+@\w+\.tmi\.twitch\.tv (PRIVMSG) (\w+)(?: :(.*))?$`)
View Source
var MsgRegex *regexp.Regexp = regexp.MustCompile(`^:(\w+)!\w+@\w+\.tmi\.twitch\.tv (PRIVMSG) #(\w+)(?: :(.*))?$`)

Regex for parsing PRIVMSG strings.

First matched group is the user's name, second is the channel? and the third matched group is the content of the user's message.

Functions

func TimeStamp

func TimeStamp() string

func TimeStampFmt

func TimeStampFmt(format string) string

Types

type AppOAuthCred

type AppOAuthCred struct {

	// The bot account's OAuth password.
	ClientID string `json:"client_id,omitempty"`

	// The developer application client ID. Used for API calls to Twitch.
	ClientSecret string `json:"client_secret,omitempty"`
}

type IRCOAuthCred

type IRCOAuthCred struct {

	// The bot account's OAuth password.
	Password string `json:"password,omitempty"`

	// The developer application client ID. Used for API calls to Twitch.
	Nick string `json:"nick,omitempty"`
}

type KardBot

type KardBot struct {
	Channel string

	IrcCredentials *IRCOAuthCred
	AppCredentials *AppOAuthCred
	MsgRate        time.Duration
	Name           string
	Port           string
	IrcPrivatePath string
	AppPrivatePath string
	Server         string

	Prompts    []string
	GlobalData data.GlobalData
	// contains filtered or unexported fields
}

func (*KardBot) ActiveChannels

func (bb *KardBot) ActiveChannels() int

Look at the channels I'm actually in

func (*KardBot) Connect

func (bb *KardBot) Connect()

Connects the bot to the Twitch IRC server. The bot will continue to try to connect until it succeeds or is forcefully shutdown.

func (*KardBot) Disconnect

func (bb *KardBot) Disconnect()

Officially disconnects the bot from the Twitch IRC server.

func (*KardBot) HandleChat

func (bb *KardBot) HandleChat() error

Listens for and logs messages from chat. Responds to commands from the channel owner. The bot continues until it gets disconnected, told to shutdown, or forcefully shutdown.

func (*KardBot) JoinChannel

func (bb *KardBot) JoinChannel(channels ...string)

Makes the bot join its pre-specified channel.

func (*KardBot) LeaveChannel

func (bb *KardBot) LeaveChannel(channels ...string)

func (*KardBot) Login

func (bb *KardBot) Login()

Login to the IRC server

func (*KardBot) Msg

func (bb *KardBot) Msg(msg string, users ...string) error

func (*KardBot) ReadCredentials

func (bb *KardBot) ReadCredentials(credType string) error

Reads from the private credentials file and stores the data in the bot's appropriate Credentials field.

func (*KardBot) Say

func (bb *KardBot) Say(msg string, channels ...string) error

Makes the bot send a message to the chat channel.

func (*KardBot) Start

func (bb *KardBot) Start()

Starts a loop where the bot will attempt to connect to the Twitch IRC server, then connect to the pre-specified channel, and then handle the chat. It will attempt to reconnect until it is told to shut down, or is forcefully shutdown.

Jump to

Keyboard shortcuts

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