+ localsettopic(np, cp, topic);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int lua_localban(lua_State *ps) {
+ channel *cp;
+ const char *mask;
+ modechanges changes;
+ nick *source;
+
+ int dir = MCB_ADD;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2) || !lua_isstring(ps, 3))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ if(lua_isboolean(ps, 4) && lua_toboolean(ps, 4))
+ dir = MCB_DEL;
+
+ source = getnickbynumeric(lua_tolong(ps, 1));
+
+ cp = findchannel((char *)lua_tostring(ps, 2));
+ if(!cp)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ mask = lua_tostring(ps, 3);
+ if(!mask || !mask[0] || !lua_lineok(mask))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ localsetmodeinit(&changes, cp, source);
+ localdosetmode_ban(&changes, mask, dir);
+ localsetmodeflush(&changes, 1);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int lua_localkick(lua_State *ps) {
+ const char *n, *msg, *chan;
+ nick *source, *np;
+ channel *cp;
+ int dochecks = 1;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2) || !lua_isstring(ps, 3) || !lua_isstring(ps, 4))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ source = getnickbynumeric(lua_tolong(ps, 1));
+ chan = lua_tostring(ps, 2);
+ n = lua_tostring(ps, 3);
+ msg = lua_tostring(ps, 4);
+ if(!source)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ if(lua_isboolean(ps, 4) && !lua_toboolean(ps, 4))
+ dochecks = 0;
+
+ np = getnickbynick(n);
+ if(!np)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ if(dochecks && (IsOper(np) || IsXOper(np) || IsService(np)))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ cp = findchannel((char *)chan);
+ if(!cp)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ if(!lua_lineok(msg))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ localkickuser(source, cp, np, msg);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int lua_localrename(lua_State *ps) {
+ nick *np;
+ char *changeto;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2) )
+ LUA_RETURN(ps, LUA_FAIL);
+
+ np = getnickbynumeric(lua_tolong(ps, 1));
+ changeto = (char *)lua_tostring(ps, 2);
+
+ if(!lua_lineok(changeto))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ renamelocaluser(np, changeto);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int lua_localwallusers(lua_State *ps) {
+ char *msg;
+ nick *source;
+ char senderstr[6];
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ source = getnickbynumeric(lua_tolong(ps, 1));
+ if(!source)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ msg = (char *)lua_tostring(ps, 2);
+
+ if(!lua_lineok(msg))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ longtonumeric2(source->numeric,5,senderstr);
+ irc_send("%s WU :%s", senderstr, msg);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int lua_localwallops(lua_State *ps) {
+ char *msg;
+ nick *source;
+ char senderstr[6];
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ source = getnickbynumeric(lua_tolong(ps, 1));
+ if(!source)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ msg = (char *)lua_tostring(ps, 2);
+
+ if(!lua_lineok(msg))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ longtonumeric2(source->numeric,5,senderstr);
+ irc_send("%s WA :%s", senderstr, msg);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
+static int lua_localsimplechanmode(lua_State *ps) {
+ nick *source;
+ channel *cp;
+ char *modes;
+ flag_t add = 0, del = ~add;
+ flag_t permitted = CHANMODE_NOEXTMSG | CHANMODE_TOPICLIMIT | CHANMODE_SECRET | CHANMODE_PRIVATE | CHANMODE_INVITEONLY | CHANMODE_MODERATE | CHANMODE_NOCOLOUR | CHANMODE_NOCTCP | CHANMODE_REGONLY | CHANMODE_DELJOINS | CHANMODE_NOQUITMSG | CHANMODE_NONOTICE | CHANMODE_MODNOAUTH | CHANMODE_SINGLETARG;
+ modechanges changes;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2) || !lua_isstring(ps, 3))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ source = getnickbynumeric(lua_tolong(ps, 1));
+ if(!source)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ cp = findchannel((char *)lua_tostring(ps, 2));
+ if(!cp)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ modes = (char *)lua_tostring(ps, 3);
+ if(!modes)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ if(setflags(&add, permitted, modes, cmodeflags, REJECT_DISALLOWED|REJECT_UNKNOWN) != REJECT_NONE)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ if(setflags(&del, permitted, modes, cmodeflags, REJECT_DISALLOWED|REJECT_UNKNOWN) != REJECT_NONE)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ localsetmodeinit(&changes, cp, source);
+ localdosetmode_simple(&changes, add, ~del);
+ localsetmodeflush(&changes, 1);