<commit_before># slacker-rtm
Erlang [Real Time Messaging API client][2] for [Slack][1].

## Fetch dependencies and compile

```
$ rebar get-deps compile
```

### Authentication
The Slack RTM API uses custom implementation of oAuth 2.0 for authentiaction.
Authorization process is not part of this library and you have to manually
[register][4] your application and obtain valid [token][5].


## Quick start

Include library in your `rebar.conf`.
```erlang
{'slacker-rtm', "",
   {git, "https://github.com/tgrk/slacker-rtm.git", {branch, "master"}}}
```
Connect to API using obtained [token][5]:
```erlang
{ok, Pid} = sr:connect(BinToken).
```

## Message formatting

Slack messages are JSON structures that follow specific [formatting][6].

Simple message with bot icon and colored left border:
```erlang
Msg = sr_message:format(<<"Hello">> <<"Hello World!">>, Fields, <<"#df4f18">>).
```

Simple message with table, bot icon and colored left border:
```erlang
Fields = [[{title, "Col"}, {value, 1}]].
Msg = sr_message:format_table(<<"Hello">> <<"Hello World!">>, Fields, <<"#df4f18">>).
```

## Testing
You have to setup API token file in order to use tests. Please add your
valid [token][5] into template (replace .template) file `test/api_token.term`.

Tests are executed as usual:
```bash
$ rebar co eunit skip_deps=true
```

[1]: http://www.slack.com/
[2]: https://api.slack.com/rtm
[3]: https://api.slack.com/web
[4]: https://api.slack.com/applications
[5]: https://api.slack.com/tokens
[6]: https://api.slack.com/docs/formatting
[7]: https://api.slack.com/methods/rtm.start<commit_msg>Update doc with deps and requirements<commit_after># slacker-rtm
Erlang [Real Time Messaging API client][2] for [Slack][1].

## Dependencies

* Erlang (>= R17) - because `maps`
* [rebar][8]

## Fetch dependencies and compile

```
$ rebar get-deps compile
```

### Authentication
The Slack RTM API uses custom implementation of oAuth 2.0 for authentiaction.
Authorization process is not part of this library and you have to manually
[register][4] your application and obtain valid [token][5].


## Quick start

Include library in your `rebar.conf`.
```erlang
{'slacker-rtm', "",
   {git, "https://github.com/tgrk/slacker-rtm.git", {branch, "master"}}}
```
Connect to API using obtained [token][5]:
```erlang
{ok, Pid} = sr:connect(BinToken).
```

## Message formatting

Slack messages are JSON structures that follow specific [formatting][6].

Simple message with bot icon and colored left border:
```erlang
Msg = sr_message:format(<<"Hello">> <<"Hello World!">>, Fields, <<"#df4f18">>).
```

Simple message with table, bot icon and colored left border:
```erlang
Fields = [[{title, "Col"}, {value, 1}]].
Msg = sr_message:format_table(<<"Hello">> <<"Hello World!">>, Fields, <<"#df4f18">>).
```

## Testing
You have to setup API token file in order to use tests. Please add your
valid [token][5] into template (replace .template) file `test/api_token.term`.

Tests are executed as usual:
```bash
$ rebar co eunit skip_deps=true
```

[1]: http://www.slack.com/
[2]: https://api.slack.com/rtm
[3]: https://api.slack.com/web
[4]: https://api.slack.com/applications
[5]: https://api.slack.com/tokens
[6]: https://api.slack.com/docs/formatting
[7]: https://api.slack.com/methods/rtm.start
[8]: https://github.com/rebar/rebar
{'fraction_non_alphanumeric': 0.17522658610271905, 'fraction_numerical': 0.015105740181268883, 'mean_word_length': 4.880994671403197, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 28, 'https://': 15, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '995128', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1113, 'n_words': 352}