Shortcuts

From Bebot Wiki 2
Jump to navigationJump to search
Introduction

The central shortcut database allows using the easy use of shortcuts for long descriptions in modules, as well as returning the corresponding long descriptions for shortcuts. The table storing the shortcuts is per default shared among all bots in the same database. The module ShortCutsGUI.php offers an interface to store new entries and delete existing entries in the cache.

Using shortcuts in modules

The shortcuts core offers several functions to access and edit the shortcut database. All the functions ignore the cases of shortcuts and long descriptions. Any array returned is a BeBot Standard Return Array.

 * //$this -> bot -> shortcuts -> get_short($long)// returns any existing shortcut for the long description. If no shortcut is yet defined it returns //$long// unmodified back.
 * //$this -> bot -> shortcuts -> get_long($short)// returns any existing long description of //$short//. If no description is in the database it returns //$short// unmodified back.
 * //$this -> bot -> shortcuts -> add($short, $long)// adds a new entry to the cache as long as neither //$short// nor //$long// are in the database yet. This function returns an array.
 * //$this -> bot -> shortcuts -> delete_shortcut($short)// removes the long description to //$short// as well as the shortcut if it exists. This function returns an array.
 * //$this -> bot -> shortcuts -> delete_description($long)// removes the shortcut to //$long// as well as the long description if it exists. This function returns an array.
 * //$this -> bot -> shortcuts -> delete_id($id)// removes the shortcut and long description indexed by //$id// if it exists. This function returns an array.