]> jfr.im git - irc/quakenet/newserv.git/blobdiff - lua/luabot.c
CHANNEL/LUA: Add ability to see old modes to HOOK_CHANNEL_MODECHANGE.
[irc/quakenet/newserv.git] / lua / luabot.c
index 9e7ae143748a1e9fc79b987c13ff1b56c354f123..10aea58ec6e6e4c49c37fe96179ecc9f1ed9bc18 100644 (file)
@@ -455,16 +455,25 @@ char *printallmodes(channel *cp) {
   return buf;
 }
 
+static char *printlimitedmodes(channel *cp, flag_t before) {
+  static char buf[1024];
+
+  snprintf(buf, sizeof(buf), "%s", printflags(cp->flags, cmodeflags));
+
+  return buf;
+}
+
 void lua_onmode(int hooknum, void *arg) {
   void **arglist = (void **)arg;
   channel *cp = (channel *)arglist[0];
   chanindex *ci = cp->index;
   nick *np = arglist[1];
+  flag_t beforeflags = (flag_t)(long)arglist[3];
 
   if(np) {
-    lua_avpcall("irc_onmode", "Sls", ci->name, np->numeric, printallmodes(cp));
+    lua_avpcall("irc_onmode", "Slss", ci->name, np->numeric, printallmodes(cp), printlimitedmodes(cp, beforeflags));
   } else {
-    lua_avpcall("irc_onmode", "S0s", ci->name, printallmodes(cp));
+    lua_avpcall("irc_onmode", "S0ss", ci->name, printallmodes(cp), printlimitedmodes(cp, beforeflags));
   }
 }