Tetra: github.com/Xe/Tetra/bot Index | Files | Directories

package tetra

import "github.com/Xe/Tetra/bot"

Package tetra implements the core for a TS6 pseudoserver. It also has lua and moonscript loading support to add functionality at runtime.


Package Files

basehandlers.go channel.go client.go clients.go command.go connection.go handler.go help.go hook.go logging_release.go script.go server.go service.go stats.go tetra.go web.go workers.go yo.go


const (
    INV_COMMAND = 0x0001
    INV_NAMHOOK = 0x0002
    INV_PROHOOK = 0x0004

The different kinds of invocations that can be called upon.


var (
    Conn     *Connection
    Info     *Server
    Clients  *ClientSet
    Channels map[string]*Channel
    Bursted  bool
    Handlers map[string]map[string]*Handler
    Services map[string]*Client
    Servers  map[string]*Server
    Scripts  map[string]*Script
    Hooks    map[string][]*Hook

    ActiveConfig *config.Config
    Log          *log.Logger
    Uplink       *Server

    Etcd   *etcd.Client
    Atheme *atheme.Atheme
    Cron   *cron.Cron

Struct Tetra contains all fields for

var (
    Libraries map[string]luar.Map

func Auth Uses

func Auth()

Auth authenticates over TS6.

func Burst Uses

func Burst()

Burst sends our local information after recieving the server's burst.

func Connect Uses

func Connect(host, port string) (err error)

Connect connects to the uplink server.

func DelHandler Uses

func DelHandler(verb string, uuid string) (err error)

DelHandler deletes a handler for a given protocol verb by the UUID of the handler.

func DelHook Uses

func DelHook(hook *Hook) (err error)

DelHook deletes a hook. Returns an error if there is no such hook to delete.

func DelService Uses

func DelService(service string) (err error)

DelService deletes a service from the network or returns an error.

func GetChannelStats Uses

func GetChannelStats(...interface{})

func GetNetworkStats Uses

func GetNetworkStats(...interface{})

func GetYo Uses

func GetYo(name string) (client *yo.Client, err error)

GetYo returns an instance of yo.Client based on the username being present in the apikeys section of the configuration file.

func Main Uses

func Main()

Main is the main loop.

func NewTetra Uses

func NewTetra(cpath string)

NewTetra returns a new instance of Tetra based on a config file located at cpath. This also kicks off the worker goroutines and statistics collection, as well as seeding basic protocol verb handlers.

func NextUID Uses

func NextUID() string

NextUID returns a new TS6 UID.

func ProcessLine Uses

func ProcessLine(line string)

ProcessLine processes a line as if it came from the server.

func Quit Uses

func Quit()

Quit kills Tetra gracefully.

func RunHook Uses

func RunHook(verb string, args ...interface{}) (err error)

RunHook runs a hook in parallel across multiple goroutines, one per implementaion of the hook. Returns error if there is no such hook.

func StickConfig Uses

func StickConfig()

StickConfig creates Clients based off of the config file and handles module autoloads.

func UnloadScript Uses

func UnloadScript(name string) error

Unload a script and delete its commands and handlers

func WebApp Uses

func WebApp()

WebApp creates the web application and YAML api for Tetra.

type ChanUser Uses

type ChanUser struct {
    Client  *Client
    Channel *Channel
    Prefix  int

Struct ChanUser is a wrapper around a Channel and a Client to represent membership in a Channel.

type Channel Uses

type Channel struct {
    Name     string
    Ts       int64
    Modes    int
    Clients  map[string]*ChanUser
    Lists    map[int][]string
    Gauge    metrics.Gauge
    Metadata map[string]string
    // contains filtered or unexported fields

Struct Channel holds all the relevant data for an IRC channel. A lot of this is not just things defined in RFC 1459, but extensions like the TS. This implements Targeter

func NewChannel Uses

func NewChannel(name string, ts int64) (c *Channel)

NewChannel creates a new channel with a given name and ts.

func (*Channel) AddChanUser Uses

func (c *Channel) AddChanUser(client *Client) (cu *ChanUser)

AddChanUser adds a client to the channel, returning the membership.

func (*Channel) DelChanUser Uses

func (c *Channel) DelChanUser(client *Client) (err error)

DelChanUser deletes a client from a channel or returns an error.

func (*Channel) IsChannel Uses

func (c *Channel) IsChannel() bool

IsChannel returns true.

func (*Channel) Target Uses

func (c *Channel) Target() string

Target returns a targetable version of Channel.

type Client Uses

type Client struct {
    Nick        string
    User        string
    Host        string
    VHost       string
    Ip          string
    Account     string
    Uid         string
    Gecos       string
    Permissions int
    Umodes      int
    Kind        string
    Ts          int64
    Channels    map[string]*Channel
    Server      *Server
    Commands    map[string]*Command
    Certfp      string
    Metadata    map[string]string
    // contains filtered or unexported fields

Struct Client holds information about a client on the IRC network.

func AddService Uses

func AddService(service, nick, user, host, gecos, certfp string) (cli *Client)

AddService adds a new service Client to the network.

func (*Client) Chghost Uses

func (r *Client) Chghost(target *Client, newhost string) (err error)

Chghost changes a client's visible host

func (*Client) Euid Uses

func (r *Client) Euid() string

Euid returns an EUID burst.

func (*Client) IsChannel Uses

func (r *Client) IsChannel() bool

IsChannel returns false.

func (*Client) IsOper Uses

func (r *Client) IsOper() bool

IsOper returns if the client is an operator or not.

func (*Client) Join Uses

func (r *Client) Join(channame string)

Join makes the client join a channel. This does not check bans.

func (*Client) Kill Uses

func (r *Client) Kill(target *Client, reason string)

Kill kills a target client

func (*Client) NewCommand Uses

func (c *Client) NewCommand(verb string, handler func(*Client, Targeter, []string) string) (cmd *Command, err error)

NewCommand returns a new command instance.

func (*Client) Notice Uses

func (r *Client) Notice(destination Targeter, message string)

Notice sends a NOTICE to destination with given message.

func (*Client) OperLog Uses

func (r *Client) OperLog(message string)

OperLog logs a given message to the operator channel.

func (*Client) Part Uses

func (r *Client) Part(channame string) bool

Part makes the client leave a channel.

func (*Client) Privmsg Uses

func (r *Client) Privmsg(destination Targeter, message string)

Privmsg sends a PRIVMSG to destination with given message.

func (*Client) Quit Uses

func (r *Client) Quit()

Quit quits a client off of the network.

func (*Client) ServicesLog Uses

func (r *Client) ServicesLog(message string)

ServicesLog logs a given message to the services snoop channel.

func (*Client) Target Uses

func (r *Client) Target() string

Target returns a targetable version of a Client.

type ClientSet Uses

type ClientSet struct {
    ByNick map[string]*Client
    ByUID  map[string]*Client
    Gauge  metrics.Gauge

Struct Clients defines the set of clients on the network, indexed by either nickname (in capital letters) or UID.

func (*ClientSet) AddClient Uses

func (c *ClientSet) AddClient(client *Client)

AddClient adds a Client to the Clients structure.

func (*ClientSet) ChangeNick Uses

func (c *ClientSet) ChangeNick(client *Client, newnick string) (err error)

ChangeNick changes a client's nickname and updates the ByNick map.

func (*ClientSet) DelClient Uses

func (c *ClientSet) DelClient(client *Client) (err error)

DelClient deletes a Client from the Clients structure.

type Command Uses

type Command struct {
    Impl      func(*Client, Targeter, []string) string
    Uuid      string
    Script    *Script
    Verb      string
    Owner     *Client
    NeedsOper bool

Struct command holds everything needed for a bot command.

type Connection Uses

type Connection struct {
    Conn   net.Conn
    Log    *log.Logger
    Reader *bufio.Reader
    Tp     *textproto.Reader
    Buffer chan string

    Debug bool
    // contains filtered or unexported fields

Struct Connection contains everything needed for the socket connection Tetra uses.

func (*Connection) Close Uses

func (c *Connection) Close()

Close kills the connection

func (*Connection) GetLine Uses

func (c *Connection) GetLine() (line string, err error)

GetLine returns a new line from the server.

func (*Connection) SendLine Uses

func (c *Connection) SendLine(line string, stuff ...interface{})

SendLine buffers a line to be sent to the server.

type Handler Uses

type Handler struct {
    Impl   func(*r1459.RawLine)
    Verb   string
    Uuid   string
    Script *Script
    Go     bool

Struct Handler defines a raw protocol verb handler. Please do not use this unless you have good reason to.

func AddHandler Uses

func AddHandler(verb string, impl func(*r1459.RawLine)) (handler *Handler, err error)

AddHandler adds a handler for a given verb.

type Hook Uses

type Hook struct {
    Uuid string

    Owner *Script
    Verb  string
    // contains filtered or unexported fields

Struct Hook defines a command hook for Tetra. This can be used for hooking on events (like being yo'd).

func NewHook Uses

func NewHook(verb string, impl func(...interface{})) (h *Hook)

NewHook allocates and returns a new Hook structure

type Invocation Uses

type Invocation struct {
    Kind     int
    Args     []interface{}
    Reply    chan string
    Function *luar.LuaObject
    Client   *Client
    Target   Targeter
    Line     *r1459.RawLine

Struct Invocation represents an event from Go->Lua.

type Script Uses

type Script struct {
    Name     string
    L        *lua.State
    Log      *log.Logger
    Handlers map[string]*Handler
    Commands map[string]*Command
    Hooks    []*Hook
    Service  string
    Client   *Client
    Uuid     string
    Kind     string
    Trigger  chan []interface{}

Struct Script implements a Lua scripting interface to Tetra.

func LoadScript Uses

func LoadScript(name string) (script *Script, err error)

LoadScript finds and loads the appropriate script by a given short name (tetra/die).

func (*Script) AddLuaCommand Uses

func (script *Script) AddLuaCommand(verb string, name string) error

AddLuaCommand adds a new command to a script from a lua context.

func (*Script) AddLuaHook Uses

func (script *Script) AddLuaHook(verb string, name string) error

AddLuaHook adds a named hook from lua.

func (*Script) AddLuaProtohook Uses

func (script *Script) AddLuaProtohook(verb string, name string) error

AddLuaProtohook adds a lua function as a protocol hook.

func (*Script) Call Uses

func (s *Script) Call(command string, source *Client, dest Targeter, args []string) (string, error)

Call calls a command in a Script.

type Server Uses

type Server struct {
    Sid     string
    Name    string
    Gecos   string
    Links   []*Server
    Count   int
    Counter metrics.Gauge
    Hops    int
    Capab   []string

Struct Server holds information for a TS6 server.

func NewServer Uses

func NewServer(parent *Server, name, gecos, id, hops string) *Server

NewServer allocates a new server struct, fitting it into the network.

func (*Server) AddClient Uses

func (s *Server) AddClient()

AddClient increments the server client counter.

func (*Server) DelClient Uses

func (s *Server) DelClient()

DelClient decrements the server client counter.

type Targeter Uses

type Targeter interface {
    Target() string  // Targetable version of name
    IsChannel() bool // Is this a channel?

Interface Targeter wraps around Client and Channel to make messaging to them seamless.


configPackage config holds the configuration for Tetra.
modesPackage modes contains a bunch of constants and lookup tables that are a pain to use without this file.
scriptPackage script is for the resuable lua scripting engine that Tetra uses.
script/charybdisPackage charybdis contains wrapped functions taken directly from the charybdis source tree.
script/cryptoPackage crypto is for cryptographic or similar kinds of functions.
script/stringsPackage strings contains Tetra's string manipulation functions that are exposed to lua scripts.
webPackage web is a series of negroni middlewares for Tetra.

Package tetra imports 41 packages (graph) and is imported by 2 packages. Updated 2016-07-19. Refresh now. Tools for package owners.