<commit_before>-module(frfbot).

-behaviour(gen_server).

%% API
-export([start_link/0,
         get_posts/1,
         login/0,
         post/2,
         is_logged_in/0
        ]).

%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

-define(SERVER, ?MODULE).

-record(state, {logged_in=false, token}).

%%%===================================================================
%%% API
%%%===================================================================

%%--------------------------------------------------------------------
%% @doc
%% Starts the server
%%
%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
%% @end
%%--------------------------------------------------------------------
start_link() ->
    gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).

login() ->
    gen_server:call(?MODULE, {login}).

post(Feed, Text) ->
    gen_server:call(?MODULE, {post, Feed, Text}).

is_logged_in() ->
    gen_server:call(?MODULE, {is_logged_in}).

get_posts(Feed) ->
    gen_server:call(?MODULE, {get_posts, Feed}).

%%%===================================================================
%%% gen_server callbacks
%%%===================================================================

%%--------------------------------------------------------------------
%% @private
%% @doc
%% Initializes the server
%%
%% @spec init(Args) -> {ok, State} |
%%                     {ok, State, Timeout} |
%%                     ignore |
%%                     {stop, Reason}
%% @end
%%--------------------------------------------------------------------
init([]) ->
    {ok, #state{}}.

%%--------------------------------------------------------------------
%% @private
%% @doc
%% Handling call messages
%%
%% @spec handle_call(Request, From, State) ->
%%                                   {reply, Reply, State} |
%%                                   {reply, Reply, State, Timeout} |
%%                                   {noreply, State} |
%%                                   {noreply, State, Timeout} |<commit_msg>Bot must log in at startup<commit_after>-module(frfbot).

-behaviour(gen_server).

%% API
-export([start_link/0,
         get_posts/1,
         login/0,
         post/2,
         is_logged_in/0
        ]).

%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

-define(SERVER, ?MODULE).

-record(state, {logged_in=false, token}).

%%%===================================================================
%%% API
%%%===================================================================

%%--------------------------------------------------------------------
%% @doc
%% Starts the server
%%
%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
%% @end
%%--------------------------------------------------------------------
start_link() ->
    gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).

login() ->
    gen_server:call(?MODULE, {login}).

post(Feed, Text) ->
    gen_server:call(?MODULE, {post, Feed, Text}).

is_logged_in() ->
    gen_server:call(?MODULE, {is_logged_in}).

get_posts(Feed) ->
    gen_server:call(?MODULE, {get_posts, Feed}).

%%%===================================================================
%%% gen_server callbacks
%%%===================================================================

%%--------------------------------------------------------------------
%% @private
%% @doc
%% Initializes the server
%%
%% @spec init(Args) -> {ok, State} |
%%                     {ok, State, Timeout} |
%%                     ignore |
%%                     {stop, Reason}
%% @end
%%--------------------------------------------------------------------
init([]) ->
    {_Status, State} = get_token(#state{}),
    {ok, State}.

%%--------------------------------------------------------------------
%% @private
%% @doc
%% Handling call messages
%%
%% @spec handle_call(Request, From, State) ->
%%                                   {reply, Reply, State} |
%%                                   {reply, Reply, State, Timeout} |
%%                                   {noreply, State} |
%%                                   {noreply, State, Timeout} |
{'fraction_non_alphanumeric': 0.4259610821072615, 'fraction_numerical': 0.005220692928334125, 'mean_word_length': 1.5858895705521472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2588164', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1045, 'n_words': 200}