ctcp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

README

ctcp Go Reference

dead simple ctcp parser, and maker.

getting started

for s.Scan() {
	line := b.Text()
	// ...

	user, cmd, flags, fullmsg := irc.ParseLine(line)
	if cmd == "PRIVMSG" && ctcp.Valid(fullmsg) { // this is ctcp
		ctcpcmd, ctcpparams, _ := ctcp.Parse(fullmsg)
		if ctcpcmd == "PING" {
			irc.Notice(conn, user.Nick, fullmsg) // just send the same PING message back.
			continue
		}

		if ctcpcmd == "SOURCE" {
			ctcpreply_msg := ctcp.Make("SOURCE https://www.example.com/source.tgz")
			irc.Notice(conn, user.Nick, ctcpreply_msg)
			continue
		}
	}
}

documentation

press this: Go Reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Make

func Make(m string) string

Make CTCP message. You will need to send this manually either by sending ([irc.Chat]) or replying [irc.Notice].

// sending:
ctcpmsg := ctcp.Make("SOURCE")
irc.Chat(conn, "User", ctcpmsg)

// replying:
ctcpmsg := ctcp.Make("SOURCE https://www.example.com/source.tgz")
irc.Notice(conn, "User", ctcpmsg)

func Parse

func Parse(fullmsg string) (cmd, params, cleanedMSG string)

Parse CTCP message. Message must be manually checked via IsCTCP before calling this.

user, cmd, flags, fullmsg := irc.ParseLine(line)
if cmd == "PRIVMSG" && ctcp.Valid(fullmsg) { // this is ctcp
	ctcpcmd, ctcpparams, _ := ctcp.Parse(fullmsg)
	if ctcpcmd == "PING" {
		irc.Notice(conn, user.Nick, fullmsg) // just send the same PING message back.
		continue
	}
}

func Valid

func Valid(fullmsg string) (valid, hasSuffix bool)

Check whenever a message is valid CTCP message

Types

This section is empty.

Jump to

Keyboard shortcuts

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