The Script’s Scope
The Keyword Assistant (keyassist) script will be written in Python using the Jabberpy library. As mentioned earlier, the script will perform the following tasks:
Connect to a predetermined Jabber server
Join a predetermined conference room
Sit there quietly, listening to the conversation
Take simple commands from people to watch for, or stop watching for, particular words or phrases uttered in the room
Relay the context of those words or phrases to whomever requested them, if heard
In addition to setting the identity of the Jabber server and the conference room in variables, we’ll also need to keep track of which users ask the assistant for words and phrases. We’ll use a dictionary (hash in Perl terms), as shown in Example 9-3, because we want to manage the data in there by key, the JID of those users that the script will be assisting. Having a look at what this dictionary will look like during the lifetime of this script will help us to visualize what we’re trying to achieve.
{
'dj@gnu.pipetree.com/home': {
'http:': 1,
'ftp:': 1
},
'piers@jabber.org/work': {
'Perl': 1,
'Java': 1,
'SAP R/3': 1
},
'cellar@conf.merlix.dyndns.org/roscoe': {
'dialback': 1
}
}
We can see from the contents of the dictionary in Example 9-3
that three people have asked the script to look out for words and phrases.
Two of those people—dj and
piers—have interacted with the script directly by sending a normal (or ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access