3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 10:59:29 +01:00
pbot/doc/Commands.md
2020-01-22 14:57:48 -08:00

12 KiB
Raw Blame History

Commands

Command interpreter

PBot has a powerful command interpreter with useful functionality.

Piping

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

Substitution

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

Chaining

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

Variables

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, which can be chained to combine their effects.

<pragma-> !echo $greeting:uc
   <PBot> HELLO, WORLD

Inline invocation

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

There are several ways of adding new commands to PBot. Well go over them here.

Built-in commands

Built-in commands are commands that are internal and native to PBot. They are executed within PBots 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 PBots source code. The owner of the PBot instance can add new commands by editing PBots source code or by acquiring and loading Plugins.

  • only bot owner can create new built-in commands
  • built-in commands have access to PBot internal API functions and data structures

Plugins

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.

  • only bot owner can install and load PBot Plugins
  • PBot Plugins have access to PBot internal API functions and data structures

Factoids

Factoids are another type of command. Factoids are simple text commands which anybody can create. In their most basic form, they simply display their text when invoked. However, significantly more complex Factoids can be created by using the powerful interpreter features and by using the even more powerful /code Factoid command.

  • anybody can create Factoids
  • Factoids do not have access to PBot internal API functions and data structures

For more information, see the Factoids documentations.

Code Factoids

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 argument following the /code command.

  • anybody can create Code Factoids
  • Code Factoids do not have access to PBot internal API functions and data structures

For more information, see the Code Factoid documentation.

Modules

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.

  • only bot owner can install new command-line modules
  • Modules do not have access to PBot internal API functions and data structures

For more information, see the Modules documentation.

Commands documented here

These are the commands documented in this file. For commands documented in other files see the PBot documentation.

There is also a list of of commands and links to their documentation in the Commands documented elsewhere section in this file.

version

The version command displays the currently installed PBot revision and revision date. It will also check to see if there is a new version available.

<pragma-> !version
   <PBot> PBot version 2845 2020-01-19; new version available: 2850 2020-01-20!

help

The help command displays useful information about built-in commands and Factoids.

Usage: help [keyword] [channel]

uptime

The uptime command displays the date and time your instance of PBot was started and how long it has been running.

<pragma-> !uptime
   <PBot> Tue Jan 14 01:55:40 2020 [8 days and 13 hours]

Commands documented elsewhere

Administrative commands

Logging in and out of PBot

login
logout

Admin management commands

adminadd
adminrem
adminset
adminunset
list admins

Channel management commands

join
part
chanadd
chanrem
chanset
chanunset
chanlist
ignore
unignore
whitelist
blacklist
op
deop
voice
devoice
mode
ban/mute
unban/unmute
invite
kick

Module management commands

load
unload
list modules

Plugin management commands

plug
unplug
replug
pluglist

Command metadata

cmdset
cmdunset

Registry commands

regset
regunset
regchange
regshow
regfind
regsetmeta
regunsetmeta

Miscellaneous admin commands

export
refresh
reload
sl
die

Factoid commands

Adding/removing factoids

factadd
factrem
factalias

Displaying factoids

fact
factshow

Editing factoids

factchange
factmove
factundo
factredo

Factoid metadata

factset
factunset

Information about factoids

factfind
factinfo
factlog
count
histogram
top20