modules/doctor.php
author Dan
Sat, 25 Oct 2008 20:24:31 +0000
changeset 18 07be890ef627
parent 8 0acb8d9a3194
child 24 6fa9346a9bdc
permissions -rw-r--r--
Minor fix to snippets web iface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     1
<?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     2
require('eliza.php');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     3
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
eb_hook('event_channel_msg', 'doctor_listen($chan, $message);');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
eb_hook('snippet_dynamic', 'if ( $snippet === "doctor" ) return doctor_go($chan, $message, $snippet);');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
eb_hook('event_greeting', 'doctor_greet($append);');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
function doctor_go(&$chan, &$message, &$snippet)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
  global $doctor;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
  if ( $snippet == 'doctor' )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
    if ( isset($doctor[$message['nick']]) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
      unset($doctor[$message['nick']]);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
      $chan->msg(eb_censor_words("{$message['nick']}, thank you for visiting the psychotherapist. Come again soon!"), true);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    20
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
      $doctor[$message['nick']] = new Psychotherapist();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
      $chan->msg(eb_censor_words("{$message['nick']}, I am the psychotherapist. Please explain your problems to me. When you are finished talking with me, type !doctor again."), true);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
    return true;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
}
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
function doctor_listen(&$chan, &$message)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    29
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
  global $doctor;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
  if ( isset($doctor[$message['nick']]) && $message['message'] != '!doctor' )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
    $chan->msg(eb_censor_words($doctor[$message['nick']]->listen($message['message'])));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    36
}
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    37
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    38
function doctor_greet(&$append)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    39
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    40
  $append .= ' Type !doctor for the psychotherapist.';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    41
}