api

package
v0.0.0-...-62d7cb0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DB_TYPE = "sqlite3"
View Source
const ExtensionGetterName = "GetExtension"

ExtensionGetterName defines the function that the extension build system looks for to create new extensions. If the top level of an Extension source file does not define this function or doesn't return an Extension, then none will be loaded.

This constant is not for direct use when implementing Extension, but is only used by the core extension build system.

View Source
const Version = "0.1.0"

Please update the version when you make changes to this api package and remember to maintain the changelog.

Variables

This section is empty.

Functions

func EchoEvent

func EchoEvent(ev *irc.Event) (message string)

Types

type Callback

type Callback func(*irc.Event)

Callback is an alias for any function that takes an irc.Event

type CallbackMap

type CallbackMap map[string]Callback

CallbackMap maps CTCP codes to Callbacks

type Connection

type Connection interface {
	HangUp() error
}

Connection is an interface for things you can hang up on when you don't care about them anymore. Extensions should never need to directly use this.

type DatabaseConnection

type DatabaseConnection struct{ *sql.DB }

DatabaseConnection represents the local sqlite3 database interface

func ConnectToDatabase

func ConnectToDatabase(path string) (DatabaseConnection, error)

func (DatabaseConnection) HangUp

func (dc DatabaseConnection) HangUp() error

func (DatabaseConnection) Init

func (dc DatabaseConnection) Init()

type Extension

type Extension interface {
	// Inject is called once per Extension when it is loaded. Extensions:
	//   - MAY Hold onto Connections passed in the Injection
	//     - After which they may be accessed by Callbacks
	//   - MAY return a CallbakMap of CTCP codes mapped to Extension methods
	//     - Extension methods MUST implement Callback
	//     - Callbacks can only access irc.Events and whatever member variables
	//       the specific Extension defines (such as the Injection).
	//   - MAY return initialization errors
	//     - If errors are returned from Inject, the Extension's callbacks will not
	//       be registered, and will not run.
	Inject(Injection) (CallbackMap, []error)
	// Kill is called on Extensions when rebuilding Extensions or when the program closes.
	// It may also happen at any time whatsoever. Any Callbacks registered are unregistered
	// prior to calling Kill.
	Kill() []error
	// Version should return a string that represents the Extension version for debugging
	// and administration purposes. Human readable versions are preferred.
	Version() string
}

Extension defines the API for jazz extensions

type FileConnection

type FileConnection struct {
	*os.File
	io.Writer
}

FileConnection represents the local filesystem interface

func ConnectToFile

func ConnectToFile(path string) (FileConnection, error)

func (FileConnection) HangUp

func (fc FileConnection) HangUp() error

type HTTPClient

type HTTPClient struct{ http.Client }

HTTPClient represents the HTTP interface

func ConnectToHTTP

func ConnectToHTTP() (HTTPClient, error)

func (HTTPClient) HangUp

func (hc HTTPClient) HangUp() error

type IRCConnection

type IRCConnection struct{ *irc.Connection }

IRCConnection represents the IRC interface

func ConnectToIRC

func ConnectToIRC(nick, user, server string) (IRCConnection, error)

func (IRCConnection) HangUp

func (ic IRCConnection) HangUp() error

type Injection

Injection is the struct provided to Extensions that allow them to interact with Connections. The Injection is only given to Extensions one time on initialization via the Inject method. It's up to Extensions to persist the Connections that will be used in Callbacks, or to persist the Injection entirely.

Jump to

Keyboard shortcuts

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