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

Commit

Permalink
send_chat_action return
Browse files Browse the repository at this point in the history
  • Loading branch information
h4child committed Apr 1, 2018
1 parent e05ab66 commit d82dc3d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions include/framebot/framebot.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ Message *edit_message_reply_markup(Bot *bot, char *chat_id, long int message_id,
Message *edit_message_reply_markup_chat(Bot *bot, long int chat_id, long int message_id,
char *inline_message_id, char *reply_markup);

/* delete message */
bool delete_message(Bot *bot, char *chat_id, long int message_id);
bool delete_message_chat(Bot *bot, long int chat_id, long int message_id);

bool answer_inline_query( Bot *bot, char *inline_query_id, char *results, long int cache_time, bool is_personal,
char *next_offset, char *switch_pm_text, char *switch_pm_parameter);

Expand Down
2 changes: 1 addition & 1 deletion include/framebot/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void network_init();
MemStore * mem_store();
void mem_store_free(MemStore * memStore);
size_t mem_write_callback(void *content, size_t size, size_t nmemb, void *userp);
MemStore *call_method(const char *token, char *method);
MemStore *call_method(const char *token, const char *method);
int call_method_download(const char * token, char * namefile, File * ofile);
MemStore * call_method_upload(const char * token, IFile ifile);

Expand Down
4 changes: 2 additions & 2 deletions src/framebot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,9 +1515,9 @@ int send_chat_action(Bot * bot, char * chat_id, char * action){
if(!s_json)
return -1;

result = json_is_true(s_json->content) ? 0 : -1;
result = json_is_true(s_json->content);

return result;
return result > 0 ? 1 : 0;
}

int send_chat_action_chat(Bot * bot, long int chat_id, char * action){
Expand Down
2 changes: 1 addition & 1 deletion src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ size_t mem_write_callback(void *data, size_t size, size_t nmemb, void *userp) {
}

/* send data to telegram */
MemStore * call_method(const char *token, char *method){
MemStore * call_method(const char *token, const char *method){
CURLcode res;
size_t url_size = API_URL_LEN + strlen( token ) + strlen( method ) + 2;
char * url = ( char * ) calloc(1, url_size );
Expand Down
17 changes: 14 additions & 3 deletions test/test_chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int _func(){
}


printf("send_contact ...... ");
/* printf("send_contact ...... ");
Message * e = send_contact_chat(_bot, chat_id, "65 9999-9992", "Framebot",
"API", 0, 0, NULL);
if(e){
Expand All @@ -140,7 +140,7 @@ int _func(){
if(e1)
printf("false\ncode:%ld | description:%s\n", e1->error_code, e1->description);
exit(-1);
}
}*/

#ifdef _WIN32
custom_sleep(5000);
Expand All @@ -149,7 +149,7 @@ int _func(){
#endif

printf("send sendchataction ............ ");
if(send_chat_action_chat(_bot, chat_id, "typing")){
if(send_chat_action_chat(_bot, chat_id, "typing") == 1){
printf("ok\n");
}
else{
Expand All @@ -176,6 +176,17 @@ int _func(){
exit(-1);
}

printf("send delete_message_chat ............. ");
if(delete_message_chat(_bot, chat_id, result->message_id) == 1){
printf("ok\n");
}
else{
printf("false\n");
Error *e1 = get_error();
if(e1)
printf("false\ncode:%ld | description:%s\n", e1->error_code, e1->description);
exit(-1);
}

return 0;
}
Expand Down

0 comments on commit d82dc3d

Please sign in to comment.