Skip to content

frosch03/rcb

Repository files navigation

Functional Reactive Rocket.Chat Bot

Description

The following implementation is an implementation of a rocket.chat client that can act as a chat bot and is called rcb.

It is intended as a pice of software to help understand how to work in a functional reactive programming style. This style is introduced by e.g. haskells yampa framework. rcb is ordered in plugins, that run in seperate threads and are designed around yampas `reactimate` function.

reactimate takes four functions following a defined function signature, used for these tasks:

  • initialize
  • sense
  • process
  • actuate

It initializes with the init function and then loops a sense call, followd by process and that result by actuate.

Currently there are three plugins used:

CLI
a set of commands, the bot is able to recognize and act in a defined way (e.g. return the latest entry of an .rss-feed)
RSS
poll a set of .rss-feeds and send a message to a list of recipients that contains the latest item of the feed, if that has not been send yet
REST
poll the result of a REST call currently of a jira query language call and send a message to a list of recipients that contains the latest item of the result, if that has not been send yet; this plugin is also called JIRA

There is a global configuration as well as a configuration for each plugin. Example config files are provided as: Configuration.lhs.sample.

Configuration

Just copy the attached sample configuration into the file `Configuration.lhs` and enter each of the empty values with a

meaningful one

global config

Here you configure the server address and port as well as the path. Then you define the credentials of the bots account. Currently you need to define the users id as subscription value, as the bot subscribes to that channel and therefore recognizes everything that ist send to that account.

You also define the location of where the bot’s plugins can store it’s persistent data.

RSS config

Here are the rss commands are defined, together with the locations of the .rss-feeds that are polled in the also given frequency.

REST config

Here are the list of jqls defined, that shall be polled each defined intervall, together with the list of recipients.

Installation

Clone the Repo

git clone https://github.com/frosch03/rcb.git

Configure

  1. Search for sample configurations:
find ./ -name "Configuration.lhs.sample"
  1. Rename them each to Configration.lhs and fill the values inside with data

Install the dependancies

cabal install

Build the executable

cabal build

Run the chat bot

./dist/build/rcb/rcb

Installation within Docker

Create the container that compiles the rcbot

Rename Dockerfile.sample to Dockerfile and change settings if needed.

The image is derived from haskell:latest and necassary dependancies for compilation will be installed:

docker build -t rcb-img -f Dockerfile .

Create the container that runs the rcbot

Rename Dockerfile.fast.sample to Dockerfile.fast and change settings if needed. Then:

docker build -t rcbot -f Dockerfile.fast .

Run the container

Now one can just run that rcbot container with:

docker run -d --rm --name rcbot rcbot

About

functional reactive rocket.chat bot

Resources

License

Stars

Watchers

Forks

Packages

No packages published