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
8f638258
Commit
8f638258
authored
Jan 24, 2014
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added delete/restore messages queries
parent
bc8e97cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
4 deletions
+78
-4
interface.c
interface.c
+29
-3
queries.c
queries.c
+47
-0
queries.h
queries.h
+2
-1
No files found.
interface.c
View file @
8f638258
...
...
@@ -46,7 +46,7 @@
#include "mtproto-common.h"
//
#define ALLOW_MULT 1
#define ALLOW_MULT 1
char
*
default_prompt
=
"> "
;
int
unread_messages
;
...
...
@@ -86,14 +86,14 @@ char *next_token (int *l) {
char
*
s
=
line_ptr
;
int
in_str
=
0
;
while
(
*
line_ptr
&&
(
*
line_ptr
!=
' '
||
neg
||
in_str
))
{
if
(
*
line_ptr
==
'\\'
)
{
/*
if (*line_ptr == '\\') {
neg = 1 - neg;
} else {
if (*line_ptr == '"' && !neg) {
in_str = !in_str;
}
neg = 0;
}
}
*/
line_ptr
++
;
}
*
l
=
line_ptr
-
s
;
...
...
@@ -320,6 +320,8 @@ char *commands[] = {
"view_document"
,
"set"
,
"chat_with_peer"
,
"delete_msg"
,
"restore_msg"
,
0
};
int
commands_flags
[]
=
{
...
...
@@ -368,6 +370,8 @@ int commands_flags[] = {
07
,
07
,
072
,
07
,
07
};
...
...
@@ -1067,6 +1071,28 @@ void interpreter (char *line UU) {
GET_PEER
;
in_chat_mode
=
1
;
chat_mode_id
=
id
;
}
else
if
(
IS_WORD
(
"delete_msg"
))
{
long
long
num
=
next_token_int
();
if
(
num
==
NOT_FOUND
)
{
printf
(
"Bad msg id
\n
"
);
RET
;
}
do_delete_msg
(
num
);
}
else
if
(
IS_WORD
(
"restore_msg"
))
{
long
long
num
=
next_token_int
();
if
(
num
==
NOT_FOUND
)
{
printf
(
"Bad msg id
\n
"
);
RET
;
}
do_restore_msg
(
num
);
}
else
if
(
IS_WORD
(
"delete_restore_msg"
))
{
long
long
num
=
next_token_int
();
if
(
num
==
NOT_FOUND
)
{
printf
(
"Bad msg id
\n
"
);
RET
;
}
do_delete_msg
(
num
);
do_restore_msg
(
num
);
}
else
if
(
IS_WORD
(
"quit"
))
{
exit
(
0
);
}
else
if
(
IS_WORD
(
"safe_quit"
))
{
...
...
queries.c
View file @
8f638258
...
...
@@ -2746,6 +2746,53 @@ void do_create_secret_chat (peer_id_t id) {
}
/* }}} */
/* {{{ Delete msg */
int
delete_msg_on_answer
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
fetch_skip
(
n
);
logprintf
(
"Deleted %d messages
\n
"
,
n
);
return
0
;
}
struct
query_methods
delete_msg_methods
=
{
.
on_answer
=
delete_msg_on_answer
};
void
do_delete_msg
(
long
long
id
)
{
clear_packet
();
out_int
(
CODE_messages_delete_messages
);
out_int
(
CODE_vector
);
out_int
(
1
);
out_int
(
id
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
delete_msg_methods
,
0
);
}
/* }}} */
/* {{{ Restore msg */
int
restore_msg_on_answer
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
fetch_skip
(
n
);
logprintf
(
"Restored %d messages
\n
"
,
n
);
return
0
;
}
struct
query_methods
restore_msg_methods
=
{
.
on_answer
=
restore_msg_on_answer
};
void
do_restore_msg
(
long
long
id
)
{
clear_packet
();
out_int
(
CODE_messages_restore_messages
);
out_int
(
CODE_vector
);
out_int
(
1
);
out_int
(
id
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
restore_msg_methods
,
0
);
}
/* }}} */
int
update_status_on_answer
(
struct
query
*
q
UU
)
{
fetch_bool
();
return
0
;
...
...
queries.h
View file @
8f638258
...
...
@@ -111,7 +111,8 @@ void do_del_user_from_chat (peer_id_t chat_id, peer_id_t id);
void
do_update_status
(
int
online
);
void
do_contacts_search
(
int
limit
,
const
char
*
s
);
void
do_send_msg
(
struct
message
*
M
);
void
do_delete_msg
(
long
long
id
);
void
do_restore_msg
(
long
long
id
);
// For binlog
...
...
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