# -*- shell-script -*-
###############################################################################
# BASIC COMMANDS ##############################################################
###############################################################################

# help
TEACH ME WHAT I CAN DO >> HELP
WHAT CAN I DO\? >> HELP
WHERE DO I (START|BEGIN)\? >> HELP
HELP :: command 'help'
HELP\s+(.*) :: command 'help' '\1'

# quit
GET LOST >> SHUTDOWN
DIE >> SHUTDOWN
VA MOURIR >> SHUTDOWN
CYANIDE >> SHUTDOWN
SHUTDOWN :: command 'shutdown'

# start a plan
START PLAN ([\w\-_]+\.[\w\-_]+)\s*(\d+) >> START-PLAN \1 \2
START-PLAN ([\w\-_]+\.[\w\-_]+)\s* >> START-PLAN \1 0
START-PLAN ([\w\-_]+\.[\w\-_]+) (\d+)\s* :: command 'start_plan' '\1' \2

# reschedule plan
RESCHED\s+(CONF\s+)?(\d+)\s+([+-]?\d+)(\s*MIN(UTES)?)? >> RESCHEDULE \2 \3
RESCHEDULE\s+(CONF\s+)?(\d+)\s+([+-]?\d+)(\s*MIN(UTES)?)? :: command 'reschedule_plan' \2 '\3'

# introspection
#
# EXAMPLE SYNTAXE: inspect elmt.name == "qqch"
#
#          et le narval te dit ce qu'il a trouvé dans sa mémoire 
#          qui correspond à la condition que tu as enoncé
#          condition == même formulation que dans un al:match
INSPECT (.+) :: command 'introspect' '\1'
XINSPECT (.+) :: command 'introspect' '\1' 'xml'

# documentation generation
#
# EXAMPLE SYNTAXE: document etype='recipe' group='active-commands'
#
# will generate docbook documentation for matching elements (recipes in the 
# active-commands cookbook in this example
# You can also set the following attributes: lang, address, encoding
DOCUMENT (.+) :: command 'document' '\1'

# reload ail brain
RELOAD AIL BRAIN :: command 'chat_reload_ail_brain'

# jabber conf openning
SETUP CONF IN (\d+)\s*MIN(UTES)? IN ROOM (\w+) WITH (.*)\s*\.? >> SETUP CONF IN \1MIN \3 \4
CONF IN (\d+)\s*MIN(UTES)? (\w+)\s+(.*) >> SETUP CONF IN \1MIN \3 \4
SETUP CONF IN (\d+)\s*MIN(UTES)? (\w+)\s+(.*) :: command 'conf_setup_delayed' 'Chat.conf-setup' \1 'conf_setup' '\3' '\4'
CONF (\w+)\s+(.*) >> SETUP CONF \1 \2
SETUP CONF (\w+)\s+(.*) :: command 'conf_setup' '\1' '\2'
REUNION\s+AVEC\s+(.*) :: random 'Il faut preciser la salle. \nsyntaxe: setup conf room user1 user2'

# ask narval to leave discussion
(LEAVE THE FORUM|GO AWAY|SORT|DEGAGE|QUIT FORUM|DEGAGE DE) >> LEAVE
LEAVE(.*) :: command 'conf_leave' '\1'
#LEAVE (\w+@[\w+\.?]+)(.*) :: command 'conf_leave' '\1'

# add a user to roster
ADD (\w+) TO ROSTER >> SUBSCRIBE \1
SUBSCRIBE\s+(\w+) :: command 'chat_subscribe' '\1'

# fill asked template
FILL TEMPLATE (\w+) :: random 'you need to specify a filename'
FILL TEMPLATE (\w+) (.*) :: command 'fill_template' '\1' '\2'
# fill the foaf template
NEW FOAF\s*(\w+) :: command 'fill_template' 'foaf' '\1'

# when user will be back
WHEN WILL ([^\s]+) COME BACK\s*\? >> WHEN WILL \1 BE BACK?
WHEN WILL ([^\s]+) BE BACK\s*\? :: command 'guess_user_time_back' \1


# tell your master that
#
# when a master is no more available on jabber, other users may ask
# the master's narval to forward their message to him
TELL YOUR MASTER THAT\s+(.*)\s+VIA\s+(.*) :: command 'tell_master' '\1' '\2'
TELL YOUR MASTER THAT\s+(.*) :: command 'tell_master' '\1' 
