Skip to content
This repository has been archived by the owner on Oct 14, 2018. It is now read-only.

Commit

Permalink
get_message, resolve_username and media_caption patch.
Browse files Browse the repository at this point in the history
	modified:   launch.sh
	new file:   patches/lua-tg.get_message.resolve_username.media_caption.patch
  • Loading branch information
Sahri Riza Umami committed Jan 7, 2016
1 parent 653f50b commit 7a8c841
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ install() {
git pull
git submodule update --init --recursive
patch -i "patches/disable-python-and-libjansson.patch" -p 0 --batch --forward
patch -i "patches/lua-tg.get_message.resolve_username.media_caption.patch" -p 0 --batch --forward
RET=$?;

cd tg
Expand Down
84 changes: 84 additions & 0 deletions patches/lua-tg.get_message.resolve_username.media_caption.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
--- tg/lua-tg.c 2016-01-07 13:34:15.093728000 +0700
+++ tg/lua-tg.resolve_username.get_message.c 2016-01-07 13:42:27.780179744 +0700
@@ -293,6 +293,7 @@
case tgl_message_media_document_encr:
lua_newtable (luaState);
lua_add_string_field ("type", "document");
+ lua_add_string_field ("caption", M->document->caption);
break;
case tgl_message_media_unsupported:
lua_newtable (luaState);
@@ -718,7 +719,9 @@
lq_channel_invite_user,
lq_channel_kick_user,
lq_channel_get_admins,
- lq_channel_get_users
+ lq_channel_get_users,
+ lq_contact_search,
+ lq_get_message
};

struct lua_query_extra {
@@ -1138,6 +1141,38 @@
free (cb);
}

+void lua_contact_search_cb (struct tgl_state *TLSR, void *cb_extra, int success, tgl_peer_t *C) {
+ assert (TLSR == TLS);
+ struct lua_query_extra *cb = cb_extra;
+ lua_settop (luaState, 0);
+ //lua_checkstack (luaState, 20);
+ my_lua_checkstack (luaState, 20);
+
+ lua_rawgeti (luaState, LUA_REGISTRYINDEX, cb->func);
+ lua_rawgeti (luaState, LUA_REGISTRYINDEX, cb->param);
+
+ lua_pushnumber (luaState, success);
+
+ if (success) {
+ push_peer (C->id, (void *)C);
+ } else {
+ lua_pushboolean (luaState, 0);
+ }
+
+ assert (lua_gettop (luaState) == 4);
+
+ int r = ps_lua_pcall (luaState, 3, 0, 0);
+
+ luaL_unref (luaState, LUA_REGISTRYINDEX, cb->func);
+ luaL_unref (luaState, LUA_REGISTRYINDEX, cb->param);
+
+ if (r) {
+ logprintf ("lua: %s\n", lua_tostring (luaState, -1));
+ }
+
+ free (cb);
+}
+
#define LUA_STR_ARG(n) lua_ptr[n].str, strlen (lua_ptr[n].str)

void lua_do_all (void) {
@@ -1363,6 +1398,14 @@
tgl_do_channel_get_members (TLS, lua_ptr[p + 1].peer_id, 100, 0, 0, lua_contact_list_cb, lua_ptr[p].ptr);
p += 2;
break;
+ case lq_contact_search:
+ tgl_do_contact_search (TLS, LUA_STR_ARG (p + 1), lua_contact_search_cb, lua_ptr[p].ptr);
+ p += 2;
+ break;
+ case lq_get_message:
+ tgl_do_get_message (TLS, &lua_ptr[p + 1].msg_id, lua_msg_cb, lua_ptr[p].ptr);
+ p += 2;
+ break;
/*
lq_delete_msg,
lq_restore_msg,
@@ -1468,6 +1511,8 @@
{"channel_kick_user", lq_channel_kick_user, { lfp_channel, lfp_user, lfp_none }},
{"channel_get_admins", lq_channel_get_admins, { lfp_channel, lfp_none }},
{"channel_get_users", lq_channel_get_users, { lfp_channel, lfp_none }},
+ {"resolve_username", lq_contact_search, { lfp_string, lfp_none }},
+ {"get_message", lq_get_message, { lfp_msg, lfp_none }},
{ 0, 0, { lfp_none}}
};

0 comments on commit 7a8c841

Please sign in to comment.