+static int lua_nickmatchban(lua_State *ps) {
+ const char *chanban_str;
+ long numeric;
+ chanban *cb;
+ nick *np;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2))
+ return 0;
+
+ numeric = lua_tolong(ps, 1);
+ chanban_str = lua_tostring(ps, 2);
+
+ np = getnickbynumeric(numeric);
+ if(!np)
+ return 0;
+
+ cb = makeban(chanban_str);
+ if(!cb)
+ return 0;
+
+ lua_pushboolean(ps, nickmatchban(np, cb, 1));
+
+ freechanban(cb);
+
+ return 1;
+}
+
+static int lua_nickbanned(lua_State *ps) {
+ const char *channel_str;
+ long numeric;
+ channel *cp;
+ nick *np;
+
+ if(!lua_islong(ps, 1) || !lua_isstring(ps, 2))
+ return 0;
+
+ numeric = lua_tolong(ps, 1);
+ channel_str = lua_tostring(ps, 2);
+
+ np = getnickbynumeric(numeric);
+ if(!np)
+ return 0;
+
+ cp = findchannel((char *)channel_str);
+ if(!cp)
+ return 0;
+
+ lua_pushboolean(ps, nickbanned(np, cp, 1));
+
+ return 1;
+}
+
+static int lua_suggestbanmask(lua_State *ps) {
+ nick *np;
+ glinebuf gb;
+ gline *gl;
+ long numeric;
+ int i = 1;
+
+ if (!lua_islong(ps, 1))
+ return 0;
+
+ numeric = lua_tolong(ps, 1);
+
+ np = getnickbynumeric(numeric);
+ if (!np)
+ return 0;
+
+ glinebufinit(&gb, 0);
+ glinebufaddbynick(&gb, np, 0, "Auto", "None", time(NULL), time(NULL), time(NULL));
+
+ lua_newtable(ps);
+
+ for (gl = gb.glines; gl; gl = gl->next) {
+ if (gl->host && gl->host->content) {
+ char *mask = glinetostring(gl);
+ LUA_APUSHSTRING(ps, i, mask);
+ i++;
+ }
+ }
+
+ glinebufabort(&gb);
+
+ return 1;
+}
+
+static int lua_nickistrusted(lua_State *ps) {
+ long numeric;
+ nick *np;
+
+ if(!lua_islong(ps, 1))
+ return 0;
+
+ numeric = lua_tolong(ps, 1);
+
+ np = getnickbynumeric(numeric);
+ if(!np)
+ return 0;
+
+ lua_pushboolean(ps, istrusted(np));
+
+ return 1;
+}
+