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
b43ab0a5
Commit
b43ab0a5
authored
Jun 17, 2015
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for custom keyboard
parent
b9447e6a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
9 deletions
+36
-9
CHANGELOG
CHANGELOG
+2
-0
interface.c
interface.c
+30
-5
lua-tg.c
lua-tg.c
+1
-1
python-tg.c
python-tg.c
+1
-1
telegram.h
telegram.h
+1
-1
tgl
tgl
+1
-1
No files found.
CHANGELOG
View file @
b43ab0a5
1.3.3
* support for sending custom keyboard
1.3.2
1.3.2
* use TGL-2.0.2
* use TGL-2.0.2
* add block/unblock user methods
* add block/unblock user methods
...
...
interface.c
View file @
b43ab0a5
...
@@ -86,6 +86,12 @@
...
@@ -86,6 +86,12 @@
# include "json-tg.h"
# include "json-tg.h"
#endif
#endif
#include "tgl/mtproto-common.h"
#include "auto/auto-store.h"
#include "auto/auto-fetch-ds.h"
#include "auto/auto-types.h"
#include "auto/auto-free-ds.h"
#define ALLOW_MULT 1
#define ALLOW_MULT 1
char
*
default_prompt
=
"> "
;
char
*
default_prompt
=
"> "
;
...
@@ -127,14 +133,13 @@ extern int daemonize;
...
@@ -127,14 +133,13 @@ extern int daemonize;
extern
struct
tgl_state
*
TLS
;
extern
struct
tgl_state
*
TLS
;
int
readline_deactivated
;
int
readline_deactivated
;
void
fail_interface
(
struct
tgl_state
*
TLS
,
struct
in_ev
*
ev
,
int
error_code
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
4
,
5
)));
void
event_incoming
(
struct
bufferevent
*
bev
,
short
what
,
void
*
_arg
);
void
event_incoming
(
struct
bufferevent
*
bev
,
short
what
,
void
*
_arg
);
int
is_same_word
(
const
char
*
s
,
size_t
l
,
const
char
*
word
)
{
int
is_same_word
(
const
char
*
s
,
size_t
l
,
const
char
*
word
)
{
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
}
}
void
fail_interface
(
struct
tgl_state
*
TLS
,
struct
in_ev
*
ev
,
int
error_code
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
4
,
5
)));
static
void
skip_wspc
(
void
)
{
static
void
skip_wspc
(
void
)
{
while
(
*
line_ptr
&&
((
unsigned
char
)
*
line_ptr
)
<=
' '
)
{
while
(
*
line_ptr
&&
((
unsigned
char
)
*
line_ptr
)
<=
' '
)
{
line_ptr
++
;
line_ptr
++
;
...
@@ -746,7 +751,27 @@ void do_msg (struct command *command, int arg_num, struct arg args[], struct in_
...
@@ -746,7 +751,27 @@ void do_msg (struct command *command, int arg_num, struct arg args[], struct in_
assert
(
arg_num
==
2
);
assert
(
arg_num
==
2
);
if
(
ev
)
{
ev
->
refcnt
++
;
}
if
(
ev
)
{
ev
->
refcnt
++
;
}
vlogprintf
(
E_DEBUG
,
"reply_id=%d, disable=%d
\n
"
,
reply_id
,
disable_msg_preview
);
vlogprintf
(
E_DEBUG
,
"reply_id=%d, disable=%d
\n
"
,
reply_id
,
disable_msg_preview
);
tgl_do_send_message
(
TLS
,
args
[
0
].
P
->
id
,
ARG2STR
(
1
),
TGL_SEND_MSG_FLAG_REPLY
(
reply_id
)
|
disable_msg_preview
,
print_msg_success_gw
,
ev
);
tgl_do_send_message
(
TLS
,
args
[
0
].
P
->
id
,
ARG2STR
(
1
),
TGL_SEND_MSG_FLAG_REPLY
(
reply_id
)
|
disable_msg_preview
,
NULL
,
print_msg_success_gw
,
ev
);
}
void
do_msg_kbd
(
struct
command
*
command
,
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
assert
(
arg_num
==
3
);
if
(
ev
)
{
ev
->
refcnt
++
;
}
clear_packet
();
if
(
tglf_store_type
(
TLS
,
ARG2STR
(
1
),
TYPE_TO_PARAM
(
reply_markup
))
<
0
)
{
fail_interface
(
TLS
,
ev
,
ENOSYS
,
"can not parse reply markup"
);
return
;
}
in_ptr
=
packet_buffer
;
in_end
=
packet_ptr
;
struct
tl_ds_reply_markup
*
DS_RM
=
fetch_ds_type_reply_markup
(
TYPE_TO_PARAM
(
reply_markup
));
assert
(
DS_RM
);
tgl_do_send_message
(
TLS
,
args
[
0
].
P
->
id
,
ARG2STR
(
2
),
TGL_SEND_MSG_FLAG_REPLY
(
reply_id
)
|
disable_msg_preview
,
DS_RM
,
print_msg_success_gw
,
ev
);
free_ds_type_reply_markup
(
DS_RM
,
TYPE_TO_PARAM
(
reply_markup
));
}
}
void
do_reply
(
struct
command
*
command
,
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
void
do_reply
(
struct
command
*
command
,
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
...
@@ -1392,6 +1417,7 @@ struct command commands[MAX_COMMANDS_SIZE] = {
...
@@ -1392,6 +1417,7 @@ struct command commands[MAX_COMMANDS_SIZE] = {
{
"main_session"
,
{
ca_none
},
do_main_session
,
"main_session
\t
Sends updates to this connection (or terminal). Useful only with listening socket"
,
NULL
},
{
"main_session"
,
{
ca_none
},
do_main_session
,
"main_session
\t
Sends updates to this connection (or terminal). Useful only with listening socket"
,
NULL
},
{
"mark_read"
,
{
ca_peer
,
ca_none
},
do_mark_read
,
"mark_read <peer>
\t
Marks messages with peer as read"
,
NULL
},
{
"mark_read"
,
{
ca_peer
,
ca_none
},
do_mark_read
,
"mark_read <peer>
\t
Marks messages with peer as read"
,
NULL
},
{
"msg"
,
{
ca_peer
,
ca_msg_string_end
,
ca_none
},
do_msg
,
"msg <peer> <text>
\t
Sends text message to peer"
,
NULL
},
{
"msg"
,
{
ca_peer
,
ca_msg_string_end
,
ca_none
},
do_msg
,
"msg <peer> <text>
\t
Sends text message to peer"
,
NULL
},
{
"msg_kbd"
,
{
ca_peer
,
ca_string
,
ca_msg_string_end
,
ca_none
},
do_msg_kbd
,
"msg <peer> <kbd> <text>
\t
Sends text message to peer with custom kbd"
,
NULL
},
{
"quit"
,
{
ca_none
},
do_quit
,
"quit
\t
Quits immediately"
,
NULL
},
{
"quit"
,
{
ca_none
},
do_quit
,
"quit
\t
Quits immediately"
,
NULL
},
{
"rename_chat"
,
{
ca_chat
,
ca_string_end
,
ca_none
},
do_rename_chat
,
"rename_chat <chat> <new name>
\t
Renames chat"
,
NULL
},
{
"rename_chat"
,
{
ca_chat
,
ca_string_end
,
ca_none
},
do_rename_chat
,
"rename_chat <chat> <new name>
\t
Renames chat"
,
NULL
},
{
"rename_contact"
,
{
ca_user
,
ca_string
,
ca_string
,
ca_none
},
do_rename_contact
,
"rename_contact <user> <first name> <last name>
\t
Renames contact"
,
NULL
},
{
"rename_contact"
,
{
ca_user
,
ca_string
,
ca_string
,
ca_none
},
do_rename_contact
,
"rename_contact <user> <first name> <last name>
\t
Renames contact"
,
NULL
},
...
@@ -1837,7 +1863,6 @@ void print_fail (struct in_ev *ev) {
...
@@ -1837,7 +1863,6 @@ void print_fail (struct in_ev *ev) {
mprint_end
(
ev
);
mprint_end
(
ev
);
}
}
void
fail_interface
(
struct
tgl_state
*
TLS
,
struct
in_ev
*
ev
,
int
error_code
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
4
,
5
)));
void
fail_interface
(
struct
tgl_state
*
TLS
,
struct
in_ev
*
ev
,
int
error_code
,
const
char
*
format
,
...)
{
void
fail_interface
(
struct
tgl_state
*
TLS
,
struct
in_ev
*
ev
,
int
error_code
,
const
char
*
format
,
...)
{
static
char
error
[
1001
];
static
char
error
[
1001
];
...
@@ -2299,7 +2324,7 @@ void interpreter_chat_mode (char *line) {
...
@@ -2299,7 +2324,7 @@ void interpreter_chat_mode (char *line) {
return
;
return
;
}
}
if
(
strlen
(
line
)
>
0
)
{
if
(
strlen
(
line
)
>
0
)
{
tgl_do_send_message
(
TLS
,
chat_mode_id
,
line
,
strlen
(
line
),
0
,
0
,
0
);
tgl_do_send_message
(
TLS
,
chat_mode_id
,
line
,
strlen
(
line
),
0
,
NULL
,
0
,
0
);
}
}
}
}
...
...
lua-tg.c
View file @
b43ab0a5
...
@@ -1026,7 +1026,7 @@ void lua_do_all (void) {
...
@@ -1026,7 +1026,7 @@ void lua_do_all (void) {
tgl_do_get_dialog_list
(
TLS
,
100
,
0
,
lua_dialog_list_cb
,
lua_ptr
[
p
++
]);
tgl_do_get_dialog_list
(
TLS
,
100
,
0
,
lua_dialog_list_cb
,
lua_ptr
[
p
++
]);
break
;
break
;
case
lq_msg
:
case
lq_msg
:
tgl_do_send_message
(
TLS
,
((
tgl_peer_t
*
)
lua_ptr
[
p
+
1
])
->
id
,
lua_ptr
[
p
+
2
],
strlen
(
lua_ptr
[
p
+
2
]),
0
,
lua_msg_cb
,
lua_ptr
[
p
]);
tgl_do_send_message
(
TLS
,
((
tgl_peer_t
*
)
lua_ptr
[
p
+
1
])
->
id
,
lua_ptr
[
p
+
2
],
strlen
(
lua_ptr
[
p
+
2
]),
0
,
NULL
,
lua_msg_cb
,
lua_ptr
[
p
]);
free
(
lua_ptr
[
p
+
2
]);
free
(
lua_ptr
[
p
+
2
]);
p
+=
3
;
p
+=
3
;
break
;
break
;
...
...
python-tg.c
View file @
b43ab0a5
...
@@ -817,7 +817,7 @@ void py_do_all (void) {
...
@@ -817,7 +817,7 @@ void py_do_all (void) {
}
}
flags
|=
TGL_SEND_MSG_FLAG_REPLY
(
reply_id
);
flags
|=
TGL_SEND_MSG_FLAG_REPLY
(
reply_id
);
}
}
tgl_do_send_message
(
TLS
,
PY_PEER_ID
(
peer
),
str
,
len
,
flags
,
py_msg_cb
,
cb_extra
);
tgl_do_send_message
(
TLS
,
PY_PEER_ID
(
peer
),
str
,
len
,
flags
,
NULL
,
py_msg_cb
,
cb_extra
);
}
else
}
else
PyErr_Print
();
PyErr_Print
();
...
...
telegram.h
View file @
b43ab0a5
...
@@ -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.
2
"
#define TELEGRAM_CLI_VERSION "1.3.
3
"
tgl
@
d9769636
Subproject commit
73482c7a461ff4341ea098dd258b6373f530ab70
Subproject commit
d9769636bcd5d2b209c956e15eca4a81f9e677e9
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