Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Plugin Config

mheffner edited this page Jan 11, 2012 · 3 revisions

Config Plugin

Provides chat access to the Twke::Conf configuration module.

Variable name scoping

Variable names should use a scoping method that separates scopes with a 'dot' (.). For example, if your plugin is named foobar then variables for this plugin should have a prefix of foobar.. You can also utilize the dot notation to provide dynamic variable lists. For example, say your plugin provides the ability to perform an action across a set of named elements, and each action requires a path and repo setting. You can then set foobar.name1.repo and foobar.name1.path to the repo and path for the named element name1. If you have a name2 element, you can set the same variables replacing name1 with name2. In the plugin, you can list all top-level names under a single prefix. So in your plugin if you did a list on foobar, it would return the array ['name1', 'name2'] -- allowing you to easily iterate over the named components.

Commands

  • set <varname> <value>

This will set the variable name <varname> to the value <value>. See the note above about variable name scoping. There are several supported value types:

  1. Strings. To explicitly set a string, wrap value in double-quotes ("). For example: "myvalue".
  2. Integers. To set an integer simply specify a whole number. For example: 345.
  3. Floats. To set a float, simply specify a number with a decimal point. For example: 23.3.
  4. Ruby eval. If the value does not parse as a string, integer nor float, then twke will attempt to evaluate the string. This allows you to set a value to an array, like: [1, 2, 3] or a hash, like: {'hi' => 'bye'}. If twke fails to evaluate the value, then it will simply use the value as a string. It is recommended that strings be set explicitly using #1.
  • get <varname>

Will print the value of <varname>.

  • list <prefix>

Will print an array of values that have the dot-notation prefix <prefix>.

Configuration Storage

All mutations (sets) are atomically committed to a YAML configuration file under the home directory and are loaded at startup time. Changes to the configuration are saved immediately, so there is no risk of losing state if twke crashes.

Accessing configs from plugins

Plugins can use similar methods of the Twke::Conf module to access variables.

Clone this wiki locally