|
|
@ -79,25 +79,25 @@ int config_tox(Tox *tox) |
|
|
|
const char *name; |
|
|
|
const char *name; |
|
|
|
|
|
|
|
|
|
|
|
if (config_lookup_string(&cfg, "Tox_Bot_Name", &str)) { |
|
|
|
if (config_lookup_string(&cfg, "Tox_Bot_Name", &str)) { |
|
|
|
printf("Tox bot name: %s\n", str); |
|
|
|
fprintf(stdout, "Tox bot name: %s\n", str); |
|
|
|
name = str; |
|
|
|
name = str; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
name = "Tox Bot test"; |
|
|
|
name = "Tox Bot test"; |
|
|
|
fprintf(stderr, "No 'Tox_Bot_Name' setting in configuration file. "); |
|
|
|
fprintf(stderr, "No 'Tox_Bot_Name' setting in configuration file. "); |
|
|
|
printf("The default name is used\n"); |
|
|
|
fprintf(stdout, "The default name is used\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const char *status_message; |
|
|
|
const char *status_message; |
|
|
|
|
|
|
|
|
|
|
|
if (config_lookup_string(&cfg, "Tox_Bot_Status", &str)) { |
|
|
|
if (config_lookup_string(&cfg, "Tox_Bot_Status", &str)) { |
|
|
|
printf("Tox bot status: %s\n", str); |
|
|
|
fprintf(stdout, "Tox bot status: %s\n", str); |
|
|
|
status_message = str; |
|
|
|
status_message = str; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
status_message = "Hello, World!"; |
|
|
|
status_message = "Hello, World!"; |
|
|
|
fprintf(stderr, "No 'Tox_Bot_Status' setting in configuration file. "); |
|
|
|
fprintf(stderr, "No 'Tox_Bot_Status' setting in configuration file. "); |
|
|
|
printf("The default status is used\n"); |
|
|
|
fprintf(stdout, "The default status is used\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tox_self_set_name(tox, name, strlen(name), NULL); |
|
|
|
tox_self_set_name(tox, name, strlen(name), NULL); |
|
|
@ -199,7 +199,7 @@ void print_tox_id(Tox *tox) |
|
|
|
tox_id_hex[i] = toupper(tox_id_hex[i]); |
|
|
|
tox_id_hex[i] = toupper(tox_id_hex[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
printf("Tox ID: %s\n", tox_id_hex); |
|
|
|
fprintf(stdout, "Tox ID: %s\n", tox_id_hex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -219,12 +219,12 @@ static void friend_request_cb(Tox *tox, const uint8_t *public_key, const uint8_t |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (file_contains_key(public_key, MASTERLIST_FILE) == 1) { |
|
|
|
if (file_contains_key(public_key, MASTERLIST_FILE) == 1) { |
|
|
|
printf("New friend is Master: %s\n", tox_id_hex); |
|
|
|
fprintf(stdout, "New friend is Master: %s\n", tox_id_hex); |
|
|
|
tox_friend_add_norequest(tox, public_key, NULL); |
|
|
|
tox_friend_add_norequest(tox, public_key, NULL); |
|
|
|
update_savedata_file(tox); |
|
|
|
update_savedata_file(tox); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
printf("New friend not on the list: %s\n", tox_id_hex); |
|
|
|
fprintf(stdout, "New friend not on the list: %s\n", tox_id_hex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -256,13 +256,13 @@ void self_connection_status_cb(Tox *tox, TOX_CONNECTION connection_status, void |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (connection_status) { |
|
|
|
switch (connection_status) { |
|
|
|
case TOX_CONNECTION_NONE: |
|
|
|
case TOX_CONNECTION_NONE: |
|
|
|
printf("Offline\n"); |
|
|
|
fprintf(stdout, "Offline\n"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case TOX_CONNECTION_TCP: |
|
|
|
case TOX_CONNECTION_TCP: |
|
|
|
printf("Online, using TCP\n"); |
|
|
|
fprintf(stdout, "Online, using TCP\n"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case TOX_CONNECTION_UDP: |
|
|
|
case TOX_CONNECTION_UDP: |
|
|
|
printf("Online, using UDP\n"); |
|
|
|
fprintf(stdout, "Online, using UDP\n"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -285,7 +285,7 @@ int main() |
|
|
|
|
|
|
|
|
|
|
|
update_savedata_file(tox); |
|
|
|
update_savedata_file(tox); |
|
|
|
|
|
|
|
|
|
|
|
printf("Connecting...\n"); |
|
|
|
fprintf(stdout, "Connecting...\n"); |
|
|
|
|
|
|
|
|
|
|
|
while (1) { |
|
|
|
while (1) { |
|
|
|
tox_iterate(tox, NULL); |
|
|
|
tox_iterate(tox, NULL); |
|
|
|