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

Commit

Permalink
authentic Framebot to framebot_init
Browse files Browse the repository at this point in the history
framrbot_init(token)
  • Loading branch information
h4child committed Jun 6, 2018
1 parent f1a1c76 commit d74906c
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 37 deletions.
4 changes: 1 addition & 3 deletions examples/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ int main (int argc, char **argv) {
Framebot *frame_update;
Update *message, *temp;

framebot_init();

echo = framebot(argv[1]);
echo = framebot_init(argv[1]);


frame_update = get_updates(echo, NULL, last_offset, 100, 0, NULL);
Expand Down
3 changes: 1 addition & 2 deletions examples/inline_bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ int main (int argc, char **argv) {
printf("Usage: ./inline BOT_TOKEN\n");
exit(-1);
}
framebot_init();

char *result = alloc_string("[{\"type\":\"sticker\",\"id\":\"1\",\"sticker_file_id\":\"CAADAQADHAADDf4xFY94M8CVYwIeAg\"}]");
Bot *inbot = framebot(argv[1]);
Bot *inbot = framebot_init(argv[1]);
if(!inbot)
return -1;

Expand Down
3 changes: 1 addition & 2 deletions include/framebot/framebot.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ typedef int32_t bool;
#include <framebot/payments.h>


void framebot_init();
Bot * framebot(const char *token);
Bot * framebot_init(const char *token);
refjson *generic_method_call (const char *token, char *formats, ...);
Error * show_error();

Expand Down
12 changes: 7 additions & 5 deletions src/framebot.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ char *parse_mode[3] =
""
};

void framebot_init () {
network_init();
}


/**
* Authentic bot token
*/
Bot * framebot (const char *token) {
Bot * framebot_init (const char *token) {
static bool net = 0;
Bot *obot = bot(token, NULL);

if(net == 0){
network_init();
net = 1;
}

User *bot_user = get_me(obot);

if (bot_user) {
Expand Down
3 changes: 1 addition & 2 deletions test/test_chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,13 @@ int _func(){
}

int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendvideonote <token> <username> <text>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ int _file(){


int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "file <token> <username> <namefile>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_payments.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,13 @@ void test_invoice(){


int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "payments <token> <provider token> <username>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_sendaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,13 @@ int _audio(){


int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendaudio <token> <username> <path audio>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_senddocument.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ void _free(Framebot *update){


int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendvideonote <token> <username> <path audio>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_sendmessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ int _message(){
}

int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendphoto <token> <username>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_sendphotos.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ int _photo(){
}

int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendphoto <token> <username> <path audio>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_sendvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,13 @@ int _video(){
}

int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendvideonote <token> <username> <path audio>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_sendvideonote.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,13 @@ int _videonote(){
}

int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendvideonote <token> <username> <path audio>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
3 changes: 1 addition & 2 deletions test/test_sendvoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ int _voice(){


int main(int argc, char *argv[]){
framebot_init();

if(argc < 4){
fprintf(stderr, "sendphoto <token> <username> <path audio>");
exit(-1);
}

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "ERROR authentic");
exit(-1);
Expand Down
4 changes: 1 addition & 3 deletions test/test_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ int main(int argc, char **argv){
*inline_query, *chosen_inline_result, *callback_query, *shipping_query, *pre_checkout_query;
Error *error = NULL;

framebot_init();

if(argc < 2)
fprintf(stderr, "update <token>");


Bot *bot = framebot(argv[1]);
Bot *bot = framebot_init(argv[1]);
if(!bot){
error = get_error();
if(error)
Expand Down
3 changes: 1 addition & 2 deletions test/test_userprofilephotos.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ void upp(UserProfilePhotos * oupp){


int main(int argc, char *argv[]){
framebot_init();

if(argc < 3)
fprintf(stderr, "update <token> <id_user>");

_bot = framebot(argv[1]);
_bot = framebot_init(argv[1]);
if(!_bot){
fprintf(stderr, "Error Authentic");
exit(-1);
Expand Down

0 comments on commit d74906c

Please sign in to comment.