Commit a3a4e63a authored by Vysheng's avatar Vysheng

Merge branch 'grishka-master'

parents a6c00cde 8d9861af
......@@ -103,6 +103,7 @@ struct in_ev *notify_ev;
extern int usfd;
extern int sfd;
extern int use_ids;
int is_same_word (const char *s, size_t l, const char *word) {
return s && word && strlen (word) == l && !memcmp (s, word, l);
......@@ -2374,7 +2375,9 @@ void print_user_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *U) {
if ((U->flags & FLAG_DELETED)) {
mprintf (ev, "deleted user#%d", tgl_get_peer_id (id));
} else if (!(U->flags & FLAG_CREATED)) {
mprintf (ev, "empty user#%d", tgl_get_peer_id (id));
mprintf (ev, "user#%d", tgl_get_peer_id (id));
} else if (use_ids) {
mprintf (ev, "user#%d", tgl_get_peer_id (id));
} else if (!U->user.first_name || !strlen (U->user.first_name)) {
mprintf (ev, "%s", U->user.last_name);
} else if (!U->user.last_name || !strlen (U->user.last_name)) {
......@@ -2392,7 +2395,7 @@ void print_user_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *U) {
void print_chat_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
assert (tgl_get_peer_type (id) == TGL_PEER_CHAT);
mpush_color (ev, COLOR_MAGENTA);
if (!C) {
if (!C || use_ids) {
mprintf (ev, "chat#%d", tgl_get_peer_id (id));
} else {
mprintf (ev, "%s", C->chat.title);
......@@ -2403,7 +2406,7 @@ void print_chat_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
void print_encr_chat_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
assert (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT);
mpush_color (ev, COLOR_MAGENTA);
if (!C) {
if (!C || use_ids) {
mprintf (ev, "encr_chat#%d", tgl_get_peer_id (id));
} else {
mprintf (ev, "%s", C->print_name);
......@@ -2414,7 +2417,7 @@ void print_encr_chat_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
void print_encr_chat_name_full (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
assert (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT);
mpush_color (ev, COLOR_MAGENTA);
if (!C) {
if (!C || use_ids) {
mprintf (ev, "encr_chat#%d", tgl_get_peer_id (id));
} else {
mprintf (ev, "%s", C->print_name);
......
......@@ -111,6 +111,7 @@ int readline_disabled;
int disable_output;
int reset_authorization;
int port;
int use_ids;
char *start_command;
void set_default_username (const char *s) {
......@@ -465,6 +466,7 @@ void usage (void) {
printf (" -P <port> port to listen for input commands\n");
printf (" -S <socket-name> unix socket to create\n");
printf (" -e <commands> make commands end exit\n");
printf (" -I use user and chat IDs in updates instead of names\n");
exit (1);
}
......@@ -567,7 +569,7 @@ char *unix_socket;
void args_parse (int argc, char **argv) {
int opt = 0;
while ((opt = getopt (argc, argv, "u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:"
while ((opt = getopt (argc, argv, "u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:I"
#ifdef HAVE_LIBCONFIG
"c:p:"
#else
......@@ -659,6 +661,9 @@ void args_parse (int argc, char **argv) {
case 'e':
start_command = optarg;
break;
case 'I':
use_ids ++;
break;
case 'h':
default:
usage ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment