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
598b4414
Commit
598b4414
authored
Oct 01, 2015
by
V V
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some fixes. Added some debug output. Added channel_info query
parent
17fc871f
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
236 additions
and
132 deletions
+236
-132
interface.c
interface.c
+200
-113
interface.h
interface.h
+3
-0
lua-tg.c
lua-tg.c
+31
-17
telegram.h
telegram.h
+1
-1
tgl
tgl
+1
-1
No files found.
interface.c
View file @
598b4414
This diff is collapsed.
Click to expand it.
interface.h
View file @
598b4414
...
@@ -84,4 +84,7 @@ void print_date (struct in_ev *ev, long t);
...
@@ -84,4 +84,7 @@ void print_date (struct in_ev *ev, long t);
void
play_sound
(
void
);
void
play_sound
(
void
);
void
update_prompt
(
void
);
void
update_prompt
(
void
);
void
set_interface_callbacks
(
void
);
void
set_interface_callbacks
(
void
);
char
*
print_permanent_msg_id
(
tgl_message_id_t
id
);
char
*
print_permanent_peer_id
(
tgl_peer_id_t
id
);
#endif
#endif
lua-tg.c
View file @
598b4414
...
@@ -73,6 +73,15 @@ void lua_add_string_field (const char *name, const char *value) {
...
@@ -73,6 +73,15 @@ void lua_add_string_field (const char *name, const char *value) {
lua_settable
(
luaState
,
-
3
);
lua_settable
(
luaState
,
-
3
);
}
}
void
lua_add_lstring_field
(
const
char
*
name
,
const
char
*
value
,
int
len
)
{
assert
(
name
&&
strlen
(
name
));
if
(
!
value
||
!
len
)
{
return
;
}
my_lua_checkstack
(
luaState
,
3
);
lua_pushstring
(
luaState
,
name
);
lua_pushlstring
(
luaState
,
len
,
value
);
lua_settable
(
luaState
,
-
3
);
}
void
lua_add_string_field_arr
(
int
num
,
const
char
*
value
)
{
void
lua_add_string_field_arr
(
int
num
,
const
char
*
value
)
{
if
(
!
value
||
!
strlen
(
value
))
{
return
;
}
if
(
!
value
||
!
strlen
(
value
))
{
return
;
}
my_lua_checkstack
(
luaState
,
3
);
my_lua_checkstack
(
luaState
,
3
);
...
@@ -100,6 +109,9 @@ void push_tgl_peer_type (int x) {
...
@@ -100,6 +109,9 @@ void push_tgl_peer_type (int x) {
case
TGL_PEER_ENCR_CHAT
:
case
TGL_PEER_ENCR_CHAT
:
lua_pushstring
(
luaState
,
"encr_chat"
);
lua_pushstring
(
luaState
,
"encr_chat"
);
break
;
break
;
case
TGL_PEER_CHANNEL
:
lua_pushstring
(
luaState
,
"channel"
);
break
;
default:
default:
assert
(
0
);
assert
(
0
);
}
}
...
@@ -144,6 +156,15 @@ void push_encr_chat (tgl_peer_t *P) {
...
@@ -144,6 +156,15 @@ void push_encr_chat (tgl_peer_t *P) {
lua_settable
(
luaState
,
-
3
);
lua_settable
(
luaState
,
-
3
);
}
}
void
push_channel
(
tgl_peer_t
*
P
)
{
my_lua_checkstack
(
luaState
,
4
);
lua_add_string_field
(
luaState
,
"title"
,
P
->
channel
.
title
);
lua_add_string_field
(
luaState
,
"about"
,
P
->
channel
.
about
);
lua_add_num_field
(
luaState
,
"participants_count"
,
P
->
channel
.
participants_count
);
lua_add_num_field
(
luaState
,
"admins_count"
,
P
->
channel
.
admins_count
);
lua_add_num_field
(
luaState
,
"kicked_count"
,
P
->
channel
.
kicked_count
);
}
void
push_update_types
(
unsigned
flags
)
{
void
push_update_types
(
unsigned
flags
)
{
my_lua_checkstack
(
luaState
,
4
);
my_lua_checkstack
(
luaState
,
4
);
lua_newtable
(
luaState
);
lua_newtable
(
luaState
);
...
@@ -203,12 +224,9 @@ void push_update_types (unsigned flags) {
...
@@ -203,12 +224,9 @@ void push_update_types (unsigned flags) {
void
push_peer
(
tgl_peer_id_t
id
,
tgl_peer_t
*
P
)
{
void
push_peer
(
tgl_peer_id_t
id
,
tgl_peer_t
*
P
)
{
lua_newtable
(
luaState
);
lua_newtable
(
luaState
);
lua_add_num_field
(
"id"
,
tgl_get_peer_id
(
id
));
lua_add_lstring_field
(
"id"
,
print_permanent_peer_id
(
P
->
id
));
lua_pushstring
(
luaState
,
"type"
);
lua_add_string_field
(
luaState
,
"type"
,
tgl_get_peer_type
(
id
));
push_tgl_peer_type
(
tgl_get_peer_type
(
id
));
lua_settable
(
luaState
,
-
3
);
if
(
!
P
||
!
(
P
->
flags
&
TGLPF_CREATED
))
{
if
(
!
P
||
!
(
P
->
flags
&
TGLPF_CREATED
))
{
lua_pushstring
(
luaState
,
"print_name"
);
lua_pushstring
(
luaState
,
"print_name"
);
...
@@ -223,6 +241,9 @@ void push_peer (tgl_peer_id_t id, tgl_peer_t *P) {
...
@@ -223,6 +241,9 @@ void push_peer (tgl_peer_id_t id, tgl_peer_t *P) {
case
TGL_PEER_ENCR_CHAT
:
case
TGL_PEER_ENCR_CHAT
:
sprintf
(
s
,
"encr_chat#%d"
,
tgl_get_peer_id
(
id
));
sprintf
(
s
,
"encr_chat#%d"
,
tgl_get_peer_id
(
id
));
break
;
break
;
case
TGL_PEER_CHANNEL
:
sprintf
(
s
,
"channel#%d"
,
tgl_get_peer_id
(
id
));
break
;
default:
default:
assert
(
0
);
assert
(
0
);
}
}
...
@@ -420,9 +441,9 @@ void push_service (struct tgl_message *M) {
...
@@ -420,9 +441,9 @@ void push_service (struct tgl_message *M) {
lua_add_string_field
(
"type"
,
"channel_created"
);
lua_add_string_field
(
"type"
,
"channel_created"
);
lua_add_string_field
(
"title"
,
M
->
action
.
title
);
lua_add_string_field
(
"title"
,
M
->
action
.
title
);
break
;
break
;
default:
/*
default:
lua_pushstring (luaState, "???");
lua_pushstring (luaState, "???");
break
;
break;
*/
}
}
}
}
...
@@ -431,15 +452,7 @@ void push_message (struct tgl_message *M) {
...
@@ -431,15 +452,7 @@ void push_message (struct tgl_message *M) {
my_lua_checkstack
(
luaState
,
10
);
my_lua_checkstack
(
luaState
,
10
);
lua_newtable
(
luaState
);
lua_newtable
(
luaState
);
static
char
s
[
256
];
lua_add_string_field
(
"id"
,
print_permanent_msg_id
(
M
->
permanent_id
));
unsigned
char
*
mid
=
(
void
*
)
&
M
->
permanent_id
;
int
i
;
for
(
i
=
0
;
i
<
(
int
)
sizeof
(
struct
tgl_message_permanent_id
);
i
++
)
{
sprintf
(
s
+
2
*
i
,
"%02u"
,
(
unsigned
)
mid
[
i
]);
}
lua_add_string_field
(
"id"
,
s
);
if
(
!
(
M
->
flags
&
TGLMF_CREATED
))
{
return
;
}
if
(
!
(
M
->
flags
&
TGLMF_CREATED
))
{
return
;
}
lua_add_num_field
(
"flags"
,
M
->
flags
);
lua_add_num_field
(
"flags"
,
M
->
flags
);
...
@@ -1619,6 +1632,7 @@ enum command_argument {
...
@@ -1619,6 +1632,7 @@ enum command_argument {
ca_user
,
ca_user
,
ca_chat
,
ca_chat
,
ca_secret_chat
,
ca_secret_chat
,
ca_channel
,
ca_peer
,
ca_peer
,
ca_file_name
,
ca_file_name
,
ca_file_name_end
,
ca_file_name_end
,
...
...
telegram.h
View file @
598b4414
...
@@ -21,4 +21,4 @@
...
@@ -21,4 +21,4 @@
#define PROG_NAME "telegram-cli"
#define PROG_NAME "telegram-cli"
#endif
#endif
#define TELEGRAM_CLI_VERSION "1.
3.3
"
#define TELEGRAM_CLI_VERSION "1.
4.0
"
tgl
@
b16c44c7
Subproject commit
119bced18153472c67a674f141960d4e75a4a76b
Subproject commit
b16c44c727f1eec561c2c69eb7373b72ee08a52d
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