Documentation ¶
Overview ¶
Package kitty is IRCv3 enabled framework for writing IRC bots
Index ¶
- Constants
- func ReconOpt() func(*Bot)
- func SaslAuth(pass string) func(*Bot)
- type Bot
- func (bot *Bot) Action(who, text string)
- func (bot *Bot) AddTrigger(h Handler)
- func (bot *Bot) CapStatus(cap string) (enabled, present bool)
- func (bot *Bot) ChMode(user, channel, mode string)
- func (bot *Bot) Close()
- func (bot *Bot) Join(ch string)
- func (bot *Bot) Msg(who, text string)
- func (bot *Bot) MsgMaxSize(who string) int
- func (bot *Bot) Notice(who, text string)
- func (bot *Bot) NoticeMaxSize(who string) int
- func (bot *Bot) Part(ch, msg string)
- func (bot *Bot) Prefix() *ircmsg.Prefix
- func (bot *Bot) PrefixChange(name, user, host string)
- func (bot *Bot) Reply(m *Message, text string)
- func (bot *Bot) ReplyMaxSize(m *Message) int
- func (bot *Bot) Run() (hijacked bool)
- func (bot *Bot) Send(command string)
- func (bot *Bot) SetNick(nick string)
- func (bot *Bot) String() string
- func (bot *Bot) Topic(c, topic string)
- func (bot *Bot) Uptime() string
- type Handler
- type Message
- type Trigger
Constants ¶
const CapAccountNotify = "account-notify"
CapAccountNotify is account-notify CAP
const CapAccountTag = "account-tag"
CapAccountTag is account-tag CAP
const CapAwayNotify = "away-notify"
CapAwayNotify is away-notify CAP
const CapCapNotify = "cap-notify"
CapCapNotify is cap-notify CAP
const CapChghost = "chghost"
CapChghost is chghost CAP
const CapExtendedJoin = "extended-join"
CapExtendedJoin is extended-join CAP
const CapIdentifyMsg = "identify-msg"
CapIdentifyMsg is identify-msg CAP
const CapInviteNotify = "invite-notify"
CapInviteNotify is invite-notify CAP
const CapMessageTags = "message-tags"
CapMessageTags is message-tags CAP
const CapMultiPrefix = "multi-prefix"
CapMultiPrefix is multi-prefix CAP
const CapSASL = "sasl"
CapSASL is SASL CAP
const CapServerTime = "server-time"
CapServerTime is server-time CAP
const CapSetName = "setname"
CapSetName is setname CAP
const CapTLS = "tls"
CapTLS is tls CAP
const CapUserhostInNames = "userhost-in-names"
CapUserhostInNames is userhost-in-names CAP
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bot ¶
type Bot struct { // Log15 loggger log.Logger // Exported fields Host string Password string Channels []string SSL bool SASL bool HijackSession bool // Set it if long messages get truncated // on the receiving end MsgSafetyBuffer bool // HijackAfterFunc executes in its own goroutine after a succesful session hijack // If you need to do something after a hijack // for example, to run some irc commands or to restore some state HijackAfterFunc func() // Fires after joining the channels Joined chan struct{} // An optional function that connects to an IRC server over plaintext: Dial func(network, addr string) (net.Conn, error) // An optional function that connects to an IRC server over a secured connection: DialTLS func(network, addr string, tlsConf *tls.Config) (*tls.Conn, error) // This bots nick Nick string // Duration to wait between sending of messages to avoid being // kicked by the server for flooding (default 200ms) ThrottleDelay time.Duration // Maxmimum time between incoming data PingTimeout time.Duration TLSConfig tls.Config // contains filtered or unexported fields }
Bot implements an irc bot to be connected to a given server
func (*Bot) AddTrigger ¶
AddTrigger adds a trigger to the bot's handlers
func (*Bot) ChMode ¶
ChMode is used to change users modes in a channel operator = "+o" deop = "-o" ban = "+b"
func (*Bot) MsgMaxSize ¶
MsgMaxSize returns maximum number of bytes that fit into one message. Useful, for example, if you want to generate a wall of emojis that fit into one message, or you want to cap some output to one message
func (*Bot) NoticeMaxSize ¶
NoticeMaxSize returns maximum number of bytes that fit into one message. Useful, for example, if you want to generate a wall of emojis that fit into one message, or you want to cap some output to one message
func (*Bot) Prefix ¶
Prefix returns the bot's own prefix. Can be useful if for example you want to make an emoji wall that fits into one message perfectly
func (*Bot) PrefixChange ¶
PrefixChange changes bot's prefix, use empty strings to make no change
func (*Bot) ReplyMaxSize ¶
ReplyMaxSize is just like MsgMaxSize but calculates message size for the reply target
func (*Bot) Run ¶
Run starts the bot and connects to the server. Blocks until we disconnect from the server. Returns true if we have been hijacked (if you loop over Run it might be wise to break on hijack to avoid looping between 2 instances).
func (*Bot) SetNick ¶
SetNick sets the bots nick on the irc server. This does not alter *Bot.Nick, so be vary of that
type Message ¶
type Message struct { // ircmsg.Message with extended data, like GetTag() for IRCv3 tags *ircmsg.Message // Content generally refers to the text of a PRIVMSG Content string //Time at which this message was recieved TimeStamp time.Time // Entity that this message was addressed to (channel or user) To string // Nick of the messages sender (equivalent to Prefix.Name) // Outdated, please use .Name From string }
Message represents a message received from the server
type Trigger ¶
type Trigger struct { // Returns true if this trigger applies to the passed in message Condition func(*Bot, *Message) bool // The action to perform if Condition is true Action func(*Bot, *Message) }
Trigger is a Handler which is guarded by a condition. DO NOT alter *Message in your triggers or you'll have strange things happen.