A chatbot for announcing upcoming matches and finding fellow players, written for the LibreGaming community
Go to file
Sebastian Crane 91cbdb69da Simplify the system start and restart functions
This commit changes the binding name of system/start's argument to
_ (since it is currently not used within the function), and simplifies
the system/restart function by not swapping the system Var's content
with nil before filling it with the new-created system state.

Eventually, these changes will be reverted when the initialisation of
the system is separated from the starting of that system, which will
mean that system/start will read its argument and that system/restart
will have to reinitialise the system state before restarting it.

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-24 21:51:06 +00:00
LICENSES Initial commit 2022-01-01 17:45:51 +00:00
src Simplify the system start and restart functions 2022-03-24 21:51:06 +00:00
test Omit sender of !match command from players list 2022-02-26 23:34:38 +00:00
CHANGELOG.md Release version 1.0.0 2022-03-03 21:48:53 +00:00
CONTRIBUTING.md Add section about licensing to CONTRIBUTING.md 2022-02-28 18:10:13 +00:00
README.md Use a Var instead of an Atom for system state 2022-03-22 22:47:00 +00:00
deps.edn Add clj-commons/clj-yaml to dependencies 2022-02-18 22:09:27 +00:00
tests.edn Initial commit 2022-01-01 17:45:51 +00:00

README.md

matchbot

A chatbot for announcing upcoming matches and finding fellow players, written for the LibreGaming community

Running

  1. Install Clojure - you can use Clojure's official installation guide or your distribution's package.

  2. Clone this repository:

git clone https://git.libregaming.org/LibreGaming/matchbot.git
cd matchbot
  1. Create a configuration file, config.yaml, in YAML format:
data-file: "matchbot-data.json"
irc:
  server: example.com
  port: 6667
  nick: matchbot
  channel: "##matchbot-test"
  1. Run matchbot:
clojure -M -m system

Usage

!list - show all the games that have a list of players

!match game - announce a match of game to all of its players

!players game - show all the players of game

!add game - add yourself to the list of players for game

!remove game - remove yourself from the list of players for game

!help - show available commands with their explanations

Development

Running the tests

matchbot includes automated unit tests for many functions, along with a simple test runner configuration with Kaocha. Running the tests is a similar process to running the main application:

clojure -M:test -m kaocha.runner

Starting a development REPL

When developing matchbot, it can be more convenient and efficient to work interactively with a REPL integrated into your text editor. Since matchbot uses Clojure's tools.deps library, the best way to start is by following the relevant part of the nREPL documentation to create a user-level deps.edn file, then install the nREPL extension for your text editor.

You can create, start and stop an instance of the chatbot process with the functions in the system namespace:

;; creating a new instance - an empty Var
(def my-instance nil)

;; starting the instance
(alter-var-root #'my-instance system/start)

;; restarting the instance
(system/restart #'my-instance)

;; stopping and resetting the instance
(alter-var-root #'my-instance system/stop)
(alter-var-root #'my-instance (constantly nil))

Once you are familiar with nREPL, you can additionally use tools.namespace.repl to make reevaluating (reloading) your changes easier:

(require '[clojure.tools.namespace.repl :refer [refresh]])
(refresh)

Make sure that you create your system instance in the REPL, since refresh will forcefully delete the instance if it has been defined in another namespace!