Added search query. But it seems, that search does not use stemmer
This commit is contained in:
parent
970cbcd3c7
commit
b70f868e0b
14
interface.c
14
interface.c
@ -231,6 +231,7 @@ char *commands[] = {
|
||||
"add_contact",
|
||||
"rename_contact",
|
||||
"show_license",
|
||||
"search",
|
||||
0 };
|
||||
|
||||
int commands_flags[] = {
|
||||
@ -256,6 +257,7 @@ int commands_flags[] = {
|
||||
07,
|
||||
071,
|
||||
07,
|
||||
072,
|
||||
};
|
||||
|
||||
int get_complete_mode (void) {
|
||||
@ -671,6 +673,18 @@ void interpreter (char *line UU) {
|
||||
#include "LICENSE.h"
|
||||
;
|
||||
printf ("%s", b);
|
||||
} else if (IS_WORD ("search")) {
|
||||
GET_PEER;
|
||||
int from = 0;
|
||||
int to = 0;
|
||||
int limit = 40;
|
||||
int t;
|
||||
char *s = next_token (&t);
|
||||
if (!s) {
|
||||
printf ("Empty message\n");
|
||||
RET;
|
||||
}
|
||||
do_msg_search (id, from, to, limit, s);
|
||||
}
|
||||
#undef IS_WORD
|
||||
#undef RET
|
||||
|
@ -261,6 +261,7 @@ static inline void out_bignum (BIGNUM *n) {
|
||||
|
||||
extern int *in_ptr, *in_end;
|
||||
|
||||
void fetch_pts (void);
|
||||
static inline int prefetch_strlen (void) {
|
||||
if (in_ptr >= in_end) {
|
||||
return -1;
|
||||
|
28
queries.c
28
queries.c
@ -607,12 +607,12 @@ int msg_send_on_answer (struct query *q UU) {
|
||||
assert (fetch_int () == (int)CODE_messages_sent_message);
|
||||
int id = fetch_int (); // id
|
||||
int date = fetch_int (); // date
|
||||
int ptr = fetch_int (); // ptr
|
||||
fetch_pts ();
|
||||
int seq = fetch_int (); // seq
|
||||
struct message *M = q->extra;
|
||||
M->id = id;
|
||||
message_insert (M);
|
||||
logprintf ("Sent: id = %d, date = %d, ptr = %d, seq = %d\n", id, date, ptr, seq);
|
||||
logprintf ("Sent: id = %d, date = %d, seq = %d\n", id, date, seq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -725,7 +725,7 @@ int get_history_on_answer (struct query *q UU) {
|
||||
for (i = 0; i < n; i++) {
|
||||
fetch_alloc_user ();
|
||||
}
|
||||
if (sn > 0) {
|
||||
if (sn > 0 && q->extra) {
|
||||
do_messages_mark_read (*(peer_id_t *)&(q->extra), ML[0]->id);
|
||||
}
|
||||
return 0;
|
||||
@ -1447,3 +1447,25 @@ void do_add_contact (const char *phone, int phone_len, const char *first_name, i
|
||||
out_int (force ? CODE_bool_true : CODE_bool_false);
|
||||
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &add_contact_methods, 0);
|
||||
}
|
||||
|
||||
int msg_search_on_answer (struct query *q UU) {
|
||||
return get_history_on_answer (q);
|
||||
}
|
||||
|
||||
struct query_methods msg_search_methods = {
|
||||
.on_answer = msg_search_on_answer
|
||||
};
|
||||
|
||||
void do_msg_search (peer_id_t id, int from, int to, int limit, const char *s) {
|
||||
clear_packet ();
|
||||
out_int (CODE_messages_search);
|
||||
out_peer_id (id);
|
||||
out_string (s);
|
||||
out_int (CODE_input_messages_filter_empty);
|
||||
out_int (from);
|
||||
out_int (to);
|
||||
out_int (0); // offset
|
||||
out_int (0); // max_id
|
||||
out_int (limit);
|
||||
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &msg_search_methods, 0);
|
||||
}
|
||||
|
@ -92,5 +92,6 @@ int do_send_code_result_auth (const char *code, const char *first_name, const ch
|
||||
void do_import_auth (int num);
|
||||
void do_export_auth (int num);
|
||||
void do_add_contact (const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, int force);
|
||||
void do_msg_search (peer_id_t id, int from, int to, int limit, const char *s);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user