Javadoc link

A while back we added the DiscordBot service to MyRobotLab.  The Discord Bot service acts as a gateway.  

The DiscordBot service implements 2 interfaces in MyRobotLab, the first is UtterancePublisher and the UtteranceListener.  

The idea is that DiscordBot connects to a discord server using the Discord java API.  The DiscordBot logs into the server using a security token that is associated with a discord bot user. 

The discord bot is permissioned to get and send messages from some channels or direct messages.  Currently, the discord bot only supports text messages,  (audio/video is not supported at this time.)

The DiscordBot service acts as a gateway that converts the discord messages into Utterances.

On the MyRobotLab side, then ProgramAB can listen for those utterances, process the utterance to produce a response utterance.  This response utterance is then published to the DiscordBot service.  The DiscordBot service then relays the response to the appropriate channel on the Discord server.

So, here's a diagram:

ProgramAB and DiscordBot

 

Ok, and here's some simple python code that can start the discord bot service and the programab service.


###############################################################################
# Example of how to use ProgramAB with the DiscordBot service
###############################################################################
# First start the ProgramAB chat bot and set the current AIML set being loaded.
brain = Runtime.start("brain", "ProgramAB")
# load the default alice bot / AIML set.
brain.setCurrentBotName("Alice");
# Next start the DiscordBot service
bot = Runtime.start("bot", "DiscordBot")
# set the security token to access the discord bot user account.
bot.setToken("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
# attach programAB as an utterance listener of the discord service (incoming messages)
brain.attachUtteranceListener(bot.getName());
# attach the discord bot as a listener for utterances from programab ( response messages )
bot.attachUtteranceListener(brain.getName());
# lastly, connect the discord bot to the discord server
bot.connect()