Bfbot

From Esolang
Jump to navigation Jump to search

bfbot is an IRC bot written by User:Palaiologos.

bfbot is capable of executing brainfuck (asm2bf, gisa and tiny-c support will be added later on). It's possible to define commands using these languages. The additions are permanent. The default prefix is =.

help

Help displays generic information about the bot and commands. It's redirecting users to this page.

str

If you want to define a long command that won't fit into a single IRC message, you can use the =str command. You have 10 temporary buffers available. To set contents of a buffer, use =str as follows:

<kspalaiologos> =str 0s Hello
<bfbot> ok

Contents of buffer 0 will be set to "Hello". "ok" response means write succeeded. If you want to clear a buffer, use d flag:

<kspalaiologos> =str 9d
<bfbot> ok

Now buffer is empty. There is one very important flag - a. For example:

<kspalaiologos> =str 0s Hello
<bfbot> ok
<kspalaiologos> =str 0a World!
<bfbot> ok

The following conversation with bot will result in buffer 0 content's be equal to "Hello World!". As you can observe, it's quite straightforward.

Let's sum things up:

  • buffer is a temporary storage unit, at most 65 kilobytes big, storing temporary data.
  • to set buffer data use s flag with the buffer ID before it, eg. =set 0s abc
  • to clear buffer use d flag, eg. =set 0d
  • to append data to a buffer, use a flag, eg. =set 0a test
  • you may use buffers to define a command.
  • after you are done, it's a gentleman's rule to clear the buffer so it doesn't clog up space.

def

If you want to define your own, first class command, you have to use =def. Let's look at a very straightforward example. We will define our very own echo command.

<kspalaiologos> =str 0s ,[.,]
<bfbot> ok
<kspalaiologos> =def 0echo
<bfbot> ok, defined 'echo'
<kspalaiologos> =echo greetings
<bfbot> greetings

A lot of stuff is covered here. First we set up a buffer, then we use def with a buffer ID and the name (note, it has to be maximum 16 characters long). The outcome is a first-class, non-overriding (you can't override builtins) function. The function may take at most 5 seconds and 128 memory cells to run.

undef

Want to remove a user-defined function? Just use undef:

<kspalaiologos> =echo abc
<bfbot> abc
<kspalaiologos> =undef echo
<bfbot> ok
<kspalaiologos> =echo greetings
<bfbot> No such command.

list

If you need to list all user-defined commands, you may use list. For example:

<kspalaiologos> =list
<bfbot> echo msg1 prog1 prog2 prog3

You can use additional parameter to filter the search result:

<kspalaiologos> =list prog
<bfbot> prog1 prog2 prog3

You can list commands in pages too, using plist:

<kspalaiologos> =plist 0
<bfbot> echo msg1 prog1 prog2 prog3

The second argument is page number. Commands are grouped 25-30 each page.

doc

The only form of writable and readable persistent memory. It's used to store stuff about various user-defined commands. To read and write a documentation string:

Write:
<kspalaiologos> =doc echo Example
<bfbot> ok.

Read:
<kspalaiologos> =doc echo
<bfbot> echo: Example

program types

Type 0: 8bit cells, integer i/o
Type 1: 32bit cells, integer i/o
Type 2: 16bit cells, integer i/o
Type 3: 8bit cells
Type 4: 32bit cells
Type 5: 16bit cells

To set the program type, enter the digit first by prepending a digit at the front.