-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDESC
executable file
·40 lines (32 loc) · 1.79 KB
/
DESC
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
Tangled is a modular chat bot systemajig, originally intended to be used
with IRC.
The core system, which resides in tangled.py, is essentially a message router
that got a bit out of hand. Theoretically a a module can be written in any
language that's heard of stdin/stdout and json. The core executes the modules
and talks to them through the stdio pipe.
Modules are identified by their 'shortname' - a short (say, 3-12 chars,
preferably ascii) and unique name that is used internally to address
communications. These communications occur through stdin/stdout and are
line-based. This is possible because the modules are executables and
called in a beautiful non-blocking fashion by the router.
PROTOCOL
The core talks to modules using json. The base message is the following:
{
"source": shortname of the sender, | One of these two, depending on
"target": shortname of the target, | direction of message
"type": descriptor of the message type
}
It can contain various other key/value pairs depending on the message
type. See json.org for more information of the format and what it can
contain.
Another way to run a module is by talking to a python interface directly, by
throwing around dicts (which are called "msgobj"s throughout the source)
rather than json strings. There are two reasons for this interface to exist:
it saves some overhead (no need for another python process), and I haven't
figured out yet how to make one script talk on IRC as well as through
stdin/stdout. Currently the python interface doesn't do anything to stop a
module from locking up the entire bot, so don't use it unless you're quite
sure the module won't block.
For a rough idea of the future plans I have for Tangled you ought to check out
the file tangled.org (formatted for emacs' org-mode) which has mostly
todo-items.