Documentation ¶
Overview ¶
Package ctcp implements partial support for the Client-to-Client Protocol.
CTCP defines extended messages using the standard PRIVMSG and NOTICE commands in IRC. This means that any CTCP messages are embedded inside the normal message text. Clients that don't support CTCP simply show the encoded message to the user.
Most IRC clients support only a subset of the protocol, and only a few commands are actually used. This package aims to implement the most basic CTCP messages: a single command per IRC message. Quoting is not supported.
Example using the irc.Message type:
m := irc.ParseMessage(...) if tag, text, ok := ctcp.Decode(m.Trailing); ok { // This is a CTCP message. } else { // This is not a CTCP message. }
Similar, for encoding messages:
m.Trailing = ctcp.Encode("ACTION","wants a cookie!")
Do not send a complete IRC message to Decode, it won't work.
Index ¶
- Constants
- func Action(message string) string
- func ClientInfo(message string) string
- func Decode(text string) (tag, message string, ok bool)
- func Encode(tag, message string) (text string)
- func Finger(message string) string
- func Ping(message string) string
- func Pong(message string) string
- func Source(message string) string
- func Time(message string) string
- func TimeReply() string
- func UserInfo(message string) string
- func Version(message string) string
- func VersionReply() string
Constants ¶
const ( ACTION = "ACTION" PING = "PING" PONG = "PONG" VERSION = "VERSION" USERINFO = "USERINFO" CLIENTINFO = "CLIENTINFO" FINGER = "FINGER" SOURCE = "SOURCE" TIME = "TIME" )
Tags extracted from the CTCP spec.
Variables ¶
This section is empty.
Functions ¶
func ClientInfo ¶
ClientInfo is a shortcut for Encode(ctcp.CLIENTINFO, message).
func Decode ¶
Decode attempts to decode CTCP tagged data inside given message text.
If the message text does not contain tagged data, ok will be false.
<text> ::= <delim> <tag> [<SPACE> <message>] <delim> <delim> ::= 0x01
func Encode ¶
Encode returns the IRC message text for CTCP tagged data.
<text> ::= <delim> <tag> [<SPACE> <message>] <delim> <delim> ::= 0x01
func TimeReply ¶
func TimeReply() string
TimeReply is a shortcut for Encode(ctcp.TIME, currenttime).
func VersionReply ¶
func VersionReply() string
VersionReply is a shortcut for ENCODE(ctcp.VERSION, go version info).
Types ¶
This section is empty.