Merge branch 'master' into deb
Conflicts: .gitignore
This commit is contained in:
commit
7f11cd568a
3
.gitignore
vendored
3
.gitignore
vendored
@ -12,4 +12,5 @@ objs/
|
||||
dep/
|
||||
auto/
|
||||
libs/
|
||||
debian/telegram-cli*
|
||||
debian/telegram-cli.[a-z]
|
||||
debian/files
|
||||
|
@ -74,5 +74,7 @@ Function_list (arguments are listed aside from cb_function and cb_extra, :
|
||||
status_online ()
|
||||
status_offline ()
|
||||
|
||||
send_location (peer, latitude, longitude)
|
||||
|
||||
Also, you have function
|
||||
postpone (cb_function, cb_extra, timeout). It will call your cb_function in specified number of seconds (number of seconds may be double).
|
||||
|
9
debian/changelog
vendored
9
debian/changelog
vendored
@ -1,5 +1,12 @@
|
||||
telegram-cli (1.0.6-1) unstable; urgency=low
|
||||
|
||||
* Upstream update version
|
||||
* Inpliment -e option
|
||||
|
||||
-- Steve Illichevsky <still.ru@gmail.com> Sun, 05 Oct 2014 09:37:06 +0400
|
||||
|
||||
telegram-cli (1.0.5.1-1) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- Steve Illichevsky <still.ru@gmail.com> Wed, 01 Oct 2014 21:06:28 +0400
|
||||
-- Steve Illichevsky <still.ru@gmail.com> Sun, 05 Oct 2014 09:37:06 +0400
|
||||
|
2
debian/compat
vendored
2
debian/compat
vendored
@ -1 +1 @@
|
||||
8
|
||||
9
|
||||
|
5
debian/control
vendored
5
debian/control
vendored
@ -9,8 +9,9 @@ Build-Depends: debhelper (>= 8.0.0),
|
||||
libconfig-dev,
|
||||
libssl-dev,
|
||||
lua5.1,
|
||||
liblua5.1-dev
|
||||
Standards-Version: 3.9.2
|
||||
liblua5.1-dev,
|
||||
lua-lgi
|
||||
Standards-Version: 3.9.5
|
||||
Homepage: https://github.com/vysheng/tg
|
||||
Vcs-Git: git://github.com/vysheng/tg.git
|
||||
Vcs-Browser: https://github.com/vysheng/tg
|
||||
|
1
debian/files
vendored
1
debian/files
vendored
@ -1 +0,0 @@
|
||||
telegram-cli_1.0.5.1-1_i386.deb net extra
|
48
debian/telegram-cli.debhelper.log
vendored
Normal file
48
debian/telegram-cli.debhelper.log
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
dh_autotools-dev_updateconfig
|
||||
dh_auto_configure
|
||||
dh_auto_build
|
||||
dh_auto_test
|
||||
dh_prep
|
||||
dh_installdirs
|
||||
dh_auto_install
|
||||
dh_install
|
||||
dh_installdocs
|
||||
dh_installchangelogs
|
||||
dh_installexamples
|
||||
dh_installman
|
||||
dh_installcatalogs
|
||||
dh_installcron
|
||||
dh_installdebconf
|
||||
dh_installemacsen
|
||||
dh_installifupdown
|
||||
dh_installinfo
|
||||
dh_installinit
|
||||
dh_installmenu
|
||||
dh_installmime
|
||||
dh_installmodules
|
||||
dh_installlogcheck
|
||||
dh_installlogrotate
|
||||
dh_installpam
|
||||
dh_installppp
|
||||
dh_installudev
|
||||
dh_installwm
|
||||
dh_installxfonts
|
||||
dh_installgsettings
|
||||
dh_bugfiles
|
||||
dh_ucf
|
||||
dh_lintian
|
||||
dh_gconf
|
||||
dh_icons
|
||||
dh_perl
|
||||
dh_usrlocal
|
||||
dh_link
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_strip
|
||||
dh_makeshlibs
|
||||
dh_shlibdeps
|
||||
dh_installdeb
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
dh_builddeb
|
2
debian/telegram-cli.substvars
vendored
Normal file
2
debian/telegram-cli.substvars
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
shlibs:Depends=libc6 (>= 2.8), libconfig8 (>= 1.3.2-2), libevent-2.0-5 (>= 2.0.16-stable), liblua5.1-0, libreadline6 (>= 6.0), libssl1.0.0 (>= 1.0.0), zlib1g (>= 1:1.1.4)
|
||||
misc:Depends=
|
1
debian/telegram-cli/DEBIAN/conffiles
vendored
Normal file
1
debian/telegram-cli/DEBIAN/conffiles
vendored
Normal file
@ -0,0 +1 @@
|
||||
/etc/telegram-cli/server.pub
|
25
debian/telegram-cli/DEBIAN/control
vendored
Normal file
25
debian/telegram-cli/DEBIAN/control
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
Package: telegram-cli
|
||||
Version: 1.0.6-1
|
||||
Architecture: i386
|
||||
Maintainer: Steve Illichevsky <still.ru@gmail.com>
|
||||
Installed-Size: 2414
|
||||
Depends: libc6 (>= 2.8), libconfig8 (>= 1.3.2-2), libevent-2.0-5 (>= 2.0.16-stable), liblua5.1-0, libreadline6 (>= 6.0), libssl1.0.0 (>= 1.0.0), zlib1g (>= 1:1.1.4)
|
||||
Section: net
|
||||
Priority: extra
|
||||
Homepage: https://github.com/vysheng/tg
|
||||
Description: Command-line interface for Telegram messenger
|
||||
Telegram messenger is a cloud-based instant messaging designed for
|
||||
smart phones and similar to Whatsapp but more flexible, and
|
||||
powerful. You can send messages, photos, videos and documents to
|
||||
people who are in your phone contacts (and have Telegram). Telegram
|
||||
also supports secret chats whose provide a private (encrypted) way of
|
||||
communication.
|
||||
.
|
||||
This package contains a command-line based client for Telegram with
|
||||
the following features:
|
||||
* Colored terminal messages.
|
||||
* Message management: history, stats, etc.
|
||||
* Group chat: create and manage groups.
|
||||
* Secret chat: secured and encrypted conversations.
|
||||
* Contact management: add/edit/remove contacts.
|
||||
* Multimedia support: send/load photos and videos.
|
8
debian/telegram-cli/DEBIAN/md5sums
vendored
Normal file
8
debian/telegram-cli/DEBIAN/md5sums
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fa3223ea6f102c82f09722afb471680c usr/bin/telegram-cli
|
||||
a491fae59cac8dfd507f262f60c7145d usr/bin/tlc
|
||||
ee6fbdf0a90599cc893dd1bc52c62df5 usr/share/doc/telegram-cli/README-LUA
|
||||
0ade98b594fb92d79ba3aa69411949aa usr/share/doc/telegram-cli/README.es.gz
|
||||
0136d70c21b079cb72401a7f9f67efcb usr/share/doc/telegram-cli/README.md.gz
|
||||
e3de59df64a4dcca7a4ee2162bed92a7 usr/share/doc/telegram-cli/changelog.Debian.gz
|
||||
340464ada745a0c792764a501e5b5586 usr/share/doc/telegram-cli/copyright
|
||||
6b61123786d05dad4fde589934c08cb8 usr/share/man/man8/telegram-cli.8.gz
|
8
debian/telegram-cli/etc/telegram-cli/server.pub
vendored
Normal file
8
debian/telegram-cli/etc/telegram-cli/server.pub
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
-----BEGIN RSA PUBLIC KEY-----
|
||||
MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6
|
||||
lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS
|
||||
an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw
|
||||
Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+
|
||||
8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n
|
||||
Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
-----END RSA PUBLIC KEY-----
|
80
debian/telegram-cli/usr/share/doc/telegram-cli/README-LUA
vendored
Normal file
80
debian/telegram-cli/usr/share/doc/telegram-cli/README-LUA
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
To use lua with client you should write lua script. You can specify it from config ("lua_script" option) or from command_line [-s].
|
||||
|
||||
It should have several functions:
|
||||
on_binlog_replay_end() - it is called when replay of old events end. Any updates prior this call were already received by this client
|
||||
some time ago.
|
||||
|
||||
on_get_difference_end() - it is called after first get_difference call. So we received all updates after last client execute.
|
||||
|
||||
on_our_id(our_id) - Informs about id of currently logged in user.
|
||||
|
||||
on_msg_receive(msg) - it is called when we receive new msg (!! may be called before on_binlog_replay_end, than it is old msg).
|
||||
|
||||
on_user_update(user,what_changed) - updated info about user. what_changed is array of strings.
|
||||
on_chat_update(user,what_changed) - updated info about user. what_changed is array of strings.
|
||||
on_secret_chat_update(user,what_changed) - updated info about user. what_changed is array of strings.
|
||||
|
||||
|
||||
|
||||
Also, you can call several functions. Each this function last two arguments, are cb_function and cb_extra.
|
||||
These functions may return false immidiately if something is bad with args, or return true and call cb_function in future.
|
||||
cb_function would have two or three arguments: first cb_extra, second success (1 or 0), third result (if applicable).
|
||||
|
||||
If you want to pass msg to function, you should pass it's id.
|
||||
If you want to pass peer to function, you should pass it's print_name.
|
||||
Or, you can pass string user#id<id> chat#id<id> and secret_chat#id<id> as peer. It is in some cases better. For example if you want to postpone and you are afraid, that print_name would be changed in the meantime.
|
||||
|
||||
Function_list (arguments are listed aside from cb_function and cb_extra, :
|
||||
get_contact_list ()
|
||||
get_dialog_list ()
|
||||
|
||||
rename_chat (chat, new_name)
|
||||
chat_set_photo (chat, file)
|
||||
|
||||
send_msg (peer, text)
|
||||
fwd_msg (peer, msg)
|
||||
|
||||
send_photo (peer, file)
|
||||
send_video (peer, file)
|
||||
send_audio (peer, file)
|
||||
send_document (peer, file)
|
||||
send_text (peer, file)
|
||||
|
||||
load_photo(msg)
|
||||
load_video(msg)
|
||||
load_video_thumb(msg)
|
||||
load_audio(msg)
|
||||
load_document(msg)
|
||||
load_document_thumb(msg)
|
||||
|
||||
chat_info (chat)
|
||||
user_info (user)
|
||||
|
||||
get_history (peer, limit)
|
||||
|
||||
chat_add_user (chat, user)
|
||||
chat_del_user (chat, user)
|
||||
|
||||
add_contactt (phone, first_name, last_name)
|
||||
rename_contactt (phone, first_name, last_name)
|
||||
|
||||
msg_search (peer, text)
|
||||
msg_global_search (text)
|
||||
|
||||
mark_read (peer)
|
||||
|
||||
set_profile_photo (file)
|
||||
|
||||
create_secret_chat (user)
|
||||
create_group_chat (user, name)
|
||||
|
||||
delete_msg (msg)
|
||||
restore_msg (number)
|
||||
|
||||
status_online ()
|
||||
status_offline ()
|
||||
|
||||
send_location (peer, latitude, longitude)
|
||||
|
||||
Also, you have function
|
||||
postpone (cb_function, cb_extra, timeout). It will call your cb_function in specified number of seconds (number of seconds may be double).
|
BIN
debian/telegram-cli/usr/share/doc/telegram-cli/README.es.gz
vendored
Normal file
BIN
debian/telegram-cli/usr/share/doc/telegram-cli/README.es.gz
vendored
Normal file
Binary file not shown.
BIN
debian/telegram-cli/usr/share/doc/telegram-cli/README.md.gz
vendored
Normal file
BIN
debian/telegram-cli/usr/share/doc/telegram-cli/README.md.gz
vendored
Normal file
Binary file not shown.
BIN
debian/telegram-cli/usr/share/doc/telegram-cli/changelog.Debian.gz
vendored
Normal file
BIN
debian/telegram-cli/usr/share/doc/telegram-cli/changelog.Debian.gz
vendored
Normal file
Binary file not shown.
31
debian/telegram-cli/usr/share/doc/telegram-cli/copyright
vendored
Normal file
31
debian/telegram-cli/usr/share/doc/telegram-cli/copyright
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
Format: http://dep.debian.net/deps/dep5
|
||||
Upstream-Name: telegram-cli
|
||||
Source: https://github.com/vysheng/tg
|
||||
|
||||
Files: *
|
||||
Copyright: 2013-2014 Vitaly Valtman <https://github.com/vysheng>
|
||||
License: GPL-3.0+
|
||||
|
||||
Files: debian/*
|
||||
Copyright: 2014 Steve Illichevsky <still.ru@gmail.com>
|
||||
License: GPL-3.0+
|
||||
|
||||
License: GPL-3.0+
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
This package is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
|
||||
|
||||
# Please also look if there are files or directories which have a
|
||||
# different copyright/license attached and list them here.
|
BIN
debian/telegram-cli/usr/share/man/man8/telegram-cli.8.gz
vendored
Normal file
BIN
debian/telegram-cli/usr/share/man/man8/telegram-cli.8.gz
vendored
Normal file
Binary file not shown.
50
interface.c
50
interface.c
@ -292,6 +292,23 @@ long long cur_token_int (void) {
|
||||
}
|
||||
}
|
||||
|
||||
double cur_token_double (void) {
|
||||
if (cur_token_len <= 0) {
|
||||
return NOT_FOUND;
|
||||
} else {
|
||||
char c = cur_token[cur_token_len];
|
||||
cur_token[cur_token_len] = 0;
|
||||
char *end = 0;
|
||||
double x = strtod (cur_token, &end);
|
||||
cur_token[cur_token_len] = c;
|
||||
if (end != cur_token + cur_token_len) {
|
||||
return NOT_FOUND;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tgl_peer_id_t cur_token_user (void) {
|
||||
if (cur_token_len <= 0) { return TGL_PEER_NOT_FOUND; }
|
||||
int l = cur_token_len;
|
||||
@ -519,6 +536,7 @@ enum command_argument {
|
||||
ca_file_name_end,
|
||||
ca_period,
|
||||
ca_number,
|
||||
ca_double,
|
||||
ca_string_end,
|
||||
ca_string,
|
||||
ca_modifier,
|
||||
@ -536,6 +554,7 @@ struct arg {
|
||||
struct tgl_message *M;
|
||||
char *str;
|
||||
long long num;
|
||||
double dval;
|
||||
};
|
||||
};
|
||||
|
||||
@ -996,6 +1015,11 @@ void do_clear (int arg_num, struct arg args[], struct in_ev *ev) {
|
||||
do_halt (0);
|
||||
}
|
||||
|
||||
void do_send_location (int arg_num, struct arg args[], struct in_ev *ev) {
|
||||
assert (arg_num == 3);
|
||||
tgl_do_send_location (args[0].P->id, args[1].dval, args[2].dval, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
struct command commands[] = {
|
||||
{"help", {ca_none}, do_help, "help\tPrints this help"},
|
||||
@ -1054,6 +1078,7 @@ struct command commands[] = {
|
||||
{"send_contact", {ca_peer, ca_string, ca_string, ca_string, ca_none}, do_send_contact, "send_contact <peer> <phone> <first-name> <last-name>\tSends contact (not necessary telegram user)"},
|
||||
{"main_session", {ca_none}, do_main_session, "main_session\tSends updates to this connection (or terminal). Useful only with listening socket"},
|
||||
{"clear", {ca_none}, do_clear, "clear\tClears all data and exits. For debug."},
|
||||
{"send_location", {ca_peer, ca_double, ca_double, ca_none}, do_send_location, "send_location <peer> <latitude> <longitude>\tSends geo location"},
|
||||
{0, {ca_none}, 0, ""}
|
||||
};
|
||||
|
||||
@ -1116,7 +1141,7 @@ enum command_argument get_complete_mode (void) {
|
||||
|
||||
char *save = line_ptr;
|
||||
next_token ();
|
||||
if (op == ca_user || op == ca_chat || op == ca_secret_chat || op == ca_peer || op == ca_number) {
|
||||
if (op == ca_user || op == ca_chat || op == ca_secret_chat || op == ca_peer || op == ca_number || op == ca_double) {
|
||||
if (cur_token_quoted) {
|
||||
if (opt) {
|
||||
line_ptr = save;
|
||||
@ -1145,6 +1170,9 @@ enum command_argument get_complete_mode (void) {
|
||||
case ca_number:
|
||||
ok = (cur_token_int () != NOT_FOUND);
|
||||
break;
|
||||
case ca_double:
|
||||
ok = (cur_token_double () != NOT_FOUND);
|
||||
break;
|
||||
default:
|
||||
assert (0);
|
||||
}
|
||||
@ -1230,7 +1258,7 @@ char *command_generator (const char *text, int state) {
|
||||
if (index == -1) { return 0; }
|
||||
}
|
||||
|
||||
if (mode == ca_none || mode == ca_string || mode == ca_string_end || mode == ca_number) {
|
||||
if (mode == ca_none || mode == ca_string || mode == ca_string_end || mode == ca_number || mode == ca_double) {
|
||||
if (c) { rl_line_buffer[rl_point] = c; }
|
||||
return 0;
|
||||
}
|
||||
@ -1999,13 +2027,17 @@ void interpreter_ex (char *line UU, void *ex) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (op == ca_user || op == ca_chat || op == ca_secret_chat || op == ca_peer || op == ca_number) {
|
||||
if (op == ca_user || op == ca_chat || op == ca_secret_chat || op == ca_peer || op == ca_number || op == ca_double) {
|
||||
if (cur_token_quoted) {
|
||||
if (opt) {
|
||||
if (op != ca_number) {
|
||||
if (op != ca_number && op != ca_double) {
|
||||
args[args_num ++].P = 0;
|
||||
} else {
|
||||
if (op == ca_number) {
|
||||
args[args_num ++].num = NOT_FOUND;
|
||||
} else {
|
||||
args[args_num ++].dval = NOT_FOUND;
|
||||
}
|
||||
}
|
||||
line_ptr = save;
|
||||
flags ++;
|
||||
@ -2016,10 +2048,14 @@ void interpreter_ex (char *line UU, void *ex) {
|
||||
} else {
|
||||
if (cur_token_end_str) {
|
||||
if (opt) {
|
||||
if (op != ca_number) {
|
||||
if (op != ca_number && op != ca_double) {
|
||||
args[args_num ++].P = 0;
|
||||
} else {
|
||||
if (op == ca_number) {
|
||||
args[args_num ++].num = NOT_FOUND;
|
||||
} else {
|
||||
args[args_num ++].dval = NOT_FOUND;
|
||||
}
|
||||
}
|
||||
line_ptr = save;
|
||||
flags ++;
|
||||
@ -2050,6 +2086,10 @@ void interpreter_ex (char *line UU, void *ex) {
|
||||
args[args_num ++].num = cur_token_int ();
|
||||
ok = (args[args_num - 1].num != NOT_FOUND);
|
||||
break;
|
||||
case ca_double:
|
||||
args[args_num ++].dval = cur_token_double ();
|
||||
ok = (args[args_num - 1].dval != NOT_FOUND);
|
||||
break;
|
||||
default:
|
||||
assert (0);
|
||||
}
|
||||
|
16
loop.c
16
loop.c
@ -91,6 +91,8 @@ static int delete_stdin_event;
|
||||
|
||||
extern volatile int sigterm_cnt;
|
||||
|
||||
extern char *start_command;
|
||||
|
||||
static void stdin_read_callback_all (int arg, short what, struct event *self) {
|
||||
if (!readline_disabled) {
|
||||
if (((long)arg) & 1) {
|
||||
@ -852,6 +854,20 @@ int loop (void) {
|
||||
lua_diff_end ();
|
||||
#endif
|
||||
|
||||
if (start_command) {
|
||||
safe_quit = 1;
|
||||
while (*start_command) {
|
||||
char *start = start_command;
|
||||
while (*start_command && *start_command != '\n') {
|
||||
start_command ++;
|
||||
}
|
||||
if (*start_command) {
|
||||
*start_command = 0;
|
||||
start_command ++;
|
||||
}
|
||||
interpreter_ex (start, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*tgl_do_get_dialog_list (get_dialogs_callback, 0);
|
||||
if (wait_dialog_list) {
|
||||
|
25
lua-tg.c
25
lua-tg.c
@ -495,6 +495,7 @@ enum lua_query_type {
|
||||
lq_send_contact,
|
||||
lq_status_online,
|
||||
lq_status_offline,
|
||||
lq_send_location,
|
||||
lq_extf
|
||||
};
|
||||
|
||||
@ -1086,6 +1087,14 @@ void lua_do_all (void) {
|
||||
free (s);
|
||||
p += 2;
|
||||
break;
|
||||
case lq_send_location:
|
||||
if (sizeof (void *) == 4) {
|
||||
tgl_do_send_location (((tgl_peer_t *)lua_ptr[p + 1])->id , *(float *)(lua_ptr + p + 2), *(float *)(lua_ptr + p + 3), lua_msg_cb, lua_ptr[p]);
|
||||
} else {
|
||||
tgl_do_send_location (((tgl_peer_t *)lua_ptr[p + 1])->id , *(double *)(lua_ptr + p + 2), *(double *)(lua_ptr + p + 3), lua_msg_cb, lua_ptr[p]);
|
||||
}
|
||||
p += 4;
|
||||
break;
|
||||
/*
|
||||
lq_delete_msg,
|
||||
lq_restore_msg,
|
||||
@ -1120,7 +1129,8 @@ enum lua_function_param {
|
||||
lfp_number,
|
||||
lfp_positive_number,
|
||||
lfp_nonnegative_number,
|
||||
lfp_msg
|
||||
lfp_msg,
|
||||
lfp_double
|
||||
};
|
||||
|
||||
struct lua_function {
|
||||
@ -1168,6 +1178,7 @@ struct lua_function functions[] = {
|
||||
{"send_contact", lq_send_contact, { lfp_peer, lfp_string, lfp_string, lfp_string, lfp_none }},
|
||||
{"status_online", lq_status_online, { lfp_none }},
|
||||
{"status_offline", lq_status_offline, { lfp_none }},
|
||||
{"send_location", lq_send_location, { lfp_peer, lfp_double, lfp_double, lfp_none }},
|
||||
{"ext_function", lq_extf, { lfp_string, lfp_none }},
|
||||
{ 0, 0, { lfp_none}}
|
||||
};
|
||||
@ -1203,6 +1214,7 @@ static int parse_lua_function (lua_State *L, struct lua_function *F) {
|
||||
const char *s;
|
||||
tgl_peer_t *P;
|
||||
long long num;
|
||||
double dval;
|
||||
struct tgl_message *M;
|
||||
switch (F->params[p]) {
|
||||
case lfp_none:
|
||||
@ -1256,6 +1268,17 @@ static int parse_lua_function (lua_State *L, struct lua_function *F) {
|
||||
lua_ptr[pos + p] = (void *)(long)num;
|
||||
break;
|
||||
|
||||
case lfp_double:
|
||||
dval = lua_tonumber (L, -cc);
|
||||
|
||||
if (sizeof (void *) == 4) {
|
||||
*(float *)(lua_ptr + pos + p) = dval;
|
||||
} else {
|
||||
assert (sizeof (void *) >= 8);
|
||||
*(double *)(lua_ptr + pos + p) = dval;
|
||||
}
|
||||
break;
|
||||
|
||||
case lfp_positive_number:
|
||||
num = lua_tonumber (L, -cc);
|
||||
if (num <= 0) {
|
||||
|
12
main.c
12
main.c
@ -111,6 +111,7 @@ int readline_disabled;
|
||||
int disable_output;
|
||||
int reset_authorization;
|
||||
int port;
|
||||
char *start_command;
|
||||
|
||||
void set_default_username (const char *s) {
|
||||
if (default_username) {
|
||||
@ -400,6 +401,11 @@ void parse_config (void) {
|
||||
tasprintf (&secret_chat_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, SECRET_CHAT_FILE);
|
||||
}
|
||||
tgl_set_download_directory (downloads_directory);
|
||||
if (!mkdir (downloads_directory, CONFIG_DIRECTORY_MODE)) {
|
||||
if (!disable_output) {
|
||||
printf ("[%s] created\n", downloads_directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -436,6 +442,7 @@ void usage (void) {
|
||||
printf (" -D disable output\n");
|
||||
printf (" -P <port> port to listen for input commands\n");
|
||||
printf (" -S <socket-name> unix socket to create\n");
|
||||
printf (" -e <commands> make commands end exit\n");
|
||||
|
||||
exit (1);
|
||||
}
|
||||
@ -538,7 +545,7 @@ char *unix_socket;
|
||||
|
||||
void args_parse (int argc, char **argv) {
|
||||
int opt = 0;
|
||||
while ((opt = getopt (argc, argv, "u:hk:vNl:fEwWCRdL:DU:G:qP:S:"
|
||||
while ((opt = getopt (argc, argv, "u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:"
|
||||
#ifdef HAVE_LIBCONFIG
|
||||
"c:p:"
|
||||
#else
|
||||
@ -627,6 +634,9 @@ void args_parse (int argc, char **argv) {
|
||||
case 'S':
|
||||
unix_socket = optarg;
|
||||
break;
|
||||
case 'e':
|
||||
start_command = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
usage ();
|
||||
|
@ -1301,7 +1301,7 @@ void tglmp_on_start (void) {
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
vlogprintf (E_ERROR, "No pubic keys found\n");
|
||||
vlogprintf (E_ERROR, "No public keys found\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
70
queries.c
70
queries.c
@ -1837,9 +1837,7 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
|
||||
out_cstring ((void *)f->key, 32);
|
||||
out_cstring ((void *)f->init_iv, 32);
|
||||
|
||||
long long msg_id;
|
||||
tglt_secure_random (&msg_id, 8);
|
||||
bl_do_create_message_media_encr_pending (msg_id, tgl_state.our_id, tgl_get_peer_type (f->to_id), tgl_get_peer_id (f->to_id), time (0), 0, 0, save_ptr, packet_ptr - save_ptr);
|
||||
bl_do_create_message_media_encr_pending (r, tgl_state.our_id, tgl_get_peer_type (f->to_id), tgl_get_peer_id (f->to_id), time (0), 0, 0, save_ptr, packet_ptr - save_ptr);
|
||||
|
||||
encr_finish (&P->encr_chat);
|
||||
if (f->size < (16 << 20)) {
|
||||
@ -1861,7 +1859,7 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
|
||||
out_int ((*(int *)md5) ^ (*(int *)(md5 + 4)));
|
||||
|
||||
tfree_secure (f->iv, 32);
|
||||
struct tgl_message *M = tgl_message_get (msg_id);
|
||||
struct tgl_message *M = tgl_message_get (r);
|
||||
assert (M);
|
||||
|
||||
//M->media.encr_photo.key = f->key;
|
||||
@ -1997,6 +1995,7 @@ void tgl_do_set_profile_photo (char *file_name, void (*callback)(void *callback_
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ Forward */
|
||||
static int fwd_msg_on_answer (struct query *q UU) {
|
||||
assert (fetch_int () == (int)CODE_messages_stated_message);
|
||||
@ -2147,6 +2146,65 @@ void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callb
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Send location */
|
||||
|
||||
void tgl_do_send_location(tgl_peer_id_t id, double latitude, double longitude, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra) {
|
||||
if (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT) {
|
||||
clear_packet ();
|
||||
out_int (CODE_messages_send_encrypted);
|
||||
out_int (CODE_input_encrypted_chat);
|
||||
out_int (tgl_get_peer_id (id));
|
||||
tgl_peer_t *P = tgl_peer_get (id);
|
||||
assert (P);
|
||||
out_long (P->encr_chat.access_hash);
|
||||
|
||||
long long r;
|
||||
tglt_secure_random (&r, 8);
|
||||
out_long (r);
|
||||
encr_start ();
|
||||
if (P->encr_chat.layer <= 16) {
|
||||
out_int (CODE_decrypted_message_l16);
|
||||
} else {
|
||||
out_int (CODE_decrypted_message);
|
||||
out_int (2 * P->encr_chat.in_seq_no + (P->encr_chat.admin_id != tgl_state.our_id));
|
||||
out_int (2 * P->encr_chat.out_seq_no + (P->encr_chat.admin_id == tgl_state.our_id) + 2);
|
||||
out_int (0);
|
||||
}
|
||||
out_long (r);
|
||||
out_random (15 + 4 * (lrand48 () % 3));
|
||||
out_string ("");
|
||||
int *save_ptr = packet_ptr;
|
||||
out_int (CODE_decrypted_message_media_geo_point);
|
||||
out_double (latitude);
|
||||
out_double (longitude);
|
||||
|
||||
bl_do_create_message_media_encr_pending (r, tgl_state.our_id, tgl_get_peer_type (id), tgl_get_peer_id (id), time (0), 0, 0, save_ptr, packet_ptr - save_ptr);
|
||||
|
||||
encr_finish (&P->encr_chat);
|
||||
|
||||
struct tgl_message *M = tgl_message_get (r);
|
||||
assert (M);
|
||||
|
||||
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &msg_send_encr_methods, M, callback, callback_extra);
|
||||
} else {
|
||||
long long t;
|
||||
tglt_secure_random (&t, 8);
|
||||
vlogprintf (E_DEBUG, "t = %lld\n", t);
|
||||
|
||||
clear_packet ();
|
||||
out_int (CODE_messages_send_media);
|
||||
out_peer_id (id);
|
||||
out_int (CODE_input_media_geo_point);
|
||||
out_int (CODE_input_geo_point);
|
||||
out_double (latitude);
|
||||
out_double (longitude);
|
||||
out_long (t);
|
||||
|
||||
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Rename chat */
|
||||
static int rename_chat_on_answer (struct query *q UU) {
|
||||
assert (fetch_int () == (int)CODE_messages_stated_message);
|
||||
@ -2415,6 +2473,10 @@ static int download_on_answer (struct query *q) {
|
||||
struct download *D = q->extra;
|
||||
if (D->fd == -1) {
|
||||
D->fd = open (D->name, O_CREAT | O_WRONLY, 0640);
|
||||
if (D->fd < 0) {
|
||||
vlogprintf (E_ERROR, "Can not open for writing: %m\n");
|
||||
assert (D->fd >= 0);
|
||||
}
|
||||
}
|
||||
fetch_int (); // mtime
|
||||
int len = prefetch_strlen ();
|
||||
|
@ -540,8 +540,8 @@ void tglf_fetch_photo_size (struct tgl_photo_size *S) {
|
||||
void tglf_fetch_geo (struct tgl_geo *G) {
|
||||
unsigned x = fetch_int ();
|
||||
if (x == CODE_geo_point) {
|
||||
G->longitude = fetch_double ();
|
||||
G->latitude = fetch_double ();
|
||||
G->longitude = fetch_double ();
|
||||
} else {
|
||||
assert (x == CODE_geo_point_empty);
|
||||
G->longitude = 0;
|
||||
@ -951,8 +951,8 @@ void tglf_fetch_message_media_encrypted (struct tgl_message_media *M) {
|
||||
*/
|
||||
case CODE_decrypted_message_media_geo_point:
|
||||
M->type = tgl_message_media_geo;
|
||||
M->geo.longitude = fetch_double ();
|
||||
M->geo.latitude = fetch_double ();
|
||||
M->geo.longitude = fetch_double ();
|
||||
break;
|
||||
case CODE_decrypted_message_media_contact:
|
||||
M->type = tgl_message_media_contact;
|
||||
|
1
tgl.h
1
tgl.h
@ -295,6 +295,7 @@ void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, co
|
||||
void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
||||
void tgl_do_del_contact (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra);
|
||||
void tgl_do_set_encr_chat_ttl (struct tgl_secret_chat *E, int ttl, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
||||
void tgl_do_send_location(tgl_peer_id_t id, double latitude, double longitude, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
||||
|
||||
|
||||
void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user