A Java-based chat bot for Stackoverflow Chat
Switch branches/tags
Nothing to show
Clone or download

README.md

OakBot

codecov.io Known Vulnerabilities

OakBot is a chat bot for Stack Overflow Chat that's written in Java. It is named after the first name given to the Java programming language before it became "Java".

OakBot is most active in the Java chat room.

Requirements

  • Java 1.8
  • Maven (for building)

Build Instructions

To build the project, run the command below.

mvn package

This command will build the project and package it into an executable, shaded JAR. A shaded JAR file contains all of the project's dependencies. The shaded JAR file is saved here: target/OakBot-VERSION.jar.

Deploy Instructions

  1. Copy the following files to the server. Put them in the same directory:
    1. target/OakBot-VERSION.jar: The executable, shaded JAR file that contains OakBot's code and dependencies.
    2. bot.properties: This file contains configuration data, such as the bot's login credentials. A sample file is located in the root of this project.
    3. logging.properties (optional): The configuration file for the Java Logging API. A sample file is located in the root of this project.
  2. Run OakBot: java -jar OakBot-VERSION.jar
  3. Once the bot has fully started up, it will instruct you to press Ctrl+Z, then type the bg command. In Linux, this will move the program into the background and free up the shell.

db.json

This is the file OakBot uses to persist information, such as how many commands it has responded to and what rooms it has joined. It is located in the bot's working directory. The file will automatically be created if it doesn't exist.

bot.properties

Contains various configuration settings for the bot. Open the sample "bot.properties" file at the root of this project for a description of each setting.

OakBot must be restarted if any of these settings are changed while OakBot is running.

Adding/Removing Commands

To add a command, create an instance of the Command interface and add it to the bot in the main method.

All of OakBot's commands are listed on the wiki.

CLI Arguments

Argument Description
--settings=PATH The properties file that contains the bot's configuration settings, such as login credentials (defaults to "bot.properties").
--db=PATH The path to a JSON file for storing all persistant data (defaults to "db.json").
--mock Runs the bot using a mock chat connection for testing purposes.

A text file will be created in the root of the project for each chat room the bot is configured to connect to. These files are used to "send" messages to the mock chat rooms. To send a message, type your message into the text file and save it.

Messages are entered one per line. Multi-line messages can be entered by ending each line with a backslash until you reach the last line. You should only append onto the end of the file; do not delete anything. These files are re-created every time the program runs.

All messages that are sent to the mock chat room are displayed in stdout (this includes your messages and the bot's responses).
--quiet If specified, the bot will not output a greeting message when it starts up.
--version Prints the version of this program.
--help Prints descriptions of each argument.

Questions/Feedback

One way to reach me is in Stack Overflow's Java chat room. Please mention my name (@Michael) so I will see your message.

You can also submit bug reports and feature requests to the issue tracker.