irc

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package irc implements an irc-discord bridge.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

A Bot represents an IRC-Discord bot.

Example
b, err := New(
	Host("irc.example.com:6697"),
	TLS(true),
	Nick("discord"),
	Token("<discord bot token>"),
	Sync(Channel("#irc-channel"), Discord("#discord-channel", "<discord webhook URL>")),
	Relay(Discord("#discord-channel", "<discord webhook URL>"), Channel("#irc-read-only-channel")),
	Relay(Channel("#irc-channel"), Discord("#discord-read-only-channel", "<discord webhook URL>")),
	// ...
)
if err != nil {
	log.Fatal(err)
}
defer b.Close()

log.Printf("IRC-Discord bridge running - press CTRL-C to exit")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
Output:

func New

func New(options ...Option) (*Bot, error)

New creates a new IRC-Discord bot.

func (*Bot) Close

func (b *Bot) Close() error

Close disconnects the bot from IRC and Discord.

type ChannelDiscord added in v1.0.10

type ChannelDiscord struct {
	// contains filtered or unexported fields
}

ChannelDiscord represents a configured Discord channel with Discord().

func Discord added in v1.0.5

func Discord(channel string, webhook string) *ChannelDiscord

Discord configures a Discord channel with a webhook.

type ChannelIRC added in v1.0.10

type ChannelIRC struct {
	// contains filtered or unexported fields
}

ChannelIRC represents a configured IRC channel with Channel().

func Channel

func Channel(channel string) *ChannelIRC

Channel configures an IRC channel.

type Option

type Option func(*Bot) error

An Option configures a Bot in New.

func Host

func Host(v string) Option

Host configures the IRC server host:port.

func Nick

func Nick(v string) Option

Nick configures the IRC nick of the bot.

func Relay added in v1.0.5

func Relay(from, to interface{}) Option

Relay configures a relay from either IRC channel or Discord channel to the other. To have it both ways, use twice or use the Sync shortcut.

func Sync added in v1.0.5

func Sync(irc *ChannelIRC, discord *ChannelDiscord) Option

Sync an IRC channel with a Discord channel.

func TLS

func TLS(v bool) Option

TLS configures whether the IRC connection should use TLS. Default is true.

func Token

func Token(v string) Option

Token configures the Discord bot token.

Jump to

Keyboard shortcuts

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