-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·70 lines (45 loc) · 1.44 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*******************************************************************************
An example HTML interface to the JxBot programmers API
Customise this webpage or make your own.
*******************************************************************************/
/* include the JxBot client API */
require_once(dirname(__FILE__) . '/jxbot/core/client.php');
/* initalize the client API */
JxBotClient::init();
/* start/resume a conversation using a cookie */
JxBotClient::resume_conversation();
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bot</title>
</head>
<body>
<?php /* check if the bot is actually online and not down for maintenance */
if (JxBotClient::is_available()) {
?>
<form method="post" action="">
<!-- BOT OUTPUT: -->
<div id="bot-output"><?php
/* generate the bot response to the user-input;
or an appropriate greeting if the page has just loaded */
if (isset($_REQUEST['input']))
print JxBotClient::respond($_REQUEST['input']);
else
print JxBotClient::respond(null);
?></div>
<!-- USER INPUT: -->
<p><input type="text" name="input" id="user-input" size="100" autofocus></p>
<p><input type="submit" id="user-submit" value="Say"></p>
</form>
<?php
} else { /* the bot is offline for maintenance: */
?>
<!-- MAINTENANCE MESSAGE -->
<h1>Bot Not Available</h1>
<p>Sorry, the chat bot is not currently available and is down for maintenance.</p>
<p>Please check back again later!</p>
<?php } ?>
</body>
</html>