<commit_before>package adapter

import (
    "fmt"
)

var adapters = map[string]InitFunc{}

func Register(name string, init InitFunc) {
    adapters[name] = init
}

func Load(name string) (InitFunc, error) {
    a, ok := adapters[name]

    if !ok {
        return nil, fmt.Errorf("Unkown adapter %s", name)
    }

    return a, nil
}

type InitFunc func(Brain) Adapter

type Adapter interface {
    Listen(chan Message) error
}

type AdapterFunc func(chan Message)
func (f AdapterFunc) Produce(m chan Message) {
    f(m)
}

type Message interface {
    Id()   string
    Body() string
    Room() Room
    User() User
    Reply(string) error
    SetParams([]string)
    Params() []string
}

type Room interface {
    Id() string
    Say(string) error
    Paste(string) error
    Sound(string) error
    Tweet(string) error
}

type User interface {
    Id() string
    Name() string
}

type Brain interface {
    Name() string
    Id() string
    SetId(string)
    Receive(Message)
    Respond(string, func(Message)) error
    Hear(string, func(Message)) error

    AddUser(User)
    AddRoom(Room)
    User(string) User
    Room(string) Room
}
<commit_msg>Documenting these a bit<commit_after>package adapter

import (
    "fmt"
)

var adapters = map[string]InitFunc{}

func Register(name string, init InitFunc) {
    adapters[name] = init
}

func Load(name string) (InitFunc, error) {
    a, ok := adapters[name]

    if !ok {
        return nil, fmt.Errorf("Unkown adapter %s", name)
    }

    return a, nil
}

type InitFunc func(Brain) Adapter

type Adapter interface {
    Listen(chan Message) error
}

type AdapterFunc func(chan Message)
func (f AdapterFunc) Produce(m chan Message) {
    f(m)
}

type Message interface {
    // Identity
    Id()   string
    Body() string
    Room() Room
    User() User

    // Sends
    Reply(string) error

    // Params
    SetParams([]string)
    Params() []string
}

type Room interface {
    // Identity
    Id() string

    // Sends
    Say(string) error
    Paste(string) error
    Sound(string) error
    Tweet(string) error
}

type User interface {
    // Identity
    Id() string
    Name() string
}

type Brain interface {
    // Identity
    Id() string
    SetId(string)
    Name() string

    // Listener registration
    Respond(string, func(Message)) error
    Hear(string, func(Message)) error

    // Input
    Receive(Message)

    // Memory (Users and Rooms)
    AddUser(User)
    AddRoom(Room)
    User(string) User
    Room(string) Room
}

{'fraction_non_alphanumeric': 0.10946863763483819, 'fraction_numerical': 0.0, 'mean_word_length': 2.7541229385307346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1632080', 'n_tokens_mistral': 837, 'n_tokens_neox': 807, 'n_words': 239}