Commit 3c6b54c6 authored by Vincent Castellano's avatar Vincent Castellano

Merging to remove bad branch

parent 5fcb8254
...@@ -19,7 +19,7 @@ DIR_LIST=${DEP} ${AUTO} ${EXE} ${OBJ} ${LIB} ${DEP}/auto ${OBJ}/auto ...@@ -19,7 +19,7 @@ DIR_LIST=${DEP} ${AUTO} ${EXE} ${OBJ} ${LIB} ${DEP}/auto ${OBJ}/auto
EXE_LIST=${EXE}/telegram-cli EXE_LIST=${EXE}/telegram-cli
TG_OBJECTS=${OBJ}/main.o ${OBJ}/loop.o ${OBJ}/interface.o ${OBJ}/lua-tg.o ${OBJ}/json-tg.o TG_OBJECTS=${OBJ}/main.o ${OBJ}/loop.o ${OBJ}/interface.o ${OBJ}/lua-tg.o ${OBJ}/json-tg.o ${OBJ}/python-tg.o
INCLUDE=-I. -I${srcdir} -I${srcdir}/tgl INCLUDE=-I. -I${srcdir} -I${srcdir}/tgl
CC=@CC@ CC=@CC@
......
...@@ -167,6 +167,9 @@ ...@@ -167,6 +167,9 @@
/* fixed for correct valgrind work */ /* fixed for correct valgrind work */
#undef VALGRIND_FIXES #undef VALGRIND_FIXES
/* use python */
#undef USE_PYTHON
/* Define to `int' if <sys/types.h> doesn't define. */ /* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t #undef gid_t
......
This diff is collapsed.
...@@ -59,6 +59,10 @@ ...@@ -59,6 +59,10 @@
# include "lua-tg.h" # include "lua-tg.h"
#endif #endif
#ifdef USE_PYTHON
# include "python-tg.h"
#endif
//#include "mtproto-common.h" //#include "mtproto-common.h"
#include <tgl/tgl.h> #include <tgl/tgl.h>
...@@ -1265,6 +1269,7 @@ extern char *downloads_directory; ...@@ -1265,6 +1269,7 @@ extern char *downloads_directory;
extern char *config_directory; extern char *config_directory;
extern char *binlog_file_name; extern char *binlog_file_name;
extern char *lua_file; extern char *lua_file;
extern char *python_file;
extern struct event *term_ev; extern struct event *term_ev;
void do_clear (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { void do_clear (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
...@@ -1279,6 +1284,7 @@ void do_clear (struct command *command, int arg_num, struct arg args[], struct i ...@@ -1279,6 +1284,7 @@ void do_clear (struct command *command, int arg_num, struct arg args[], struct i
free (config_directory); free (config_directory);
free (binlog_file_name); free (binlog_file_name);
free (lua_file); free (lua_file);
free (python_file);
clear_history (); clear_history ();
event_free (term_ev); event_free (term_ev);
struct event_base *ev_base = TLS->ev_base; struct event_base *ev_base = TLS->ev_base;
...@@ -2307,6 +2313,9 @@ void print_message_gw (struct tgl_state *TLSR, struct tgl_message *M) { ...@@ -2307,6 +2313,9 @@ void print_message_gw (struct tgl_state *TLSR, struct tgl_message *M) {
#ifdef USE_LUA #ifdef USE_LUA
lua_new_msg (M); lua_new_msg (M);
#endif #endif
#ifdef USE_PYTHON
py_new_msg (M);
#endif
if (!binlog_read) { return; } if (!binlog_read) { return; }
if (tgl_get_peer_type (M->to_id) == TGL_PEER_ENCR_CHAT) { if (tgl_get_peer_type (M->to_id) == TGL_PEER_ENCR_CHAT) {
write_secret_chat_file (); write_secret_chat_file ();
...@@ -2336,6 +2345,9 @@ void our_id_gw (struct tgl_state *TLSR, int id) { ...@@ -2336,6 +2345,9 @@ void our_id_gw (struct tgl_state *TLSR, int id) {
#ifdef USE_LUA #ifdef USE_LUA
lua_our_id (id); lua_our_id (id);
#endif #endif
#ifdef USE_PYTHON
py_our_id (id);
#endif
} }
void print_peer_updates (struct in_ev *ev, int flags) { void print_peer_updates (struct in_ev *ev, int flags) {
...@@ -2401,7 +2413,10 @@ void user_update_gw (struct tgl_state *TLSR, struct tgl_user *U, unsigned flags) ...@@ -2401,7 +2413,10 @@ void user_update_gw (struct tgl_state *TLSR, struct tgl_user *U, unsigned flags)
#ifdef USE_LUA #ifdef USE_LUA
lua_user_update (U, flags); lua_user_update (U, flags);
#endif #endif
#ifdef USE_PYTHON
py_user_update (U, flags);
#endif
if (disable_output && !notify_ev) { return; } if (disable_output && !notify_ev) { return; }
if (!binlog_read) { return; } if (!binlog_read) { return; }
struct in_ev *ev = notify_ev; struct in_ev *ev = notify_ev;
...@@ -2432,7 +2447,10 @@ void chat_update_gw (struct tgl_state *TLSR, struct tgl_chat *U, unsigned flags) ...@@ -2432,7 +2447,10 @@ void chat_update_gw (struct tgl_state *TLSR, struct tgl_chat *U, unsigned flags)
#ifdef USE_LUA #ifdef USE_LUA
lua_chat_update (U, flags); lua_chat_update (U, flags);
#endif #endif
#ifdef USE_PYTHON
py_chat_update (U, flags);
#endif
if (disable_output && !notify_ev) { return; } if (disable_output && !notify_ev) { return; }
if (!binlog_read) { return; } if (!binlog_read) { return; }
struct in_ev *ev = notify_ev; struct in_ev *ev = notify_ev;
...@@ -2463,7 +2481,12 @@ void secret_chat_update_gw (struct tgl_state *TLSR, struct tgl_secret_chat *U, u ...@@ -2463,7 +2481,12 @@ void secret_chat_update_gw (struct tgl_state *TLSR, struct tgl_secret_chat *U, u
#ifdef USE_LUA #ifdef USE_LUA
lua_secret_chat_update (U, flags); lua_secret_chat_update (U, flags);
#endif #endif
#ifdef USE_PYTHON
py_secret_chat_update (U, flags);
#endif
if ((flags & TGL_UPDATE_WORKING) || (flags & TGL_UPDATE_DELETED)) { if ((flags & TGL_UPDATE_WORKING) || (flags & TGL_UPDATE_DELETED)) {
write_secret_chat_file (); write_secret_chat_file ();
} }
......
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
# include "lua-tg.h" # include "lua-tg.h"
#endif #endif
#ifdef USE_PYTHON
# include "python-tg.h"
#endif
#include <tgl/tgl.h> #include <tgl/tgl.h>
#define PROGNAME "telegram-cli" #define PROGNAME "telegram-cli"
...@@ -107,6 +111,7 @@ char *downloads_directory; ...@@ -107,6 +111,7 @@ char *downloads_directory;
char *config_directory; char *config_directory;
char *binlog_file_name; char *binlog_file_name;
char *lua_file; char *lua_file;
char *python_file;
int binlog_enabled; int binlog_enabled;
extern int log_level; extern int log_level;
int sync_from_start; int sync_from_start;
...@@ -381,6 +386,10 @@ void parse_config (void) { ...@@ -381,6 +386,10 @@ void parse_config (void) {
parse_config_val (&conf, &lua_file, "lua_script", 0, config_directory); parse_config_val (&conf, &lua_file, "lua_script", 0, config_directory);
} }
if (!python_file) {
parse_config_val (&conf, &python_file, "python_script", 0, config_directory);
}
strcpy (buf + l, "binlog_enabled"); strcpy (buf + l, "binlog_enabled");
config_lookup_bool (&conf, buf, &binlog_enabled); config_lookup_bool (&conf, buf, &binlog_enabled);
...@@ -698,6 +707,11 @@ void args_parse (int argc, char **argv) { ...@@ -698,6 +707,11 @@ void args_parse (int argc, char **argv) {
break; break;
#endif #endif
case 'W': case 'W':
#ifdef USE_PYTHON
case 'Z':
python_file = strdup (optarg);
break;
#endif
wait_dialog_list = 1; wait_dialog_list = 1;
break; break;
case 'C': case 'C':
...@@ -942,6 +956,12 @@ int main (int argc, char **argv) { ...@@ -942,6 +956,12 @@ int main (int argc, char **argv) {
lua_init (lua_file); lua_init (lua_file);
} }
#endif #endif
#ifdef USE_PYTHON
if (python_file) {
py_init (python_file);
}
#endif
inner_main (); inner_main ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment