tsugumi

package module
v0.0.0-...-32d5e39 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 16 Imported by: 0

README

tsugumi

やれやれだぜ

Installing
$ go get -u github.com/vulski/tsugumi/...
Getting Started
$ mkdir ~/.tsugumi && cp $GOPATH/src/github.com/vulski/tsugumi/config.json ~/.tsugumi/config.json

Edit the default config.json to your liking

{
  "nick": "tsugumi",
  "ssl": false,
  "sasl": false,
  "username": "tsugumi",
  "password": "",
  "host": "chat.freenode.net:6667",
  "commandoperator": "!",
  "channels": [
    "#tsugumi"
  ],
  "daddies": [],
  "plugins": [],
  "debug": false,
  "instances": "1"
}

Run !

tsugumi -rebuild

The -rebuild flag will rebuild/build any plugins, if you set any.

Default Commands

Some default commands out of the box (assuming ! is our commandoperator)

  • !nick {NICK} - Change the bot's nick name.
  • !join {CHANNEL} - Tell the bot to join a channel.
  • !part {CHANNEL} - Tell the bot to part a channel.
  • !topic {TOPIC} - Set the topic for the current channel.
  • !tell {NICK} {MESSAGE} - Tell a user a message when they type in the current channel.
Installing plugins

Installing and updating plugins are fairly simple, simple clone the plugin you want into the ~/.tsugumi/plugins directory and add the plugin's directory name to "plugins" variable in your config.

For example,

$ git clone https://github.com/vulski/title_plugin.git ~/.tsugumi/plugins/title

Add to your config.json plugins

  "plugins": [
    "title",
  ]

Then run tsugumi with the -rebuild flag.

$ tsugumi -rebuild

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ANGRY

func ANGRY() string

func GimmeFunny

func GimmeFunny() string

Randomly return a string from the string slice 'xd'

func NewLogger

func NewLogger(options Options) *log.Logger

func UserHomeDir

func UserHomeDir() string

Types

type Bot

type Bot struct {
	Logger        *log.Logger
	Config        Configuration
	Connection    *irc.Connection
	Commands      []*Command
	WorkDirectory string
	DB            *gorm.DB
}

func New

func New(
	config Configuration,
	logger *log.Logger,
	db *gorm.DB,
) *Bot

Create a new Tsugumi bot.

func (*Bot) AddCallback

func (tsugumi *Bot) AddCallback(eventCode string, callback func(c *irc.Event))

Register an IRC callback.

func (*Bot) AddCommand

func (tsugumi *Bot) AddCommand(cmd *Command)

func (*Bot) IsDad

func (tsugumi *Bot) IsDad(nick string) bool

Check if they're an allowed user.

func (*Bot) Log

func (tsugumi *Bot) Log(message string)

Simple helper function to make basic logs easier.

func (*Bot) Start

func (tsugumi *Bot) Start()

Run the bot.

type Command

type Command struct {
	Channel     string
	Nick        string
	Target      string
	Command     string
	EventCode   string
	Arguments   []string
	Description string
	Tsugumi     *Bot
	Handle      func(event *irc.Event, cmd *Command)
	*irc.Event
	IsDad bool
}

func ParseCommand

func ParseCommand(event *irc.Event, cmd *Command) *Command

func (*Command) Reply

func (cmd *Command) Reply(msg string)

type Configuration

type Configuration struct {
	Host string

	Nick     string
	Username string
	Password string
	SASL     bool

	CommandOperator string

	Channels  []string
	Daddies   []string
	Plugins   []string
	Debug     bool
	Identify  string
	Instances int
	SSL       bool
}

func ConfigFromJSON

func ConfigFromJSON(fileName string, filePath string) (Configuration, error)

Create a Configuration from a JSON file.

type Options

type Options struct {
	TimeFormat   string
	LogDirectory string
}

func GetDefaultOptions

func GetDefaultOptions() Options

type Plugin

type Plugin struct {
	Name        string
	Description string
	Author      string
	Version     string

	Commands  []*Command
	Callbacks []func() (string, func(*irc.Event))

	Enabled bool

	Dir string
}

func (*Plugin) Build

func (p *Plugin) Build() error

type PluginManager

type PluginManager struct {
	Plugins []*Plugin
	// contains filtered or unexported fields
}

func NewPluginManager

func NewPluginManager(t *Bot) PluginManager

func (*PluginManager) BuildPlugins

func (pm *PluginManager) BuildPlugins()

func (*PluginManager) DisablePlugin

func (pm *PluginManager) DisablePlugin(name string) error

func (*PluginManager) EnablePlugin

func (pm *PluginManager) EnablePlugin(name string) error

func (*PluginManager) GetPlug

func (pm *PluginManager) GetPlug(name string) (*Plugin, error)

func (*PluginManager) LoadPlugins

func (pm *PluginManager) LoadPlugins()

func (*PluginManager) Register

func (pm *PluginManager) Register() error

Directories

Path Synopsis
cmd
sed

Jump to

Keyboard shortcuts

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