<commit_before># Erlang bot for FreeFeed.net #

## Build and deploy ##

```
git clone https://github.com/yashrk/erlfrfbot
cd erlfrfbot
wget https://github.com/rebar/rebar/wiki/rebar
chmod +x rebar
./rebar compile
cd rel
vim files/sys.config # About config file see below
../rebar generate
```

That's all. Now you have a ready to work Erlang release of erlfrfbot in `$PROJECTDIR/rel/frfbot`. Now you can copy it to your server and run or just run on the same machine.

## What to edit in sys.config ##

```
 %% FreeFeed bot config
 {frfbot, [
           {user, "<YOUR_LOGIN_HERE>"},
           {password, "<<PASSWORD>>"}
          ]},
 %% Scheduled tasks
 {erlcron, [
            {crontab, [
                       {{daily, {6, 00, am}}, {utils, habits_post, []}}
            ]}
            ]}
```

Change `<YOUR_LOGIN_HERE>` and `<YOUR_PASSWORD_HERE>` to your bot login and password. If you don't need scheduled tasks, comment out `erlcron` section, otherwise edit it.

## Usage ##

### How to run and connect ###

Go to `$RELEASE_DIR/bin`. Run

```
./frfbot start
```

Now your bot is (probably) up and running.

If you need a console, type
```
./frfbot attach
```

To leave console, press `Ctrl-D`.

### API example ###

```
(frfbot@127.0.0.1)1> frfbot:is_logged_in().
true

(frfbot@127.0.0.1)2> frfbot:post(<<"mybot">>, <<"This is a test"/utf8>>).
{ok,{{"HTTP/1.1",200,"OK"},
...
    "{\"posts\":{\"id\":\"b93b1b68-2325-490c-99c8-7318a15e9536\",
...

(frfbot@127.0.0.1)3> frfbot:comment(<<"b93b1b68-2325-490c-99c8-7318a15e9536">>, <<"This is a test comment"/utf8>>).
{"comment":{"postId":"b93b1b68-2325-490c-99c8-7318a15e9536","body":"This is a test comment"}}{{"HTTP/1.1",200,"OK"},
"{\"comments\":{\"id\":\"0ef6ee44-88d9-4647-a3a8-99fe68757b7a\",\"body\":\"This is a test comment\",\"createdAt\":1

(frfbot@127.0.0.1)4> frfbot:get_posts("mybot").
[#{<<"body">> => <<"This is a test">>,
...
   <<"id">> => <<"b93b1b68-2325-490c-99c8-7318a15e9536">>,
...

(frfbot@127.0.0.1)5> frfbot:login().
ok

```

## License ##

This code is available under the terms of GNU Affero General Public License (http://www.gnu.org/licenses/agpl-3.0.en.html).<commit_msg>Small markup fixes<commit_after># Erlang bot for FreeFeed.net #

## Build and deploy ##

```
git clone https://github.com/yashrk/erlfrfbot
cd erlfrfbot
wget https://github.com/rebar/rebar/wiki/rebar
chmod +x rebar
./rebar compile
cd rel
vim files/sys.config # About config file see below
../rebar generate
```

That's all. Now you have a ready to work Erlang release of erlfrfbot in `$PROJECTDIR/rel/frfbot`. You can copy it to your server and run or just run on the same machine.

## What to edit in sys.config ##

```
 %% FreeFeed bot config
 {frfbot, [
           {user, "<YOUR_LOGIN_HERE>"},
           {password, "<<PASSWORD>>"}
          ]},
 %% Scheduled tasks
 {erlcron, [
            {crontab, [
                       {{daily, {6, 00, am}}, {utils, habits_post, []}}
            ]}
           ]}
```

Change `<YOUR_LOGIN_HERE>` and `<YOUR_PASSWORD_HERE>` to your bot login and password. If you don't need scheduled tasks, comment out `erlcron` section, otherwise edit it.

## Usage ##

### How to run and connect ###

Go to `$RELEASE_DIR/bin`. Run

```
./frfbot start
```

Now your bot is (probably) up and running.

If you need a console, type
```
./frfbot attach
```

To leave console, press `Ctrl-D`.

### API example ###

<pre>
(frfbot@127.0.0.1)1> <strong>frfbot:is_logged_in().</strong>
true

(frfbot@127.0.0.1)2> <strong>frfbot:post(<<"mybot">>, <<"This is a test"/utf8>>).</strong>
{ok,{{"HTTP/1.1",200,"OK"},
...
    "{\"posts\":{\"id\":\"b93b1b68-2325-490c-99c8-7318a15e9536\",
...

(frfbot@127.0.0.1)3> <strong>frfbot:comment(<<"b93b1b68-2325-490c-99c8-7318a15e9536">>, <<"This is a test comment"/utf8>>).</strong>
{"comment":{"postId":"b93b1b68-2325-490c-99c8-7318a15e9536","body":"This is a test comment"}}{{"HTTP/1.1",200,"OK"},
"{\"comments\":{\"id\":\"0ef6ee44-88d9-4647-a3a8-99fe68757b7a\",\"body\":\"This is a test comment\",\"createdAt\":1

(frfbot@127.0.0.1)4> <strong>frfbot:get_posts("mybot").</strong>
[#{<<"body">> => <<"This is a test">>,
...
   <<"id">> => <<"b93b1b68-2325-490c-99c8-7318a15e9536">>,
...

(frfbot@127.0.0.1)5> <strong>frfbot:login().</strong>
ok
</pre>

## License ##

This code is available under the terms of GNU Affero General Public License (http://www.gnu.org/licenses/agpl-3.0.en.html).
{'fraction_non_alphanumeric': 0.2063167461940468, 'fraction_numerical': 0.0790729379686435, 'mean_word_length': 3.5102459016393444, 'pattern_counts': {'":': 18, '<': 57, '<?xml version=': 0, '>': 71, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 10, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6009608', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1760, 'n_words': 400}