Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
get_me follows the pattern of receiving the bot parameter
Browse files Browse the repository at this point in the history
get_me (Bot *bot)
  • Loading branch information
h4child committed May 23, 2018
1 parent c3896d1 commit 5600701
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/framebot/framebot.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ refjson *generic_method_call (const char *token, char *formats, ...);
Error * show_error();

/** Available methods **/
User * get_me(const char *token);
User * get_me(Bot *bot);
Framebot *get_updates (Bot *bot, Framebot *framebot, long int offset, long int limit,
long int timeout, char *allowed_updates);

Expand Down
14 changes: 7 additions & 7 deletions src/framebot.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ void framebot_init () {
* Authentic bot token
*/
Bot * framebot (const char *token) {
Bot *obot = bot(token, NULL);

User *bot_user = get_me(token);
User *bot_user = get_me(obot);

if (bot_user) {
Bot *obot = bot(token, bot_user);
obot->user = bot_user;

return obot;
}

bot_free(obot);

return NULL;
}

Expand All @@ -27,14 +30,11 @@ Bot * framebot (const char *token) {
* Returns a User object of the owner bot.
* https://core.telegram.org/bots/api#getme
*/
User *get_me (const char *token) {
User *get_me (Bot *bot) {
User * user = NULL;
refjson *s_json = NULL;

if (!token)
return NULL;

s_json = generic_method_call(token, API_GETME);
s_json = generic_method_call(bot->token, API_GETME);
if(!s_json)
return NULL;

Expand Down
4 changes: 1 addition & 3 deletions src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ Bot *bot(const char *token, User *user){
return NULL;

bot->token = alloc_string(token);
if(user)
bot->user = user;
bot->user = user;

return bot;
}
Expand All @@ -114,7 +113,6 @@ void bot_free(Bot *bot){
user_free(bot->user);

free(bot);
bot = NULL;
}

/**
Expand Down

0 comments on commit 5600701

Please sign in to comment.