mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Lua received room and private message hooks
This commit is contained in:
parent
170601b85b
commit
942f2c0a9d
@ -177,14 +177,48 @@ char *
|
||||
lua_on_private_message_received_hook(ProfPlugin *plugin, const char * const room,
|
||||
const char * const nick, const char *message)
|
||||
{
|
||||
return NULL;
|
||||
int *p_ref = (int *)plugin->module;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, *p_ref);
|
||||
lua_pushstring(L, "prof_on_private_message_received");
|
||||
lua_gettable(L, -2);
|
||||
lua_pushstring(L, room);
|
||||
lua_pushstring(L, nick);
|
||||
lua_pushstring(L, message);
|
||||
int res2 = lua_pcall(L, 3, 1, 0);
|
||||
lua_check_error(res2);
|
||||
|
||||
char *result = NULL;
|
||||
if (lua_isstring(L, -1)) {
|
||||
result = strdup(lua_tostring(L, -1));
|
||||
}
|
||||
|
||||
lua_pop(L, 2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
lua_on_room_message_received_hook(ProfPlugin *plugin, const char * const room,
|
||||
const char * const nick, const char *message)
|
||||
{
|
||||
return NULL;
|
||||
int *p_ref = (int *)plugin->module;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, *p_ref);
|
||||
lua_pushstring(L, "prof_on_room_message_received");
|
||||
lua_gettable(L, -2);
|
||||
lua_pushstring(L, room);
|
||||
lua_pushstring(L, nick);
|
||||
lua_pushstring(L, message);
|
||||
int res2 = lua_pcall(L, 3, 1, 0);
|
||||
lua_check_error(res2);
|
||||
|
||||
char *result = NULL;
|
||||
if (lua_isstring(L, -1)) {
|
||||
result = strdup(lua_tostring(L, -1));
|
||||
}
|
||||
|
||||
lua_pop(L, 2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -37,7 +37,6 @@ python_env_init(void)
|
||||
python_check_error();
|
||||
python_api_init();
|
||||
python_check_error();
|
||||
// TODO change to use XDG spec
|
||||
GString *path = g_string_new(Py_GetPath());
|
||||
g_string_append(path, ":");
|
||||
gchar *plugins_dir = plugins_get_dir();
|
||||
|
Loading…
Reference in New Issue
Block a user