pbot/doc/Commands.md

296 lines
9.3 KiB
Markdown
Raw Normal View History

2020-01-21 08:07:08 +01:00
# Commands
<!-- md-toc-begin -->
2020-01-21 20:35:57 +01:00
* [Command interpreter](#command-interpreter)
* [Piping](#piping)
* [Substitution](#substitution)
* [Chaining](#chaining)
* [Variables](#variables)
* [Inline invocation](#inline-invocation)
2020-01-21 08:07:08 +01:00
* [Types of commands](#types-of-commands)
* [Built-in commands](#built-in-commands)
2020-01-21 20:35:57 +01:00
* [Creating new built-in commands](#creating-new-built-in-commands)
2020-01-21 08:07:08 +01:00
* [Plugins](#plugins)
* [Factoids](#factoids)
* [Code Factoids](#code-factoids)
* [Modules](#modules)
* [Command documentation](#command-documentation)
* [Administrative commands](#administrative-commands)
2020-01-21 20:35:57 +01:00
* [Logging in and out of PBot](#logging-in-and-out-of-pbot)
2020-01-21 20:49:45 +01:00
* [login](#login)
* [logout](#logout)
2020-01-21 20:35:57 +01:00
* [Admin management commands](#admin-management-commands)
2020-01-21 20:49:45 +01:00
* [adminadd](#adminadd)
* [adminrem](#adminrem)
* [adminset](#adminset)
* [adminunset](#adminunset)
* [list admins](#list-admins)
2020-01-21 20:35:57 +01:00
* [Channel management commands](#channel-management-commands)
2020-01-21 20:49:45 +01:00
* [join](#join)
* [part](#part)
* [chanadd](#chanadd)
* [chanrem](#chanrem)
* [chanset](#chanset)
* [chanunset](#chanunset)
* [chanlist](#chanlist)
2020-01-21 20:35:57 +01:00
* [Module management commands](#module-management-commands)
2020-01-21 20:49:45 +01:00
* [load](#load)
* [unload](#unload)
* [list modules](#list-modules)
2020-01-21 20:35:57 +01:00
* [Plugin management commands](#plugin-management-commands)
2020-01-21 20:49:45 +01:00
* [plug](#plug)
* [unplug](#unplug)
* [pluglist](#pluglist)
* [Command metadata commands](#command-metadata-commands)
* [cmdset](#cmdset)
* [cmdunset](#cmdunset)
2020-01-21 20:35:57 +01:00
* [Registry commands](#registry-commands)
2020-01-21 20:49:45 +01:00
* [regset](#regset)
* [regunset](#regunset)
* [regchange](#regchange)
* [regshow](#regshow)
* [regfind](#regfind)
* [regsetmeta](#regsetmeta)
* [regunsetmeta](#regunsetmeta)
2020-01-21 20:35:57 +01:00
* [Miscellaneous admin commands](#miscellaneous-admin-commands)
2020-01-21 20:49:45 +01:00
* [export](#export)
* [refresh](#refresh)
* [reload](#reload)
* [sl](#sl)
* [die](#die)
2020-01-21 20:35:57 +01:00
* [Factoid commands](#factoid-commands)
2020-01-21 21:10:29 +01:00
* [Adding/remove factoids](#addingremove-factoids)
* [factadd](#factadd)
* [factrem](#factrem)
* [factalias](#factalias)
* [Displaying factoids](#displaying-factoids)
* [fact](#fact)
* [factshow](#factshow)
* [Editing factoids](#editing-factoids)
* [factchange](#factchange)
* [factmove](#factmove)
* [factundo](#factundo)
* [factredo](#factredo)
* [factset](#factset)
* [factunset](#factunset)
* [Information about factoids](#information-about-factoids)
* [factlog](#factlog)
* [factfind](#factfind)
* [factinfo](#factinfo)
* [count](#count)
* [histogram](#histogram)
* [top20](#top20)
2020-01-21 08:07:08 +01:00
* [Miscellaneous commands](#miscellaneous-commands)
<!-- md-toc-end -->
2020-01-21 20:35:57 +01:00
## Command interpreter
2020-01-21 08:07:08 +01:00
2020-01-21 20:35:57 +01:00
PBot has a powerful command interpreter with useful functionality.
2020-01-21 08:07:08 +01:00
2020-01-21 20:35:57 +01:00
### Piping
2020-01-21 08:07:08 +01:00
You can pipe output from one command as input into another command, indefinitely.
<pragma-> !echo hello world | {sed s/world/everybody/} | {uc}
<PBot> HELLO EVERYBODY
2020-01-21 20:35:57 +01:00
### Substitution
2020-01-21 08:07:08 +01:00
You can insert the output from another command at any point within a command. This
substitutes the command with its output at the point where the command was used.
<pragma-> !echo This is &{echo a demonstration} of command substitution
<PBot> This is a demonstration of command substitution
For example, suppose you want to make a Google Image Search command. The naive
way would be to simply do:
<pragma-> !factadd img /call echo https://google.com/search?tbm=isch&q=$args
Unfortuately this would not support queries containing spaces or certain symbols. But
never fear! We can use command substitution and the `uri_escape` function from the
`func` command.
Note that you must escape the command substitution to insert it literally into the
factoid otherwise it will be expanded first.
<pragma-> !factadd img /call echo https://google.com/search?tbm=isch&q=\&{func uri_escape $args}
<pragma-> !img spaces & stuff
<PBot> https://google.com/search?tbm=isch&q=spaces%20%26%20stuff
2020-01-21 20:35:57 +01:00
### Chaining
2020-01-21 08:07:08 +01:00
You can execute multiple commands sequentially as one command.
<pragma-> !echo Test! ;;; me smiles. ;;; version
<PBot> Test! * PBot smiles. PBot version 2696 2020-01-04
2020-01-21 20:35:57 +01:00
### Variables
2020-01-21 08:07:08 +01:00
You can use factoids as variables and interpolate them within commands.
<pragma-> !factadd greeting "Hello, world"
<pragma-> !echo greeting is $greeting
<PBot> greeting is Hello, world
PBot variable interpolation supports [expansion modifiers](doc/Factoids.md#expansion-modifiers), which can be chained to
combine their effects.
<pragma-> !echo $greeting:uc
<PBot> HELLO, WORLD
2020-01-21 20:35:57 +01:00
### Inline invocation
2020-01-21 08:07:08 +01:00
You can invoke up to three commands inlined within a message. If the message
is addressed to a nick, the output will also be addressed to them.
<pragma-> newuser13: Check the !{version} and the !{help} documentation.
<PBot> newuser13: PBot version 2696 2020-01-04
<PBot> newuser13: To learn all about me, see https://github.com/pragma-/pbot/tree/master/doc
## Types of commands
2020-01-21 20:35:57 +01:00
There are several ways of adding new commands to PBot. We'll go over them here.
2020-01-21 08:07:08 +01:00
### Built-in commands
2020-01-21 20:35:57 +01:00
Built-in commands are commands that are internal and native to PBot. They are
executed within PBot's API and context. They have access to PBot internal
subroutine and data structures.
#### Creating new built-in commands
Built-in commands are created via the `register()` function of the `Commands`
module. Such commands are registered throughout PBot's source code. The owner
of the PBot instance can locally add new commands by editing PBot's source code
2020-01-21 20:49:45 +01:00
or by acquiring and loading Plugins.
2020-01-21 20:35:57 +01:00
2020-01-21 08:07:08 +01:00
#### Plugins
2020-01-21 20:35:57 +01:00
Additional built-in commands can be created by loading PBot Plugins. Plugins are
stand-alone self-contained units of code that can be loaded by the PBot owner.
Plugins have access to PBot's internal APIs and data structures.
2020-01-21 08:07:08 +01:00
### Factoids
2020-01-21 20:35:57 +01:00
Factoids are another type of command. Factoids are simple textual strings that
2020-01-21 20:49:45 +01:00
anybody can create. At their most simple, they display their text when invoked.
However, significantly more complex Factoids can be created by using the powerful
interpreter and by using the even more powerful `/code` Factoid command.
2020-01-21 20:35:57 +01:00
Factoids do not have access to PBot's internal API or data structures.
2020-01-21 08:07:08 +01:00
#### Code Factoids
2020-01-21 20:49:45 +01:00
Code Factoids are Factoids whose text begins with the `/code` command.
These Factoids will execute their text using the scripting or programming
language specified by the `/code` command.
2020-01-21 20:35:57 +01:00
Code Factoids do not have access to PBot's internal API or data structures.
2020-01-21 08:07:08 +01:00
#### Modules
2020-01-21 20:35:57 +01:00
Modules are simple stand-alone external command-line scripts and programs. Just
about any application that can be run in your command-line shell can be loaded as
a PBot module.
Modules do not have access to PBot's internal API or data structures.
2020-01-21 08:07:08 +01:00
## Command documentation
2020-01-21 20:35:57 +01:00
Here is the documentation for all of PBot's commands.
2020-01-21 08:07:08 +01:00
### Administrative commands
2020-01-21 20:35:57 +01:00
#### Logging in and out of PBot
2020-01-21 21:43:07 +01:00
##### [login](Admin.md#login)
##### [logout](Admin.md#logout)
2020-01-21 20:49:45 +01:00
2020-01-21 20:35:57 +01:00
#### Admin management commands
2020-01-21 21:43:07 +01:00
##### [adminadd](Admin.md#adminadd)
##### [adminrem](Admin.md#adminrem)
##### [adminset](Admin.md#adminset)
##### [adminunset](Admin.md#adminunset)
##### [list admins](Admin.md#listing-admins)
2020-01-21 20:49:45 +01:00
2020-01-21 20:35:57 +01:00
#### Channel management commands
2020-01-21 21:43:07 +01:00
##### [join](Admin.md#join)
##### [part](Admin.md#part)
##### [chanadd](Admin.md#chanadd)
##### [chanrem](Admin.md#chanrem)
##### [chanset](Admin.md#chanset)
##### [chanunset](Admin.md#chanunset)
##### [chanlist](Admin.md#chanlist)
2020-01-21 20:49:45 +01:00
2020-01-21 20:35:57 +01:00
#### Module management commands
2020-01-21 21:43:07 +01:00
##### [load](Admin.md#load)
##### [unload](Admin.md#unload)
##### [list modules](Admin.md#listing-modules)
2020-01-21 20:49:45 +01:00
2020-01-21 20:35:57 +01:00
#### Plugin management commands
2020-01-21 21:43:07 +01:00
##### [plug](Admin.md#plug)
##### [unplug](Admin.md#unplug)
##### [pluglist](Admin.md#pluglist)
2020-01-21 20:35:57 +01:00
2020-01-21 20:49:45 +01:00
#### Command metadata commands
2020-01-21 20:35:57 +01:00
2020-01-21 21:43:07 +01:00
##### [cmdset](Admin.md#cmdset)
##### [cmdunset](Admin.md#cmdunset)
2020-01-21 20:35:57 +01:00
2020-01-21 20:49:45 +01:00
#### Registry commands
2020-01-21 20:35:57 +01:00
2020-01-21 21:10:29 +01:00
##### [regset](Registry.md#regset)
##### [regunset](Registry.md#regunset)
##### [regchange](Registry.md#regchange)
##### [regshow](Registry.md#regshow)
##### [regfind](Registry.md#regfind)
##### [regsetmeta](Registry.md#regsetmeta)
##### [regunsetmeta](Registry.md#regunsetmeta)
2020-01-21 20:35:57 +01:00
2020-01-21 20:49:45 +01:00
#### Miscellaneous admin commands
2020-01-21 20:35:57 +01:00
2020-01-21 21:10:29 +01:00
##### [export](Admin.md#export)
##### [refresh](Admin.md#refresh])
##### [reload](Admin.md#reload])
##### [sl](Admin.md#sl)
##### [die](Admin.md#die)
2020-01-21 20:35:57 +01:00
2020-01-21 20:49:45 +01:00
### Factoid commands
2020-01-21 20:35:57 +01:00
2020-01-21 21:10:29 +01:00
#### Adding/remove factoids
##### [factadd](Factoids.md#factadd)
2020-01-21 21:43:07 +01:00
##### [factrem](Factoids.md#factrem)
##### [factalias](Admin.md#factalias)
2020-01-21 21:10:29 +01:00
#### Displaying factoids
##### [fact](Factoids.md#fact)
##### [factshow](Factoids.md#factshow)
#### Editing factoids
2020-01-21 21:43:07 +01:00
##### [factchange](Admin.md#factchange)
##### [factmove](Admin.md#factmove)
##### [factundo](Admin.md#factundo)
##### [factredo](Admin.md#factredo)
##### [factset](Admin.md#factset)
##### [factunset](Admin.md#factunset)
2020-01-21 21:10:29 +01:00
#### Information about factoids
2020-01-21 21:43:07 +01:00
##### [factlog](Admin.md#factlog)
##### [factfind](Admin.md#factfind)
##### [factinfo](Admin.md#factinfo)
##### [count](Admin.md#count)
##### [histogram](Admin.md#histogram)
##### [top20](Admin.md#top20)
2020-01-21 08:07:08 +01:00
### Miscellaneous commands