pail

package module
v0.0.0-...-3c05be1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 9 Imported by: 0

README

Pail

Pail is a simple Discord bot, heavily inspired by xkcd's Bucket

Pail was thrown together in a few hours and as such is horribly written at the moment. Feel free to submit PRs with improvements to functionality, code quality, bug fixes, or anything else.

Getting Started

Dependencies
  • Go
  • sqlite3
  • reflex to use hotreload
Setup
  1. Create pail config directory at ~/.config/pail/
  2. Copy pail.toml from the examples folder to new config directory
  3. Configure pail
  4. Run pail once, either using hotreload.sh or go run cmd/pail/main.go. This will create an empty database. Quit pail using ctrl+c
  5. Run initial database population using cat examples/pail.sql | sqlite3 ~/.config/pail/pail.db
Configuration
  • Token: Your bot's unique token
  • ReplaceChance: The chance a phrase will be replaced using a replace action in the regex table. 5 = 5%, 100 = 100%, etc.
  • RandomInterval: How often your bot will pick a random fact if there is no activity in minutes
  • RandomChannels: List of channel IDs to send a random fact on. To get a channel's ID, right click on it in Discord and select Copy ID. Leaving the list empty will result in no random facts.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Token          string
	RandomChannels []int
	ReplaceChance  int
	RandomInterval int
	Debug          bool
}

type Fact

type Fact struct {
	ID             int64  `db:"id"`
	Fact           string `db:"fact"`
	Verb           string `db:"verb"`
	Tidbit         string `db:"tidbit"`
	ReplacedTidbit string `db:"-"`
}

func NewFact

func NewFact(fact, tidbit, verb string) *Fact

type Pail

type Pail struct {
	// contains filtered or unexported fields
}

func NewPail

func NewPail(config *Config, dbPath string) (*Pail, error)

func (*Pail) Close

func (p *Pail) Close()

func (*Pail) Open

func (p *Pail) Open() error

func (*Pail) Reset

func (p *Pail) Reset()

func (*Pail) Say

func (p *Pail) Say(chanID, msg string)

type Regex

type Regex struct {
	ID         int64          `db:"id"`
	Expression string         `db:"expression"`
	Action     string         `db:"action"`
	Sub        string         `db:"sub"`
	Compiled   *regexp.Regexp `db:"-"`
}

type Value

type Value struct {
	ID    int64  `db:"id"`
	VarID int64  `db:"var_id"`
	Value string `db:"value"`
}

func NewValue

func NewValue(varID int64, value string) *Value

type Var

type Var struct {
	ID   int64  `db:"id"`
	Name string `db:"name"`
}

func NewVar

func NewVar(name string) *Var

type VarValue

type VarValue struct {
	*Var
	*Value
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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