mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 05:53:02 +01:00
Make /whois show both public key and name
This commit is contained in:
parent
a5b44dffd2
commit
f16aa35ebc
@ -49,7 +49,7 @@ static struct cmd_func global_commands[] = {
|
|||||||
{ "/connect", cmd_connect },
|
{ "/connect", cmd_connect },
|
||||||
{ "/decline", cmd_decline },
|
{ "/decline", cmd_decline },
|
||||||
{ "/exit", cmd_quit },
|
{ "/exit", cmd_quit },
|
||||||
{ "/conference",cmd_conference },
|
{ "/conference", cmd_conference },
|
||||||
{ "/group", cmd_groupchat },
|
{ "/group", cmd_groupchat },
|
||||||
#ifdef GAMES
|
#ifdef GAMES
|
||||||
{ "/game", cmd_game },
|
{ "/game", cmd_game },
|
||||||
@ -124,7 +124,7 @@ static struct cmd_func conference_commands[] = {
|
|||||||
|
|
||||||
static struct cmd_func groupchat_commands[] = {
|
static struct cmd_func groupchat_commands[] = {
|
||||||
{ "/chatid", cmd_chatid },
|
{ "/chatid", cmd_chatid },
|
||||||
{ "/disconnect",cmd_disconnect },
|
{ "/disconnect", cmd_disconnect },
|
||||||
{ "/ignore", cmd_ignore },
|
{ "/ignore", cmd_ignore },
|
||||||
{ "/kick", cmd_kick },
|
{ "/kick", cmd_kick },
|
||||||
{ "/list", cmd_list },
|
{ "/list", cmd_list },
|
||||||
|
@ -693,11 +693,11 @@ void cmd_whois(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *nick = argv[1];
|
const char *identifier = argv[1];
|
||||||
uint32_t peer_id;
|
uint32_t peer_id;
|
||||||
|
|
||||||
if (group_get_nick_peer_id(self->num, nick, &peer_id) == -1) {
|
if (group_get_nick_peer_id(self->num, identifier, &peer_id) == -1) {
|
||||||
if (group_get_public_key_peer_id(self->num, nick, &peer_id) == -1) {
|
if (group_get_public_key_peer_id(self->num, identifier, &peer_id) == -1) {
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Invalid peer name or public key.");
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Invalid peer name or public key.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -710,33 +710,35 @@ void cmd_whois(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupPeer *peer = &chat->peer_list[peer_index];
|
||||||
|
|
||||||
const char *status_str = "Online";
|
const char *status_str = "Online";
|
||||||
|
|
||||||
if (chat->peer_list[peer_index].status == TOX_USER_STATUS_BUSY) {
|
if (peer->status == TOX_USER_STATUS_BUSY) {
|
||||||
status_str = "Busy";
|
status_str = "Busy";
|
||||||
} else if (chat->peer_list[peer_index].status == TOX_USER_STATUS_AWAY) {
|
} else if (peer->status == TOX_USER_STATUS_AWAY) {
|
||||||
status_str = "Away";
|
status_str = "Away";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *role_str = "User";
|
const char *role_str = "User";
|
||||||
|
|
||||||
if (chat->peer_list[peer_index].role == TOX_GROUP_ROLE_FOUNDER) {
|
if (peer->role == TOX_GROUP_ROLE_FOUNDER) {
|
||||||
role_str = "Founder";
|
role_str = "Founder";
|
||||||
} else if (chat->peer_list[peer_index].role == TOX_GROUP_ROLE_MODERATOR) {
|
} else if (peer->role == TOX_GROUP_ROLE_MODERATOR) {
|
||||||
role_str = "Moderator";
|
role_str = "Moderator";
|
||||||
} else if (chat->peer_list[peer_index].role == TOX_GROUP_ROLE_OBSERVER) {
|
} else if (peer->role == TOX_GROUP_ROLE_OBSERVER) {
|
||||||
role_str = "Observer";
|
role_str = "Observer";
|
||||||
}
|
}
|
||||||
|
|
||||||
char last_seen_str[128];
|
char last_seen_str[128];
|
||||||
get_elapsed_time_str_alt(last_seen_str, sizeof(last_seen_str),
|
get_elapsed_time_str_alt(last_seen_str, sizeof(last_seen_str),
|
||||||
get_unix_time() - chat->peer_list[peer_index].last_active);
|
get_unix_time() - peer->last_active);
|
||||||
|
|
||||||
char pk_string[TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2 + 1] = {0};
|
char pk_string[TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2 + 1] = {0};
|
||||||
|
|
||||||
for (size_t i = 0; i < TOX_GROUP_PEER_PUBLIC_KEY_SIZE; ++i) {
|
for (size_t i = 0; i < TOX_GROUP_PEER_PUBLIC_KEY_SIZE; ++i) {
|
||||||
char d[3];
|
char d[3];
|
||||||
snprintf(d, sizeof(d), "%02X", chat->peer_list[peer_index].public_key[i] & 0xff);
|
snprintf(d, sizeof(d), "%02X", peer->public_key[i] & 0xff);
|
||||||
strcat(pk_string, d);
|
strcat(pk_string, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,11 +751,11 @@ void cmd_whois(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
|
|||||||
connection_type_str = connection_type == TOX_CONNECTION_UDP ? "UDP" : "TCP";
|
connection_type_str = connection_type == TOX_CONNECTION_UDP ? "UDP" : "TCP";
|
||||||
}
|
}
|
||||||
|
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Whois for %s", nick);
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Public key: %s", pk_string);
|
||||||
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Name: %s", peer->name);
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Role: %s", role_str);
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Role: %s", role_str);
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Status: %s", status_str);
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Status: %s", status_str);
|
||||||
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Connection: %s", connection_type_str);
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Last active: %s", last_seen_str);
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Last active: %s", last_seen_str);
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Connection status: %s", connection_type_str);
|
|
||||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Public key: %s", pk_string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user