LUA_RETURN(ps, LUA_OK);
}
+static int a4stats_lua_set_privacy(lua_State *ps) {
+ const char *channel;
+ unsigned long privacy;
+
+ if (!lua_isstring(ps, 1) || !lua_isnumber(ps, 2))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ channel = lua_tostring(ps, 1);
+ privacy = lua_tonumber(ps, 2);
+
+ a4statsdb->squery(a4statsdb, "UPDATE ? SET privacy = ? WHERE name = ?", "TUs", "channels", privacy, channel);
+ LUA_RETURN(ps, LUA_OK);
+}
+
static int a4stats_lua_add_kick(lua_State *ps) {
unsigned long channelid, kickerid, victimid;
const char *kicker, *victim, *reason;
LUA_RETURN(ps, LUA_OK);
}
+static int a4stats_lua_db_begin(lua_State *ps) {
+ a4statsdb->query(a4statsdb, NULL, NULL, "BEGIN TRANSACTION", "");
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int a4stats_lua_db_commit(lua_State *ps) {
+ a4statsdb->query(a4statsdb, NULL, NULL, "COMMIT TRANSACTION", "");
+ LUA_RETURN(ps, LUA_OK);
+}
+
static void a4stats_hook_loadscript(int hooknum, void *arg) {
void **args = arg;
lua_State *l = args[1];
lua_register(l, "a4_enable_channel", a4stats_lua_enable_channel);
lua_register(l, "a4_disable_channel", a4stats_lua_disable_channel);
+ lua_register(l, "a4_set_privacy", a4stats_lua_set_privacy);
lua_register(l, "a4_fetch_channels", a4stats_lua_fetch_channels);
lua_register(l, "a4_add_kick", a4stats_lua_add_kick);
lua_register(l, "a4_add_topic", a4stats_lua_add_topic);
lua_register(l, "a4_update_user", a4stats_lua_update_user);
lua_register(l, "a4_update_relation", a4stats_lua_update_relation);
lua_register(l, "a4_escape_string", a4stats_lua_escape_string);
+ lua_register(l, "a4_db_begin", a4stats_lua_db_begin);
+ lua_register(l, "a4_db_commit", a4stats_lua_db_commit);
}
#define lua_unregister(L, n) (lua_pushnil(L), lua_setglobal(L, n))
lua_unregister(l->l, "a4_enable_channel");
lua_unregister(l->l, "a4_disable_channel");
+ lua_unregister(l->l, "a4_set_privacy");
lua_unregister(l->l, "a4_fetch_channels");
lua_unregister(l->l, "a4_add_kick");
lua_unregister(l->l, "a4_add_topic");
lua_unregister(l->l, "a4_update_user");
lua_unregister(l->l, "a4_update_relation");
lua_unregister(l->l, "a4_escape_string");
+ lua_unregister(l->l, "a4_db_begin");
+ lua_unregister(l->l, "a4_db_commit");
}
deregisterhook(HOOK_LUA_LOADSCRIPT, a4stats_hook_loadscript);