Merge github.com:vysheng/tg
This commit is contained in:
commit
608c2c2608
@ -5,12 +5,17 @@ Command-line interface for [Telegram](http://telegram.org). Uses readline interf
|
||||
### API, Protocol documentation
|
||||
|
||||
Documentation for Telegram API is available here: http://core.telegram.org/api
|
||||
|
||||
Documentation for MTproto protocol is available here: http://core.telegram.org/mtproto
|
||||
|
||||
### Installation
|
||||
|
||||
Just run `make`
|
||||
|
||||
#### Requirements
|
||||
|
||||
Currently only Linux OS is supported. But if you manage to launch it on OS X or other UNIX, please let me know.
|
||||
|
||||
### Usage
|
||||
|
||||
./telegram -k <public-server-key>
|
||||
|
@ -452,6 +452,10 @@ int get_contacts_on_answer (struct query *q UU) {
|
||||
push_color (COLOR_GREEN);
|
||||
printf (" (");
|
||||
printf ("%s", U->print_name);
|
||||
if (U->phone) {
|
||||
printf (" ");
|
||||
printf ("%s", U->phone);
|
||||
}
|
||||
printf (") ");
|
||||
pop_color ();
|
||||
if (U->status.online > 0) {
|
||||
|
47
structures.c
47
structures.c
@ -23,6 +23,7 @@
|
||||
#include "tree.h"
|
||||
#include "loop.h"
|
||||
int verbosity;
|
||||
union user_chat *Peers[MAX_USER_NUM];
|
||||
|
||||
void fetch_file_location (struct file_location *loc) {
|
||||
int x = fetch_int ();
|
||||
@ -60,6 +61,9 @@ void fetch_user_status (struct user_status *S) {
|
||||
}
|
||||
|
||||
int our_id;
|
||||
int user_num;
|
||||
int chat_num;
|
||||
|
||||
void fetch_user (struct user *U) {
|
||||
unsigned x = fetch_int ();
|
||||
assert (x == CODE_user_empty || x == CODE_user_self || x == CODE_user_contact || x == CODE_user_request || x == CODE_user_foreign || x == CODE_user_deleted);
|
||||
@ -100,6 +104,48 @@ void fetch_user (struct user *U) {
|
||||
if (*s == ' ') { *s = '_'; }
|
||||
s++;
|
||||
}
|
||||
int cc = 0;
|
||||
while (1) {
|
||||
int ok = 1;
|
||||
int i;
|
||||
for (i = 0; i < user_num + chat_num; i++) {
|
||||
if (Peers[i] != (void *)U && !strcmp (Peers[i]->print_name, U->print_name)) {
|
||||
ok = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
break;
|
||||
}
|
||||
cc ++;
|
||||
assert (cc <= 99);
|
||||
if (cc == 1) {
|
||||
int l = strlen (U->print_name);
|
||||
char *s = malloc (l + 3);
|
||||
memcpy (s, U->print_name, l);
|
||||
s[l + 2] = 0;
|
||||
s[l] = '#';
|
||||
s[l + 1] = '1';
|
||||
free (U->print_name);
|
||||
U->print_name = s;
|
||||
} else if (cc == 10) {
|
||||
int l = strlen (U->print_name);
|
||||
char *s = malloc (l + 2);
|
||||
memcpy (s, U->print_name, l);
|
||||
s[l + 1] = 0;
|
||||
s[l] = '0';
|
||||
s[l - 1] = '1';
|
||||
free (U->print_name);
|
||||
U->print_name = s;
|
||||
} else {
|
||||
int l = strlen (U->print_name);
|
||||
U->print_name[l - 1] ++;
|
||||
if (U->print_name[l - 1] > '9') {
|
||||
U->print_name[l - 1] = '0';
|
||||
U->print_name[l - 2] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x == CODE_user_deleted) {
|
||||
U->flags |= FLAG_DELETED;
|
||||
return;
|
||||
@ -481,7 +527,6 @@ int user_num;
|
||||
int users_allocated;
|
||||
int chats_allocated;
|
||||
int messages_allocated;
|
||||
union user_chat *Peers[MAX_USER_NUM];
|
||||
|
||||
struct message message_list = {
|
||||
.next_use = &message_list,
|
||||
|
Loading…
Reference in New Issue
Block a user