X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/15a91b41493c79276ca1e59c09500eeb0fea888d..1151d736b86e4405ed9e0266dc5227a2ab9a5d66:/lua/luacommands.c diff --git a/lua/luacommands.c b/lua/luacommands.c index 79a8277a..205bafc4 100644 --- a/lua/luacommands.c +++ b/lua/luacommands.c @@ -38,8 +38,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); @@ -47,6 +47,8 @@ void lua_initchanpusher(void); #define lua_setupnickpusher(L2, I2, P2, M2) lua_setuppusher(&nickpusher[0], L2, I2, P2, M2, nickpushercount) #define lua_setupchanpusher(L2, I2, P2, M2) lua_setuppusher(&chanpusher[0], L2, I2, P2, M2, chanpushercount) +int lua_cmsg(char *channell, char *message, ...) __attribute__ ((format (printf, 2, 3))); + int lua_cmsg(char *channell, char *message, ...) { char buf[512]; va_list va; @@ -258,7 +260,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)); } @@ -368,6 +370,12 @@ static int lua_basepath(lua_State *ps) { return 1; } +static int lua_botnick(lua_State *ps) { + lua_pushstring(ps, luabotnick->content); + + return 1; +} + /* O(n) */ static int lua_getuserbyauth(lua_State *l) { const char *acc; @@ -381,7 +389,7 @@ static int lua_getuserbyauth(lua_State *l) { for(i=0;inext) { - if(np && np->authname && !ircd_strcmp(np->authname, acc)) { + if(np && np->authname[0] && !ircd_strcmp(np->authname, acc)) { lua_pushnumeric(l, np->numeric); found++; } @@ -844,6 +852,7 @@ void lua_registercommands(lua_State *l) { lua_register(l, "chanmsg", lua_chanmsg); lua_register(l, "versioninfo", lua_versioninfo); lua_register(l, "basepath", lua_basepath); + lua_register(l, "botnick", lua_botnick); lua_register(l, "irc_report", lua_chanmsg); lua_register(l, "irc_ctcp", lua_ctcp); @@ -940,6 +949,7 @@ static int lua_skill(lua_State *ps) { #define PUSHER_REALUSERS 11 #define PUSHER_CHANMODES 12 #define PUSHER_TIMESTAMP 13 +#define PUSHER_STRING_INDIRECT 14 void lua_initnickpusher(void) { int i = 0; @@ -951,7 +961,7 @@ void lua_initnickpusher(void) { PUSH_NICKPUSHER(PUSHER_STRING, ident); PUSH_NICKPUSHER(PUSHER_HOSTNAME, host); PUSH_NICKPUSHER(PUSHER_REALNAME, realname); - PUSH_NICKPUSHER(PUSHER_STRING, authname); + PUSH_NICKPUSHER(PUSHER_STRING_INDIRECT, authname); PUSH_NICKPUSHER(PUSHER_IP, ipnode); PUSH_NICKPUSHER(PUSHER_LONG, numeric); PUSH_NICKPUSHER(PUSHER_LONG, timestamp); @@ -963,7 +973,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) @@ -992,7 +1002,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) { @@ -1002,6 +1012,9 @@ INLINE int lua_usepusher(lua_State *l, struct lua_pusher **lp, void *np) { case PUSHER_STRING: lua_pushstring(l, (char *)offset); break; + case PUSHER_STRING_INDIRECT: + lua_pushstring(l, *(char **)offset); + break; case PUSHER_HOSTNAME: lua_pushstring(l, (*(host **)offset)->name->content); break; @@ -1036,7 +1049,7 @@ INLINE int lua_usepusher(lua_State *l, struct lua_pusher **lp, void *np) { continue; if((np2=getnickbynumeric(cp->users->content[i]))==NULL) { - Error("lua", ERR_ERROR, "Found unknown numeric %u on channel %s", cp->users->content[i], cp->index->name->content); + Error("lua", ERR_ERROR, "Found unknown numeric %lu on channel %s", cp->users->content[i], cp->index->name->content); continue; }