Hardware Reference
In-Depth Information
Press
Alt
+
1
through
9
to change windows, or alternatively use the
/win
[number]
command. To get a list of all your windows, use the
/wins
command.
This marks the end of our Profanity crash course. Let's exit Profanity using the
/quit
command and see how to set up our chat bot.
Project AgentBot
As mentioned earlier, we'll be passing chat messages between our friends and one
of three existing chat bots. The default one is called Cleverbot and can be found
interface. These bots primarily speak English, but Cleverbot especially has been
known to impress by answering in different languages.
Since we are all about the command line on the Pi, we'll be interacting with
Cleverbot through an
Application Programming Interface
(
API
) module written
in Python by Pierre-David Bélanger. Let's download it to the Profanity
plugins
directory with the following command:
pi@raspberrypi ~ $ wget http://www.intestinate.com/chatterbotapi.py -P
~/.local/share/profanity/plugins
Now we create our plugin by opening up an empty Python file for editing in the
Profanity
plugins
directory:
pi@raspberrypi ~ $ nano ~/.local/share/profanity/plugins/agentbot.py
This is our plugin code:
import prof
from chatterbotapi import ChatterBotFactory, ChatterBotType
factory = ChatterBotFactory()
bot = factory.create(ChatterBotType.CLEVERBOT)
# bot = factory.create(ChatterBotType.JABBERWACKY)
# bot = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
bot_session = {}
bot_state = False
def prof_post_chat_message_display(jid, message):
if bot_state:
if jid not in bot_session:
bot_session[jid] = bot.create_session()
prof.cons_show("New AgentBot session created:
" + str(bot_session[jid]))