]> jfr.im git - irc/quakenet/newserv.git/blobdiff - lua/lualocal.c
LUA: port luadb to dbapi2 to drop postgres dependency
[irc/quakenet/newserv.git] / lua / lualocal.c
index 329c14bfc42bc59bd638b7e2094c754296342fe3..86993baeee7267e6c76ded7213a0030c0465ae73 100644 (file)
@@ -201,7 +201,7 @@ void lua_localnickhandler(nick *target, int type, void **args) {
       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);
@@ -315,6 +315,32 @@ static int lua_localchanmsg(lua_State *ps) {
   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;
@@ -668,5 +694,6 @@ void lua_registerlocalcommands(lua_State *l) {
   lua_register(l, "irc_localwallops", lua_localwallops);
 
   lua_register(l, "irc_localsimplechanmode", lua_localsimplechanmode);
+  lua_register(l, "irc_localchanopnotice", lua_localchanopnotice);
 }