1
0
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:
James Booth 2013-09-15 15:51:39 +01:00
parent 170601b85b
commit 942f2c0a9d
2 changed files with 36 additions and 3 deletions

View File

@ -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 *

View File

@ -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();