Hardware Reference
In-Depth Information
response = bot_session[jid].think(message)
prof.send_line("/msg " + jid + " " + response)
def _cmd_agentbot(state):
global bot_state
if state == "enable":
prof.cons_show("AgentBot Activated")
bot_state = True
elif state == "disable":
prof.cons_show("AgentBot Stopped")
bot_state = False
else:
if bot_state:
prof.cons_show("AgentBot is running - current sessions:")
prof.cons_show(str(bot_session))
else:
prof.cons_show("AgentBot is stopped - Type /agentbot enable to
activate.")
def prof_init(version, status):
prof.register_command("/agentbot", 0, 1, "/agentbot
[enable|disable]", "AgentBot", "AgentBot", _cmd_agentbot)
It's important to note when working with Python code that Python uses whitespace
to delimit program blocks, so make sure to preserve the indentation levels in the code.
Let's take a closer look at the code:
import prof : Every Profanity plugin must import this module.
from chatterbotapi : We import the functions and variables we need
from the chatterbotapi.py module.
bot = factory.create : Here, we tell chatterbotapi to create a new
CLEVERBOT for us and store it in a variable named bot . Uncommenting one
of the other two bot = lines allows you to switch between the three different
bot-types—Cleverbot, Jabberwacky, and Pandorabot.
bot_session = {} : This empty dictionary will be used to keep track of
which chat session belongs to which of your friends.
bot_state = False : This Boolean is used to toggle the bot on or off.
 
Search WWH ::




Custom Search