8
+ − 1
<?php
+ − 2
require('eliza.php');
+ − 3
+ − 4
eb_hook('event_channel_msg', 'doctor_listen($chan, $message);');
+ − 5
eb_hook('snippet_dynamic', 'if ( $snippet === "doctor" ) return doctor_go($chan, $message, $snippet);');
+ − 6
eb_hook('event_greeting', 'doctor_greet($append);');
+ − 7
+ − 8
function doctor_go(&$chan, &$message, &$snippet)
+ − 9
{
+ − 10
global $doctor;
+ − 11
+ − 12
if ( $snippet == 'doctor' )
+ − 13
{
+ − 14
if ( isset($doctor[$message['nick']]) )
+ − 15
{
+ − 16
unset($doctor[$message['nick']]);
+ − 17
$chan->msg(eb_censor_words("{$message['nick']}, thank you for visiting the psychotherapist. Come again soon!"), true);
+ − 18
}
+ − 19
else
+ − 20
{
+ − 21
$doctor[$message['nick']] = new Psychotherapist();
+ − 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);
+ − 23
}
+ − 24
return true;
+ − 25
}
+ − 26
}
+ − 27
+ − 28
function doctor_listen(&$chan, &$message)
+ − 29
{
+ − 30
global $doctor;
+ − 31
+ − 32
if ( isset($doctor[$message['nick']]) && $message['message'] != '!doctor' )
+ − 33
{
+ − 34
$chan->msg(eb_censor_words($doctor[$message['nick']]->listen($message['message'])));
+ − 35
}
+ − 36
}
+ − 37
+ − 38
function doctor_greet(&$append)
+ − 39
{
+ − 40
$append .= ' Type !doctor for the psychotherapist.';
+ − 41
}