3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 04:19:27 +01:00
Go to file
2020-02-06 04:01:41 -08:00
build License project under MPL2 2017-03-06 00:31:15 +00:00
data data/factoids: add users alias 2020-02-03 22:02:31 -08:00
doc doc/Admin.md: document new capabilities 2020-02-05 17:39:12 -08:00
misc misc/git-md-toc: improvent indentation of TOC 2020-01-21 18:08:05 -08:00
modules modules: remove some outdated modules 2020-02-01 14:33:42 -08:00
PBot Interpreter: minor bugfix 2020-02-06 04:01:41 -08:00
Plugins Remove unnecessary use of delete keyword 2020-02-06 01:14:08 -08:00
.gitattributes Tell GitHub not to run linguist on modules/ 2020-01-10 00:07:50 -08:00
.gitignore update .gitignores 2020-01-31 15:39:40 -08:00
LICENSE License project under MPL2 2017-03-06 00:31:15 +00:00
MODULES WebPaste: use LWP::UserAgent::Paranoid for stricter timeout 2020-02-03 09:46:44 -08:00
pbot pbot: remove file header 2020-01-10 10:20:19 -08:00
README.md docs: minor improvements 2020-02-04 20:49:56 -08:00

PBot

PBot is a versatile IRC Bot written in Perl

Installation / Quick Start

To get up-and-running quickly, check out the Quick Start guide.

Features

Commands

PBot has several useful built-in commands. Additional commands can be added to PBot through Factoids, Plugins and Modules.

For more information, see the Commands documentation.

Powerful command interpreter

PBot has an 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

Factoids

Factoids are a very special type of command. Anybody interacting with PBot can create, edit, delete and invoke factoids. Factoids can be locked by the creator of the factoid to prevent them from being edited by others.

At its most simple, a factoid merely displays the text the creator sets.

<pragma-> !factadd hello /say Hello, $nick!
   <PBot> hello added to global channel.

<pragma-> PBot, hello
   <PBot> Hello, pragma-!

Significantly more complex factoids can be built by using $variables, command-substitution, command-piping, /code invocation, and more!

PBot factoids include these advanced features:

For more information, see the Factoids documentation.

Code Factoids

Code Factoids are a special type of factoid that begin with the /code command.

/code <language> <code>

Thats right! Anybody can create a factoid that can execute arbitrary code in any language! This is one of PBots most powerful features.

How is this safe? Because the code is executed within a virtual machine that has been configured to fall-back to a previously saved state whenever it times out.

For example, the venerable rot13 function:

<pragma-> !factadd rot13 /code sh echo "$@" | tr a-zA-Z n-za-mN-ZA-M
   <PBot> rot13 added to global channel.

<pragma-> !rot13 Pretty neat, huh?
   <PBot> Cerggl arng, uhu?

You can pipe output from other commands to Code Factoids.

<pragma-> !echo test | {rot13}
   <PBot> grfg

For more information, see the Code Factoid documentation.

Plugins

PBot can dynamically load and unload Perl modules to alter its behavior.

These are some of the plugins that PBot has; there are many more:

Plugin Description
GoogleSearch Performs Internet searches using the Google search engine.
UrlTitles When a URL is seen in a channel, intelligently display its title. It will not display titles that are textually similiar to the URL, in order to maintain the channel signal-noise ratio.
Quotegrabs Grabs channel messages as quotes for posterity. Can grab messages from anywhere in the channel history. Can grab multiple messages at once!
Weather Fetches and shows weather data for a location.
Wttr Advanced weather Plugin with tons of options. Uses wttr.in.
RemindMe Lets people set up reminders. Lots of options.
ActionTrigger Lets admins set regular expression triggers to execute PBot commands or factoids.
AntiAway Detects when a person uses annoying in-channel away messages and warns them.
AutoRejoin Automatically rejoin channels if kicked or removed.
AntiNickSpam Detects when a person is spamming an excessive number of nicks in the channel and removes them.
AntiRepeat Warn people about excessively repeating messages. Kicks if they fail to heed warnings.
AntiTwitter Warn people about addressing others with @<nick>. Kicks if they fail to heed warnings.
Date Displays date and time for a timezone.

There are even a few games!

