<commit_before># Jabbot

Jabbot is an easily extensible chat robot written in java.
It supports connection to multiple servers & chat systems, and a pluggable chatroom command system and focus on extensibility. 

Jabbot consists of 3 projects:

1. **jabbot-binding-api** whihch provide a set of interfaces to create new chat system bindings such like XMPP, IRC...
2. **jabbot-extension-api** which aims at providing an interface for plugging new commands & features for chat rooms
3. **jabbot-daemon** which is the actual Bot daemon

**Bindings** can be written using jabbot-binding api and are currently stored under the
[bindings](https://github.com/midoricorp/jabbot/tree/master/bindings) directory.

**Extensions** can be written using jabbot-extension-api and are currently stored under the [extensions](https://github.com/midoricopr/jabbot/tree/master/extensions) directory.

**CGI Extensions** can be written using in any language you want. Scripts and their json configuration are currently stored under the [scripts](https://github.com/midoricorp/jabbot/tree/master/scripts) directory.

**Script Extensions** can also be written the in chat language. Declaring a sub will result in a new bot function being created. Any existing bot command (regardless of implementation) can be called as a function. See the project [Searle Script](https://github.com/midoricorp/script/) for information on the language syntax.

There is also a collection of script commands you can install, check them out in the [Snippet Archive](https://github.com/midoricorp/snippets)

## Quickstart

**Installing it via APT **

Tested on Ubuntu Bionic
```bash
sudo apt-get install apt-transport-https ca-certificates
echo "deb [trusted=yes] https://dl.bintray.com/midoricorp/deb unstable main" > /etc/apt/sources.list.d/midoricorp-jabbot.list
sudo apt-get update
sudo apt-get install jabbot-full
```
**Configuring**
Installing via apt will trigger genconf.pl being run.  This will ask you which protocols and bindings you want to use.
If you make a mistake during this phase, simply delete or fix /etc/jabbot/saved_values.ini and invoke ```dpkg-reconfigure jabbbot```.  See "[Per-Protocol Configuration Details](#per-protocol-configuration-details)" for advice on how to configure each protocool.

**Logs**
logs for jabbot can be found in /var/log/jabbot/

**Build debs from master**

Tested on Ubuntu Bionic
```bash
sudo apt-get install git ca-certificates
git clone https://github.com/midoricorp/jabbot.git
cd jabbot
sudo apt-get install build-essential fakeroot devscripts equivs
sudo mk-build-deps --install --tool 'apt-get --yes --no-install-recommends' --remove
sudo rm ../jabbot*_all.deb
sudo dpkg-buildpackage -uc -us
cd ..
apt install ./jabbot*_all.deb
```


**Build it by hand**
Assuming you have git, java 8, jsvc and maven2 installed

```bash
host$ git clone https://github.com/midoricorp/jabbot.git
host$ cd jabbot/
host$ mvn clean install -Pstandalone,all
host$ cd jabbot-daemon/target/
host$ tar -xzf jabbot-daemon-<version>.tar.gz
host$ cd ../../

```
**Configure it**
```bash
apt-get install libjson-perl libconfig-simple-perl
./genconf.pl
mv jabbot.json jabbot-daemon/target/jabbot-daemon-<version>/conf/
```
**Start it**
```bash
host$ cd jabbot-daemon/target/jabbot-daemon-<version>/
host$ bin/jabbot.sh start
```

> You can use [ngrok](https://ngrok.com/) that can generate public URLs for testing your chatbot. After downloading and installation type ```./ngrok http 8080``` then copy URL and paste it in variable ```parameters.webhook_url```

## Jabbot Configuration
Jabbot can be configured by editing the main config file jabbot.json under the conf/ directory.
The config file consists in the following main areas

## Bindings
```json
    "bindings":[
        {   "name":"XMPP",
            "className":"org.wanna.jabbot.binding.xmpp.XmppBinding"
        }
    ]
```
Defines a list of available binding type such as xmpp, irc..

* **name:** a unique identifier for this binding
* **className:** the canonical name of the binding connection class

### serverList
```json
    "serverList":[
        {   "type" : "XMPP",
            "identifier" : "XMPP",
            "url":"jabber.hostname.com",
            "serverName":"hostname.com",
            "port":5222,
            "username":"Jabbot",
            "password":"password",
            "commandPrefix":"!",
            "parameters":{<commit_msg>info about ngrok<commit_after># Jabbot

Jabbot is an easily extensible chat robot written in java.
It supports connection to multiple servers & chat systems, and a pluggable chatroom command system and focus on extensibility. 

Jabbot consists of 3 projects:

1. **jabbot-binding-api** whihch provide a set of interfaces to create new chat system bindings such like XMPP, IRC...
2. **jabbot-extension-api** which aims at providing an interface for plugging new commands & features for chat rooms
3. **jabbot-daemon** which is the actual Bot daemon

**Bindings** can be written using jabbot-binding api and are currently stored under the
[bindings](https://github.com/midoricorp/jabbot/tree/master/bindings) directory.

**Extensions** can be written using jabbot-extension-api and are currently stored under the [extensions](https://github.com/midoricopr/jabbot/tree/master/extensions) directory.

**CGI Extensions** can be written using in any language you want. Scripts and their json configuration are currently stored under the [scripts](https://github.com/midoricorp/jabbot/tree/master/scripts) directory.

**Script Extensions** can also be written the in chat language. Declaring a sub will result in a new bot function being created. Any existing bot command (regardless of implementation) can be called as a function. See the project [Searle Script](https://github.com/midoricorp/script/) for information on the language syntax.

There is also a collection of script commands you can install, check them out in the [Snippet Archive](https://github.com/midoricorp/snippets)

## Quickstart

**Installing it via APT **

Tested on Ubuntu Bionic
```bash
sudo apt-get install apt-transport-https ca-certificates
echo "deb [trusted=yes] https://dl.bintray.com/midoricorp/deb unstable main" > /etc/apt/sources.list.d/midoricorp-jabbot.list
sudo apt-get update
sudo apt-get install jabbot-full
```
**Configuring**
Installing via apt will trigger genconf.pl being run.  This will ask you which protocols and bindings you want to use.
If you make a mistake during this phase, simply delete or fix /etc/jabbot/saved_values.ini and invoke ```dpkg-reconfigure jabbbot```.  See "[Per-Protocol Configuration Details](#per-protocol-configuration-details)" for advice on how to configure each protocool.

**Logs**
logs for jabbot can be found in /var/log/jabbot/

**Build debs from master**

Tested on Ubuntu Bionic
```bash
sudo apt-get install git ca-certificates
git clone https://github.com/midoricorp/jabbot.git
cd jabbot
sudo apt-get install build-essential fakeroot devscripts equivs
sudo mk-build-deps --install --tool 'apt-get --yes --no-install-recommends' --remove
sudo rm ../jabbot*_all.deb
sudo dpkg-buildpackage -uc -us
cd ..
apt install ./jabbot*_all.deb
```


**Build it by hand**
Assuming you have git, java 8, jsvc and maven2 installed

```bash
host$ git clone https://github.com/midoricorp/jabbot.git
host$ cd jabbot/
host$ mvn clean install -Pstandalone,all
host$ cd jabbot-daemon/target/
host$ tar -xzf jabbot-daemon-<version>.tar.gz
host$ cd ../../

```
**Configure it**
```bash
apt-get install libjson-perl libconfig-simple-perl
./genconf.pl
mv jabbot.json jabbot-daemon/target/jabbot-daemon-<version>/conf/
```
**Start it**
```bash
host$ cd jabbot-daemon/target/jabbot-daemon-<version>/
host$ bin/jabbot.sh start
```

> You can use [ngrok](https://ngrok.com/) that can generate public URLs for testing your chatbots. After downloading and installation type ```./ngrok http 8080``` then copy URL and paste it in variable ```parameters.webhook_url```

## Jabbot Configuration
Jabbot can be configured by editing the main config file jabbot.json under the conf/ directory.
The config file consists in the following main areas

## Bindings
```json
    "bindings":[
        {   "name":"XMPP",
            "className":"org.wanna.jabbot.binding.xmpp.XmppBinding"
        }
    ]
```
Defines a list of available binding type such as xmpp, irc..

* **name:** a unique identifier for this binding
* **className:** the canonical name of the binding connection class

### serverList
```json
    "serverList":[
        {   "type" : "XMPP",
            "identifier" : "XMPP",
            "url":"jabber.hostname.com",
            "serverName":"hostname.com",
            "port":5222,
            "username":"Jabbot",
            "password":"password",
            "commandPrefix":"!",
            "parameters":{
{'fraction_non_alphanumeric': 0.11143894689060373, 'fraction_numerical': 0.0031774852473899226, 'mean_word_length': 3.981910684002261, 'pattern_counts': {'":': 22, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3559415', 'n_tokens_mistral': 2741, 'n_tokens_neox': 2613, 'n_words': 969}