#include "../localuser/localuserchannel.h"
#include "../lib/irc_string.h"
#include "../lib/flags.h"
+#include "../authext/authext.h"
#include "lua.h"
#include "luabot.h"
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);
if(!cp)
LUA_RETURN(ps, LUA_FAIL);
- localinvite(lua_nick, cp, np);
+ localinvite(lua_nick, cp->index, np);
LUA_RETURN(ps, LUA_OK);
}
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;
lua_register(l, "irc_simplechanmode", lua_simplechanmode);
lua_register(l, "irc_sethost", lua_sethost);
+
+ lua_register(l, "irc_numerictobase64", lua_numerictobase64);
}
/* --- */
#define PUSHER_CHANMODES 12
#define PUSHER_TIMESTAMP 13
#define PUSHER_STRING_INDIRECT 14
+#define PUSHER_ACC_ID 15
+#define PUSHER_SERVER_NAME 16
+#define PUSHER_SERVER_NUMERIC 17
void lua_initnickpusher(void) {
int i = 0;
PUSH_NICKPUSHER(PUSHER_LONG, accountts);
PUSH_NICKPUSHER(PUSHER_UMODES, umodes);
PUSH_NICKPUSHER_CUSTOM(PUSHER_COUNTRY, "country");
+ PUSH_NICKPUSHER_CUSTOM(PUSHER_ACC_ID, "accountid");
+ PUSH_NICKPUSHER_CUSTOM(PUSHER_SERVER_NAME, "servername");
+ PUSH_NICKPUSHER_CUSTOM(PUSHER_SERVER_NUMERIC, "servernumeric");
nickpushercount = i;
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)
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) {
case PUSHER_CHANMODES:
lua_pushstring(l, printallmodes(*((channel **)offset)));
break;
+ case PUSHER_ACC_ID:
+ {
+ nick *tnp = (nick *)np;
+ if(IsAccount(tnp) && tnp->auth) {
+ lua_pushlong(l, tnp->auth->userid);
+ } else {
+ lua_pushnil(l);
+ }
+ break;
+ }
case PUSHER_REALUSERS:
{
channel *cp = *((channel **)offset);
lua_pushint(l, (long)((nick *)offset)->exts[geoipext]);
}
break;
+ case PUSHER_SERVER_NAME:
+ lua_pushstring(l, serverlist[homeserver(((nick *)offset)->numeric)].name->content);
+ break;
+ case PUSHER_SERVER_NUMERIC:
+ lua_pushint(l, homeserver(((nick *)offset)->numeric));
+ break;
}
i++;
chanpushercount = i;
chanpusher[i].argtype = 0;
}
+