@@ -683,6 +683,7 @@ enum lua_query_type {
683
683
lq_load_video_thumb ,
684
684
lq_load_video ,
685
685
lq_chat_info ,
686
+ lq_channel_info ,
686
687
lq_user_info ,
687
688
lq_history ,
688
689
lq_chat_add_user ,
@@ -1034,6 +1035,38 @@ void lua_secret_chat_cb (struct tgl_state *TLSR, void *cb_extra, int success, st
1034
1035
free (cb );
1035
1036
}
1036
1037
1038
+ void lua_channel_cb (struct tgl_state * TLSR , void * cb_extra , int success , struct tgl_channel * C ) {
1039
+ assert (TLSR == TLS );
1040
+ struct lua_query_extra * cb = cb_extra ;
1041
+ lua_settop (luaState , 0 );
1042
+ //lua_checkstack (luaState, 20);
1043
+ my_lua_checkstack (luaState , 20 );
1044
+
1045
+ lua_rawgeti (luaState , LUA_REGISTRYINDEX , cb -> func );
1046
+ lua_rawgeti (luaState , LUA_REGISTRYINDEX , cb -> param );
1047
+
1048
+ lua_pushnumber (luaState , success );
1049
+
1050
+ if (success ) {
1051
+ push_peer (C -> id , (void * )C );
1052
+ } else {
1053
+ lua_pushboolean (luaState , 0 );
1054
+ }
1055
+
1056
+ assert (lua_gettop (luaState ) == 4 );
1057
+
1058
+ int r = ps_lua_pcall (luaState , 3 , 0 , 0 );
1059
+
1060
+ luaL_unref (luaState , LUA_REGISTRYINDEX , cb -> func );
1061
+ luaL_unref (luaState , LUA_REGISTRYINDEX , cb -> param );
1062
+
1063
+ if (r ) {
1064
+ logprintf ("lua: %s\n" , lua_tostring (luaState , -1 ));
1065
+ }
1066
+
1067
+ free (cb );
1068
+ }
1069
+
1037
1070
void lua_user_cb (struct tgl_state * TLSR , void * cb_extra , int success , struct tgl_user * C ) {
1038
1071
assert (TLSR == TLS );
1039
1072
struct lua_query_extra * cb = cb_extra ;
@@ -1211,6 +1244,10 @@ void lua_do_all (void) {
1211
1244
tgl_do_get_chat_info (TLS , lua_ptr [p + 1 ].peer_id , 0 , lua_chat_cb , lua_ptr [p ].ptr );
1212
1245
p += 2 ;
1213
1246
break ;
1247
+ case lq_channel_info :
1248
+ tgl_do_get_channel_info (TLS , lua_ptr [p + 1 ].peer_id , 0 , lua_channel_cb , lua_ptr [p ].ptr );
1249
+ p += 2 ;
1250
+ break ;
1214
1251
case lq_user_info :
1215
1252
tgl_do_get_user_info (TLS , lua_ptr [p + 1 ].peer_id , 0 , lua_user_cb , lua_ptr [p ].ptr );
1216
1253
p += 2 ;
@@ -1379,6 +1416,7 @@ struct lua_function functions[] = {
1379
1416
{"fwd_msg" , lq_fwd , { lfp_peer , lfp_msg , lfp_none }},
1380
1417
{"fwd_media" , lq_fwd_media , { lfp_peer , lfp_msg , lfp_none }},
1381
1418
{"chat_info" , lq_chat_info , { lfp_chat , lfp_none }},
1419
+ {"channel_info" , lq_channel_info , { lfp_channel , lfp_none }},
1382
1420
{"user_info" , lq_user_info , { lfp_user , lfp_none }},
1383
1421
{"get_history" , lq_history , { lfp_peer , lfp_nonnegative_number , lfp_none }},
1384
1422
{"chat_add_user" , lq_chat_add_user , { lfp_chat , lfp_user , lfp_none }},
0 commit comments