break;
+ case LU_PRIVNOTICE:
+ np = (nick *)args[0];
+ p = (char *)args[1];
+
+ if(!np || !p)
+ return;
+
+ lua_vlpcall(l, ln, "irc_onnotice", "Ns", np, p);
+
+ break;
+
case LU_CHANMSG:
np = (nick *)args[0];
c = (channel *)args[1];
break;
case LU_KILLED:
- p = (char *)args[2];
- lua_vlpcall(l, ln, "irc_onkilled", "s", p);
+ lua_vlpcall(l, ln, "irc_onkilled", "");
strlcpy(ln->nickname, target->nick, sizeof(ln->nickname));
strlcpy(ln->ident, target->ident, sizeof(ln->ident));
np = (nick *)args[0];
c = (channel *)args[1];
- if(!c || !np || !c->index || !c->index->name || !c->index->name->content)
+ if(!c || !np || !c->index || !c->index->name)
return;
lua_vlpcall(l, ln, "irc_oninvite", "Ns", np, c->index->name->content);
LUA_RETURN(ps, LUA_OK);
}
+static int lua_localchanopnotice(lua_State *ps) {
+ char *msg;
+ nick *source;
+ channel *target;
+
+ 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);
+
+ target = findchannel((char *)lua_tostring(ps, 2));
+ if(!target)
+ LUA_RETURN(ps, LUA_FAIL);
+
+ msg = (char *)lua_tostring(ps, 3);
+
+ if(!lua_lineok(msg))
+ LUA_RETURN(ps, LUA_FAIL);
+
+ sendopnoticetochannel(source, target, "%s", msg);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
static int lua_localnotice(lua_State *ps) {
char *msg;
nick *source;
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);
+
+ LUA_RETURN(ps, LUA_OK);
+}
+
void lua_registerlocalcommands(lua_State *l) {
lua_register(l, "irc_localregisteruserid", lua_registerlocaluserid);
lua_register(l, "irc_localderegisteruser", lua_deregisterlocaluser);
lua_register(l, "irc_localumodes", lua_localumodes);
lua_register(l, "irc_localrename", lua_localrename);
+
+ lua_register(l, "irc_localwallusers", lua_localwallusers);
+ lua_register(l, "irc_localwallops", lua_localwallops);
+
+ lua_register(l, "irc_localsimplechanmode", lua_localsimplechanmode);
+ lua_register(l, "irc_localchanopnotice", lua_localchanopnotice);
}