Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
608c2c26
Commit
608c2c26
authored
Oct 25, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge github.com:vysheng/tg
parents
e20f9e49
3e62e525
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
1 deletion
+55
-1
README.md
README.md
+5
-0
queries.c
queries.c
+4
-0
structures.c
structures.c
+46
-1
No files found.
README.md
View file @
608c2c26
...
...
@@ -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>
...
...
queries.c
View file @
608c2c26
...
...
@@ -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
)
{
...
...
structures.c
View file @
608c2c26
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment