]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Export the mask matching function to lua (to match bans, ignores, etc.).
authorThomas Sader <redacted>
Sun, 23 Feb 2014 14:18:28 +0000 (15:18 +0100)
committerThomas Sader <redacted>
Sun, 23 Feb 2014 14:18:28 +0000 (15:18 +0100)
lua/luacommands.c

index 1d96ac66d9c4d2283be5dff26bb60a55c0cf95fd..222396ad14be7025acf26e12b11d3a177c373028 100644 (file)
@@ -364,6 +364,21 @@ static int lua_numerictobase64(lua_State *ps) {
   return 1;
 }
 
+static int lua_match(lua_State *ps) {
+  const char *mask, *string;
+
+  if(!lua_isstring(ps, 1) || !lua_isstring(ps, 2))
+    return 0;
+
+  mask = lua_tostring(ps, 1);
+  string = lua_tostring(ps, 2);
+
+  if (!mask || !mask[0] || !string || !string[0])
+    return 0;
+
+  LUA_RETURN(ps, match2strings(mask, string));
+}
+
 static int lua_getuserbyauth(lua_State *l) {
   nick *np;
   int found = 0;
@@ -887,6 +902,7 @@ void lua_registercommands(lua_State *l) {
   lua_register(l, "irc_sethost", lua_sethost);
 
   lua_register(l, "irc_numerictobase64", lua_numerictobase64);
+  lua_register(l, "irc_match", lua_match);
 }
 
 /* --- */