Plugin Description
Spinach An advanced multiplayer Trivia game engine with a twist! A question is shown. Everybody privately submits a false answer. All false answers and the true answer is shown. Everybody tries to guess the true answer. Points are gained when people pick your false answer!
Battleship The classic Battleship board game, simplified for IRC
Connect4 The classic Connect-4 game.

Modules

Modules are external command-line executable programs and scripts that can be loaded as PBot commands.

Suppose you have the Qalculate! command-line program and you want to provide a PBot command for it. You can create a very simple shell script containing:

#!/bin/sh
qalc "$*"

And lets call it qalc.sh and put it in PBots modules/ directory.

Then you can load it with the load command.

!load qalc qalc.sh

Now you have a Qalculate! calculator in PBot!

<pragma-> !qalc 2 * 2
   <PBot> 2 * 2 = 4

These are just some of the modules PBot comes with; there are several more:

Module Description
C-to-English translator Translates C code to natural English sentences.
C precedence analyzer Adds parentheses to C code to demonstrate precedence.
C Jeopardy! game C programming trivia game based on the Jeopardy! TV game show.
C Standard citations Cite specified sections/paragraphs from the C standard.
Virtual machine Executes arbitrary code and commands within a virtual machine.
dict.org Dictionary Interface to dict.org for definitions, translations, acronyms, etc.
Urban Dictionary Search Urban Dictionary for definitions.
Manpages Display a concise formatting of manual pages (designed for C functions)

For more information, see the Modules documentation.

Virtual machine

PBot can integrate with a virtual machine to safely execute arbitrary user-submitted operating system commands or code.

PBot supports several shells and languages out of the box!

<pragma-> !sh echo Remember rot13? | tr a-zA-Z n-za-mN-ZA-M
   <PBot> Erzrzore ebg13?
    <nil> !go package main\nimport "fmt"\nfunc main() { fmt.Print("foo" == "foo"); }
   <PBot> true
<pragma-> !python print('Hello there!')
   <PBot> Hello there!

PBot has extensive support for the C programming language. For instance, the C programming language plugin is integrated with the GNU Debugger. It will print useful debugging information.

<pragma-> !cc char *p = 0; *p = 1;
   <PBot> runtime error: store to null pointer of type 'char'
          Program received signal SIGSEGV, Segmentation fault at
          statement: *p = 1; <local variables: p = 0x0>

It can display the value of the most recent statement if there is no program output.

<pragma-> !cc sizeof (int)
   <PBot> no output: sizeof(int) = 4

For more information about the C programming language plugin, see the cc command in the Modules documentation.

For more information about the virtual machine, see the Virtual Machine documentation.

Useful IRC command improvements

  • mode command can take wildcards, e.g. mode +ov foo* bar* to op nicks beginning with foo and voice nicks beginning with bar
  • unban <nick> and unmute <nick> can remove all bans/mutes matching <nick>s hostmask or account
  • ban and mute will intelligently set banmasks; supports timeouts
  • ban and mute can take a comma-separate list of nicks. Will intelligently group them into multiple MODE +bbbb commands
  • kick can take a comma-separated list of nicks; also accepts wildcards
  • and much, much more!

Channel management

PBot can perform the typical channel management tasks.

  • opping/deopping, etc
  • channel-mode tracking
  • user hostmask/alias tracking
  • ban-evasion detection
  • flood detection
  • whitelisting, blacklisting, etc
  • spam/advertisement detection
  • and much, much more!

For more information, see the Channels documentation and the Anti-abuse documentation

User management

PBot has easy straightforward user management via simple built-in commands.

  • user capabilities dictate what users can and cannot do
  • user accounts can be global or channel-specific
  • users can be recognized by hostmask or required to login with password
  • users can adjust their user-metadata with the my command
  • and much, much more!

For more information, see the Admin documentation.

Easy configuration

PBots settings are contained in a central registry of key/value pairs grouped by sections.

These settings can easily be configured via several methods:

For more information, see the Registry documentation.

Documentation

See the PBot documentation for more information.

Frequently Asked Questions

If you have a question, try the PBot FAQ!

Support

For additional questions and support, feel free to join the #pbot2 channel on the Freenode IRC network (Web Chat).

License

PBot is licensed under the Mozilla Public License, version 2.