Documentation ¶
Overview ¶
Package irc contains a Bot implementation that works over the IRC protocol
Index ¶
- Variables
- type Admin
- type Conf
- type IRC
- func (i *IRC) AdminLevel(source string) int
- func (i *IRC) Connect() error
- func (i *IRC) Disconnect(msg string)
- func (i *IRC) HookJoin(f func(source, channel string))
- func (i *IRC) HookKick(f func(source, channel, target, message string))
- func (i *IRC) HookMessage(f func(source, channel, message string, isAction bool))
- func (i *IRC) HookNick(f func(source, newNick string))
- func (i *IRC) HookPart(f func(source, channel, message string))
- func (i *IRC) HookPrivateMessage(f func(source, channel, message string))
- func (i *IRC) HookQuit(f func(source, message string))
- func (i *IRC) HumanReadableSource(source string) string
- func (i *IRC) IsCommandPrefix(line string) (string, bool)
- func (i *IRC) JoinChannel(name string)
- func (i *IRC) Reload(tree interfaces.Unmarshaler) error
- func (i *IRC) Run() error
- func (i *IRC) SendAdminMessage(msg string)
- func (i *IRC) SendMessage(target, message string)
- func (i *IRC) SendNotice(target, message string)
- func (i *IRC) SendRaw(raw string)
- func (i *IRC) StaticCommandPrefixes() []string
- func (i *IRC) Status() string
- func (i *IRC) String() string
- type JoinEvent
- type KickEvent
- type LineHandler
- type MessageEvent
- type NickEvent
- type PartEvent
- type QuitEvent
- type RawEvent
- type Transformer
Constants ¶
This section is empty.
Variables ¶
var ErrNotConnected = errors.New("cannot send a message when not connected")
ErrNotConnected returned from Write when the IRC instance is not connected to a server
var (
ErrorIRCAlreadyConnected = errors.New("IRC is already connected")
)
Various Errors
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf struct { VerifyCerts bool `toml:"verify_certs" default:"true" comment:"verify TLS certs when connecting (default: true)"` SSL bool `toml:"ssl" default:"true" comment:"Use SSL/TLS (really TLS) for connection (default: true)"` CmdPfx string `toml:"command_prefix" default:"~" comment:"Command prefix to respond to (default: '~')"` Host string `toml:"host"` Port string `toml:"port"` HostPasswd string `toml:"host_password"` Admins []Admin `toml:"admins"` AdminChannels []string `toml:"admin_channels"` Nick string `toml:"nick"` Ident string `toml:"ident"` Gecos string `toml:"gecos"` // TODO: Cert based auth? (via SASL) Authenticate bool `toml:"authenticate" comment:"Should we authenticate with the IRC network"` SASL bool `toml:"sasl" comment:"Should authentication use SASL for negotiation (this is faster and more secure)"` //nolint:lll // Cant be made shorter AuthUser string `toml:"auth_user" comment:"User account to authenticate for"` AuthPasswd string `toml:"auth_passwd" comment:"Password for account authentication"` SuppressMOTD bool `toml:"suppress_motd" comment:"Suppress logging of IRC MOTD messages being logged"` SuppressPing bool `toml:"suppress_ping" comment:"Suppress logging of internal PING messages being logged"` }
Conf holds the configuration for an IRC instance
type IRC ¶
type IRC struct { *Conf Connected mutexTypes.Bool StopRequested mutexTypes.Bool RawEvents *event.Manager ParsedEvents *event.Manager // contains filtered or unexported fields }
IRC Represents a connection to an IRC server
func (*IRC) AdminLevel ¶
AdminLevel returns what admin level the given mask has, 0 means no admin access
func (*IRC) Connect ¶
Connect connects to IRC and does the required negotiation for registering on the network and any capabilities that have been requested
func (*IRC) Disconnect ¶
Disconnect disconnects the bot from IRC either with the given message. If no message is passed, it defaults to "Disconnecting"
func (*IRC) HookMessage ¶
HookMessage hooks on messages to a channel
func (*IRC) HookPrivateMessage ¶
HookPrivateMessage hooks on messages to us directly
func (*IRC) HumanReadableSource ¶
HumanReadableSource takes an IRC userhost and returns just the nick
func (*IRC) IsCommandPrefix ¶
IsCommandPrefix returns whether or not the given string contains any dynamic command prefixes
func (*IRC) JoinChannel ¶
JoinChannel joins the bot to the named channel and adds it to the channel list for later autojoins
func (*IRC) Reload ¶
func (i *IRC) Reload(tree interfaces.Unmarshaler) error
Reload parses and reloads the config on the IRC instance
func (*IRC) SendAdminMessage ¶
SendAdminMessage sends the given message to all AdminChannels defined on the bot
func (*IRC) SendMessage ¶
SendMessage sends a message to the given target
func (*IRC) SendNotice ¶
SendNotice sends a notice to the given notice
func (*IRC) StaticCommandPrefixes ¶
StaticCommandPrefixes returns the valid static command prefixes. This means any prefixes that will never change at runtime (for IRC, none)
type JoinEvent ¶
JoinEvent represents an IRC channel JOIN
func NewJoinEvent ¶
NewJoinEvent creates a JoinEvent with the given data
type KickEvent ¶
type KickEvent struct { *RawEvent Source ircutils.UserHost Channel string KickedNick string Message string }
KickEvent represents a channel KICK
func NewKickEvent ¶
NewKickEvent creates a KickEvent from the given data
type LineHandler ¶
type LineHandler func(message *ircmsg.IrcMessage, irc *IRC)
LineHandler is a function that is called on every raw Line
type MessageEvent ¶
type MessageEvent struct { *RawEvent IsNotice bool Source ircutils.UserHost Channel string Message string }
MessageEvent represents an IRC authUser message, both NOTICE and PRIVMSGs
func NewMessageEvent ¶
func NewMessageEvent(name string, line ircmsg.IrcMessage, tme time.Time) *MessageEvent
NewMessageEvent creates a MessageEvent with the given data.
type NickEvent ¶
NickEvent represents an IRC NICK command
func NewNickEvent ¶
NewNickEvent creates a NickEvent from the given data
type PartEvent ¶
PartEvent represents an IRC channel PART
func NewPartEvent ¶
NewPartEvent creates a PartEvent with the given data
type QuitEvent ¶
QuitEvent represents an IRC QUIT
func NewQuitEvent ¶
NewQuitEvent creates a QuitEvent from the given data
type RawEvent ¶
RawEvent represents an incoming raw IRC Line that needs to be handled
func NewRawEvent ¶
NewRawEvent creates a RawEvent with the given name and Line
type Transformer ¶
type Transformer struct{}
Transformer is a dummy struct that holds methods for IRCs implementation of format/transformer's transformer interface
func (Transformer) MakeIntermediate ¶
func (Transformer) MakeIntermediate(in string) string
MakeIntermediate implements Transformer.MakeIntermediate
func (Transformer) Transform ¶
func (Transformer) Transform(in string) string
Transform implements Transformer.Transform, colours are converted via a palette to the 15 IRC colours