Update Plang documentation

This commit is contained in:
Pragmatic Software 2020-07-23 12:37:34 -07:00
parent 294f9453b0
commit 65624cfcba
1 changed files with 18 additions and 21 deletions

View File

@ -2,22 +2,21 @@
<!-- md-toc-begin --> <!-- md-toc-begin -->
* [About](#about) * [About](#about)
* [The Plang Language](#the-plang-language) * [The Plang Language](#the-plang-language)
* [PBot `plang` and `plangrepl` commands](#pbot-plang-and-plangrepl-commands) * [`plang` command](#plang-command)
* [`plang`](#plang-1) * [`plangrepl` command](#plangrepl-command)
* [`plangrepl`](#plangrepl) * [PBot built-in Plang functions](#pbot-built-in-plang-functions)
* [PBot built-in Plang functions](#pbot-built-in-plang-functions) * [factget](#factget)
* [factget](#factget) * [factset](#factset)
* [factset](#factset) * [factappend](#factappend)
* [factappend](#factappend) * [userget](#userget)
* [userget](#userget)
<!-- md-toc-end --> <!-- md-toc-end -->
## About ## About
This Plang plugin provides a scripting interface to PBot. It has access to PBot This Plang plugin provides a scripting interface to PBot. It has access to PBot
internal APIs and state. internal APIs and state.
### The Plang Language ## The Plang Language
The scripting language is [Plang](https://github.com/pragma-/Plang). It was The scripting language is [Plang](https://github.com/pragma-/Plang). It was
written specifically for PBot, but is powerful enough to be used as a general-purpose written specifically for PBot, but is powerful enough to be used as a general-purpose
scripting language embedded into any Perl application. scripting language embedded into any Perl application.
@ -25,21 +24,20 @@ scripting language embedded into any Perl application.
This document describes PBot's Plang plugin. To learn how to use the Plang scripting This document describes PBot's Plang plugin. To learn how to use the Plang scripting
language, see the [Plang documentation](https://github.com/pragma-/Plang/blob/master/README.md). language, see the [Plang documentation](https://github.com/pragma-/Plang/blob/master/README.md).
### PBot `plang` and `plangrepl` commands ## `plang` command
#### `plang`
Use the `plang` command to run a Plang script. Use the `plang` command to run a Plang script.
Usage: `plang <code>` Usage: `plang <code>`
#### `plangrepl` ## `plangrepl` command
The `plangrepl` command is identical to the `plang` command, except the environment The `plangrepl` command is identical to the `plang` command, except the environment
is preserved in-between commands and the types of values is output along with the value. is preserved in-between commands and the types of values is output along with the value.
### PBot built-in Plang functions ## PBot built-in Plang functions
[Plang](https://github.com/pragma-/Plang) lets you add custom built-in functions. We [Plang](https://github.com/pragma-/Plang) lets you add custom built-in functions.
have added several for PBot. They are described here. Several have been added for PBot; they are described here.
#### factget ### factget
factget(channel, keyword, meta = "action") factget(channel, keyword, meta = "action")
Use the `factget` function to retrieve metadata from factoids. Use the `factget` function to retrieve metadata from factoids.
@ -49,7 +47,7 @@ parameter can be omitted and will default to `"action"`.
The `factget` function returns a `String` containing the value of the factoid metadata key. The `factget` function returns a `String` containing the value of the factoid metadata key.
#### factset ### factset
factset(channel, keyword, text) factset(channel, keyword, text)
Use the `factset` function to set the `action` metadata value for factoids. Use the `factset` function to set the `action` metadata value for factoids.
@ -58,7 +56,7 @@ The `factset` function takes three parameters: `channel`, `keyword` and `text`.
The `factset` function returns a `String` containing the value of `text`. The `factset` function returns a `String` containing the value of `text`.
#### factappend ### factappend
factappend(channel, keyword, text) factappend(channel, keyword, text)
Use the `factappend` function to append text to the `action` metadata for factoids. Use the `factappend` function to append text to the `action` metadata for factoids.
@ -68,7 +66,7 @@ The `factappend` function takes three parameters: `channel`, `keyword` and `text
The `factappend` function returns a `String` containing the value of factoid's `action` The `factappend` function returns a `String` containing the value of factoid's `action`
metadata with `text` appended. metadata with `text` appended.
#### userget ### userget
userget(name) userget(name)
Use the `userget` function to retrieve user metadata. Use the `userget` function to retrieve user metadata.
@ -87,4 +85,3 @@ Examples:
<pragma-> !plang userget('pragma-')['botowner'] <pragma-> !plang userget('pragma-')['botowner']
<PBot> 1 <PBot> 1