The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bot::Cobalt::Manual::Plugins::Config - Cobalt config file primer

DESCRIPTION

This document is a very brief overview aimed at plugin authors in need of a quick reference to plugin configuration files loaded via Config directives.

Bot::Cobalt configuration files are written in YAML. http://yaml.org/spec/1.1/

Mostly, you will see hash structures like this:

  $ cat etc/plugins/mine/myplugin.conf
  ---
  ## config for MyPlugin
  ## RequiredLevels: hash specifying access levels for commands:
  RequiredLevels:
    cmd_ensnackulate: 2
    cmd_refrobulate: 1

...which would be converted, upon load, into a Bot::Cobalt::Conf::File::PerPlugin object.

(These structures would normally be accessed by plugins via the Core's "get_plugin_cfg" in Bot::Cobalt::Core::Role::EasyAccessors method or "plugin_cfg" in Bot::Cobalt::Core::Sugar -- see Bot::Cobalt::Manual::Plugins for details.)

See Bot::Cobalt::Manual::Plugins::Dist for details on embedding configuration files installable via cobalt2-plugin-installcf.

Indentation

Indentation builds nested structures; 2 spaces is the standard for Bot::Cobalt configuration files:

  Opts:
    SomeOpt: 1
    OtherOpts:
      ThisElement: "Some string"

Boolean values

Many configuration options, especially in the core plugin set, are simple boolean true/false:

  ## Example of a boolean true or false
  ## if UseSSL is commented out, 0, or ~ (undef), it is "false"
  ## true if 1 or some other positive value like a string ("Yes")
  UseSSL: 1
  
  ## ...just as valid for a simple boolean check:
  UseSSL: "Yes please!"

Strings

  SomeString: A string

Strings can be quoted:

  SomeString: "A string"

For example:

  SomeNum: 176.100    ## Numeric 176.1
  SomeNum: "176.100"  ## String "176.100"

Within double-quotes, special characters can be escaped C-style.

Block literals

A block literal might look something like this:

  ## newlines preserved:
  ThisDoc: |
    Some text here.
    And even more text here.
    Perhaps some more!

  ## newlines folded:
  ThisDoc: >
    <p>Some literal html</p>
    <p>More of it</p>

Hashes

  MyHash:
    Scalar_item: "a scalar"
    Another_Hash:
      Item_one: 1
      Item_two: "String"

Item_two would be available via MyHash->{Another_Hash}->{Item_two}.

Lists

A list/array looks something like this:

  MyList:
    - An item
    - Another item

  ## a deeply nested structure:
  MyUsers:
    - JoeUser
    - Bobby
    - Another list
    - SomeHash:
        One_Item: 1
        Another_item: "Some string"

(In this example, Another_item would be available via MyUsers[3]->{Another_item})

SEE ALSO

http://yaml.org/spec/1.1/

YAML::XS

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>