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
|
### API, Protocol documentation
|
||||||
|
|
||||||
Documentation for Telegram API is available here: http://core.telegram.org/api
|
Documentation for Telegram API is available here: http://core.telegram.org/api
|
||||||
|
|
||||||
Documentation for MTproto protocol is available here: http://core.telegram.org/mtproto
|
Documentation for MTproto protocol is available here: http://core.telegram.org/mtproto
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
Just run `make`
|
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
|
### Usage
|
||||||
|
|
||||||
./telegram -k <public-server-key>
|
./telegram -k <public-server-key>
|
||||||
|
@ -452,6 +452,10 @@ int get_contacts_on_answer (struct query *q UU) {
|
|||||||
push_color (COLOR_GREEN);
|
push_color (COLOR_GREEN);
|
||||||
printf (" (");
|
printf (" (");
|
||||||
printf ("%s", U->print_name);
|
printf ("%s", U->print_name);
|
||||||
|
if (U->phone) {
|
||||||
|
printf (" ");
|
||||||
|
printf ("%s", U->phone);
|
||||||
|
}
|
||||||
printf (") ");
|
printf (") ");
|
||||||
pop_color ();
|
pop_color ();
|
||||||
if (U->status.online > 0) {
|
if (U->status.online > 0) {
|
||||||
|
47
structures.c
47
structures.c
@ -23,6 +23,7 @@
|
|||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "loop.h"
|
#include "loop.h"
|
||||||
int verbosity;
|
int verbosity;
|
||||||
|
union user_chat *Peers[MAX_USER_NUM];
|
||||||
|
|
||||||
void fetch_file_location (struct file_location *loc) {
|
void fetch_file_location (struct file_location *loc) {
|
||||||
int x = fetch_int ();
|
int x = fetch_int ();
|
||||||
@ -60,6 +61,9 @@ void fetch_user_status (struct user_status *S) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int our_id;
|
int our_id;
|
||||||
|
int user_num;
|
||||||
|
int chat_num;
|
||||||
|
|
||||||
void fetch_user (struct user *U) {
|
void fetch_user (struct user *U) {
|
||||||
unsigned x = fetch_int ();
|
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);
|
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 = '_'; }
|
if (*s == ' ') { *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) {
|
if (x == CODE_user_deleted) {
|
||||||
U->flags |= FLAG_DELETED;
|
U->flags |= FLAG_DELETED;
|
||||||
return;
|
return;
|
||||||
@ -481,7 +527,6 @@ int user_num;
|
|||||||
int users_allocated;
|
int users_allocated;
|
||||||
int chats_allocated;
|
int chats_allocated;
|
||||||
int messages_allocated;
|
int messages_allocated;
|
||||||
union user_chat *Peers[MAX_USER_NUM];
|
|
||||||
|
|
||||||
struct message message_list = {
|
struct message message_list = {
|
||||||
.next_use = &message_list,
|
.next_use = &message_list,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user