Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

m-czernek/acrobot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE

If you are a Red Hatter that would like to report Acrobot not working, please ping Eduardo who took over the Acrobot maintenance at Red Hat, or Richard as a backup.

This repository is now archived.

Acrobot

Acrobot is a Google Hangouts chat bot, with the aim of keeping track of acronyms used within the company.

Image of Acrobot saving and answering an acronym

Image of Acrobot editing and removing acronym explanations

Usage

Acrobot is capable of multiple actions:

  • Saving an acronym: !acronym = explanation
  • Getting an acronym explanation: acronym
  • Modifying an acronym explanation: !acronym = explanation => new explanation
  • Removing an acronym explanation: !acronym = explanation =>

White spaces do not matter. If you are interacting with acrobot in a room, do not forget to tag the bot, e.g. @Acrobot !acronym = explanation.

You can change and remove only those explanations that you entered into the database.

Architecture

Acrobot is a simple application, using:

  • Java (tested against OpenJDK 11)
  • Hibernate
  • MySQL
  • Kubernetes/OpenShift for deployment #todo OCP template

This particular implementation uses Google's Cloud Pub/Sub messaging middleware.

Alt text

custom_mark10 @startuml; actor "Google Hangouts" as User; participant "Pub/Sub middleware" as A; participant Acrobot; User -> A: Send a message; Acrobot --> A: Poll for a message; Acrobot --> User: Send a response; @enduml; custom_mark10

As such, before deploying the Google bot, you have to complete Google's Pub/Sub prerequisites:

  1. Create a project in the Cloud Platform Console, which:
    1. Has the Pub/Sub API enabled.
    2. Has granted the Pub/Sub permissions to the [email protected] service role.
  2. Create a service account with the Pub/Sub API roles.
  3. Create a message queue in the Cloud Platform Console.
  4. Associate the queue with a subscription in the Cloud Platform Console.

For more details on setting up the bot, see the Google Developer's documentation.

Acrobot has a few dependencies:

  1. export GOOGLE_APPLICATION_CREDENTIALS: an environment variable that contains the path to the service account json you created. If you are deploying Acrobot on Kubernetes/OpenShift, you will have to inject the file either using a secret, or a config map, into your pod.
  2. export JDBC_URL, JDBC_USER, and JDBC_PASSWORD for the DB connection details.
  3. export PROJECT_ID and SUBSCRIPTION_ID which match your Google project and subscription created earlier.

Testing

Acrobot contains unit tests with an in-memory H2 database. You should execute all tests before pushing new code. You can execute tests by issuing: mvn clean test. To execute a particular test, you can specify the test parameter in the format of ClassName#TestName, for example:

mvn clean test -Dtest=MessageHelperTest#exceptionPropagationTest

All new features should have tests.

Credits

Author: Marek Czernek. The idea of Acrobot came from a number of very smart folks at Red Hat. The IRC implementation was done by https://github.com/mfojtik. If you wish to run AcroBot on IRC, see the AcroBot Implementation.