]> jfr.im git - irc/quakenet/newserv.git/blobdiff - lua/luacommands.c
LUA: add irc_numerictobase64.
[irc/quakenet/newserv.git] / lua / luacommands.c
index c1a55f9b63affd48cf8fd91c3f5e2ccd4ec298d9..bb6e003f9bb4ca018ddb032bdf259354972023d3 100644 (file)
@@ -16,6 +16,7 @@
 #include "../localuser/localuserchannel.h"
 #include "../lib/irc_string.h"
 #include "../lib/flags.h"
+#include "../authext/authext.h"
 
 #include "lua.h"
 #include "luabot.h"
@@ -38,8 +39,8 @@ struct lua_pusher nickpusher[MAX_PUSHER];
 struct lua_pusher chanpusher[MAX_PUSHER];
 int nickpushercount, chanpushercount;
 
-INLINE void lua_setuppusher(struct lua_pusher *pusherlist, lua_State *l, int index, struct lua_pusher **lp, int max, int pcount);
-INLINE int lua_usepusher(lua_State *l, struct lua_pusher **lp, void *np);
+void lua_setuppusher(struct lua_pusher *pusherlist, lua_State *l, int index, struct lua_pusher **lp, int max, int pcount);
+int lua_usepusher(lua_State *l, struct lua_pusher **lp, void *np);
 
 void lua_initnickpusher(void);
 void lua_initchanpusher(void);
@@ -260,7 +261,7 @@ static int lua_gline(lua_State *ps) {
     snprintf(mask, sizeof(mask), "*@%s", IPtostr(target->p_ipaddr));
   }
 
-  irc_send("%s GL * +%s %d :%s", mynumeric->content, mask, duration, reason);
+  irc_send("%s GL * +%s %d %jd :%s", mynumeric->content, mask, duration, (intmax_t)getnettime(), reason);
   LUA_RETURN(ps, lua_cmsg(LUA_PUKECHAN, "lua-GLINE: %s (%d users, %d seconds -- %s)", mask, usercount, duration, reason));
 }
 
@@ -376,24 +377,29 @@ static int lua_botnick(lua_State *ps) {
   return 1;
 }
 
-/* O(n) */
+static int lua_numerictobase64(lua_State *ps) {
+  if(!lua_islong(ps, 1))
+    return 0;
+
+  lua_pushstring(ps, longtonumeric(lua_tolong(ps, 1), 5));
+  return 1;
+}
+
 static int lua_getuserbyauth(lua_State *l) {
-  const char *acc;
   nick *np;
-  int i, found = 0;
+  int found = 0;
+  authname *au;
 
   if(!lua_isstring(l, 1))
     return 0;
 
-  acc = lua_tostring(l, 1);
+  au = getauthbyname(lua_tostring(l, 1));
+  if(!au)
+    return 0;
 
-  for(i=0;i<NICKHASHSIZE;i++) {
-    for(np=nicktable[i];np;np=np->next) {
-      if(np && np->authname[0] && !ircd_strcmp(np->authname, acc)) {  
-        lua_pushnumeric(l, np->numeric);
-        found++;
-      }
-    }
+  for(np=au->nicks;np;np=np->nextbyauthname) {
+    lua_pushnumeric(l, np->numeric);
+    found++;
   }
 
   return found;
@@ -900,6 +906,8 @@ void lua_registercommands(lua_State *l) {
 
   lua_register(l, "irc_simplechanmode", lua_simplechanmode);
   lua_register(l, "irc_sethost", lua_sethost);
+
+  lua_register(l, "irc_numerictobase64", lua_numerictobase64);
 }
 
 /* --- */
@@ -973,7 +981,7 @@ void lua_initnickpusher(void) {
   nickpusher[i].argtype = 0;
 }
 
-INLINE void lua_setuppusher(struct lua_pusher *pusherlist, lua_State *l, int index, struct lua_pusher **lp, int max, int pcount) {
+void lua_setuppusher(struct lua_pusher *pusherlist, lua_State *l, int index, struct lua_pusher **lp, int max, int pcount) {
   int current = 0;
 
   if(max > 0)
@@ -1002,7 +1010,7 @@ INLINE void lua_setuppusher(struct lua_pusher *pusherlist, lua_State *l, int ind
   lp[current] = NULL;
 }
 
-INLINE int lua_usepusher(lua_State *l, struct lua_pusher **lp, void *np) {
+int lua_usepusher(lua_State *l, struct lua_pusher **lp, void *np) {
   int i = 0;
 
   while(*lp) {