4 The chatbot API allows chatbots to interact in chatrooms as if they
5 were ordinary users. Potentially it could also be used in the future
6 to allow Java applets on the client to post and read messages.
8 Chatbots are designed to be written in a scripting language such as
9 perl with libwww-perl. The API has been designed so that the scripting
10 language doesn't necessarily have to be multi-threaded (to deal with
11 multiple chatrooms), although you could use a threaded language if
14 Another concern is that the API has been designed so that it shouldn't
15 drop messages, except under abnormally huge loads.
17 The API consists of a single shared object script, normally located at
18 http://server/so-bin/chatbot.so
20 The 'fn' parameter controls the function requested. This parameter is
21 mandatory, and the possible values are explained below.
23 Room and message identification
24 -------------------------------
26 Each room has a unique resource ID (resid).
28 Each message in a room has a unique message ID. At a particular point
29 in time, a room contains a window of continuous message IDs:
31 room contains: [ first_message . . . . . . . . last_message ]
33 The last_message is the most recently posted message.
35 The first_message ID is retrieved when you list all rooms (see
36 fn=rooms below). You can then retrieve this message using the fn=wait
37 function. To retrieve the next message, increment the message ID and
38 call fn=wait again, and so on until you reach the last message. At
39 this point, incrementing the message ID to last_message+1 and calling
40 fn=wait causes the CGI call to wait until another message is posted.
42 As you will see below, fn=wait also allows you to retrieve messages
43 across many different rooms.
48 Chatbots should send an authentication cookie. Currently, because of
49 the no-security implementation (see below), they should send the
53 value: chatbot's userid
55 Currently if no cookie is sent, the chatbot appears as an anonymous
56 user. In future we will be adding proper, secure cookies and an
57 authentication mechanism.
62 Error handling is through the normal HTTP mechanism so if you, for
63 example, request a room which doesn't exist, then you will get a 500
64 Internal Server Error, with an attached text/plain content section
65 containing the error message.
70 There is no security in the chat server at the present time.
78 Returns a list of the rooms available, one per line, in the following
81 resid msgid name_of_the_room
83 resid : the room resource ID (ie. unique number)
84 msgid : the message ID of the first available message in the room
89 In its simplest form, this function allows you to retrieve messages
90 posted in a room, possibly waiting for a message to be posted.
92 If the room has resid 1, and the first message ID (from the fn=rooms
93 call) is 3, then calling:
95 fn=wait&rooms=1&msgids=1:3
97 reads message ID 3 from resid 1. To read the next message, increment
100 fn=wait&rooms=1&msgids=1:4
101 fn=wait&rooms=1&msgids=1:5
104 Eventually one of these calls will block until a message is posted
107 More normally, you will use the fn=wait call to monitor several rooms
108 at once. For this, you need to construct:
110 rooms : comma-separated list of resids
111 msgids : comma-separated list of resid:msgid pairs
113 Each resid:msgid pair is the next expected message ID in each room.
114 You should start with the first message ID from each room, and
115 increment the msgid _only_ when you receive that msgid in that room.
118 fn=wait&rooms=1,2&msgids=1:5,2:1
120 This API call may return one or more messages. Each message is on its
121 own line with the following format:
123 resid msgid msgtype [optional fields depending on msgtype ...]
126 msgid : the message ID
127 msgtype : one of the following message types:
129 msgtype 'posted' (an ordinary posted message):
131 resid msgid posted hh:mm userid [username] text_of_the_message
133 hh:mm : the time the message was posted
134 userid : the user ID (0 = the anonymous user)
135 username : for non-anonymous users, the name of the user
136 text_of_the_message : the message text as typed by the user
138 msgtype 'enter'/'leave' (a user entered or left the room):
140 resid msgid enter userid [username]
142 userid : the user ID (0 = the anonymous user)
143 username : for non-anonymous users, the name of the user
145 msgtype 'blank'/'gone': clients should ignore all messages of these types.
149 1 5 posting 10:45 2 rich This is a really insightful comment
150 1 6 posting 10:46 0 This is an anonymous posting
155 Chatbots should ignore lines that they don't understand (eg. if the
156 line doesn't start with a number).
161 Post a message to a room. The following parameters are required:
163 fn=post&room=resid&text=message
166 text : the text of the message in smart-text format
168 Note that chatbots reads back their own messages.