if(!l)
return 0;
- ln = (lua_localnick *)malloc(sizeof(lua_localnick));
+ ln = (lua_localnick *)luamalloc(sizeof(lua_localnick));
if(!ln)
return 0;
ln->nick = registerlocaluser(nickname, ident, hostname, realname, account, modes, &lua_localnickhandler);
if(!ln->nick) {
- free(ln);
+ luafree(ln);
return 0;
}
luaL_unref(ps, LUA_REGISTRYINDEX, l->handler);
- free(l);
+ luafree(l);
}
int lua_getlocalnickbynick(nick *np, lua_list **rl, lua_localnick **rln) {
LUA_RETURN(ps, LUA_FAIL);
chan = (char *)lua_tostring(ps, 2);
+ if(chan[0] != '#')
+ LUA_RETURN(ps, LUA_FAIL);
if(!lua_lineok(chan))
LUA_RETURN(ps, LUA_FAIL);
static int lua_localpart(lua_State *ps) {
nick *source;
channel *target;
- char *chan;
+ char *chan, *reason;
if(!lua_islong(ps, 1) || !lua_isstring(ps, 2))
LUA_RETURN(ps, LUA_FAIL);
if(!lua_lineok(chan))
LUA_RETURN(ps, LUA_FAIL);
-
+
+ if(lua_isstring(ps, 3)) {
+ reason = (char *)lua_tostring(ps, 3);
+ if(!lua_lineok(reason))
+ LUA_RETURN(ps, LUA_FAIL);
+ } else {
+ reason = NULL;
+ }
+
target = findchannel(chan);
if(target) {
- localpartchannel(source, target);
+ localpartchannel(source, target, reason);
} else {
LUA_RETURN(ps, LUA_FAIL);
}
static int lua_localovmode(lua_State *l) {
nick *source;
channel *chan;
- int state = 0, add, realmode, ignoring = 0;
+ int state = 0, add = 0, realmode = 0, ignoring = 0;
modechanges changes;
if(!lua_islong(l, 1) || !lua_isstring(l, 2) || !lua_istable(l, 3))
LUA_RETURN(l, LUA_OK);
}
+static int lua_localumodes(lua_State *ps) {
+ nick *np;
+ char *modes;
+ flag_t newmodes = 0;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ np = getnickbynumeric(lua_tolong(ps, 1));
+ if(!np)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ modes = (char *)lua_tostring(ps, 2);
+
+ setflags(&newmodes, UMODE_ALL, modes, umodeflags, REJECT_NONE);
+
+ localusersetumodes(np, newmodes);
+ LUA_RETURN(ps, LUA_OK);
+}
+
static int lua_localtopic(lua_State *ps) {
nick *np;
channel *cp;
lua_register(l, "irc_localban", lua_localban);
lua_register(l, "irc_localkick", lua_localkick);
+ lua_register(l, "irc_localumodes", lua_localumodes);
}