]> jfr.im git - irc/quakenet/newserv.git/blame - lua/luabot.h
CHANSERV: tell user when they can't attempts to auth any more, and drop max attempts...
[irc/quakenet/newserv.git] / lua / luabot.h
CommitLineData
2da56f0d
CP
1/* Copyright (C) Chris Porter 2005 */
2/* ALL RIGHTS RESERVED. */
3/* Don't put this into the SVN repo. */
4
5#ifndef _LUA_BOT_H
6#define _LUA_BOT_H
7
8#include "../nick/nick.h"
9#include "../channel/channel.h"
10
bb4b25ee
CP
11int lua_channelmessage(channel *cp, char *message, ...) __attribute__ ((format (printf, 2, 3)));
12int lua_message(nick *np, char *message, ...) __attribute__ ((format (printf, 2, 3)));
13int lua_notice(nick *np, char *message, ...) __attribute__ ((format (printf, 2, 3)));
0225bed3 14int _lua_vpcall(lua_State *l, void *function, int mode, const char *sig, ...);
68c9a3de 15char *printallmodes(channel *cp);
2da56f0d 16
aff92435 17extern nick *lua_nick;
d324e17b 18extern sstring *luabotnick;
2da56f0d
CP
19
20#define LUA_OK 0
21#define LUA_FAIL 1
22
0225bed3
CP
23#define LUA_CHARMODE 0
24#define LUA_POINTERMODE 1
25
d0d1e2a3
CP
26#define LUA_TPUSHSTRING(l, param, value) { lua_pushstring(l, param); lua_pushstring(l, value); lua_rawset(l, -3); }
27#define LUA_TPUSHNUMBER(l, param, value) { lua_pushstring(l, param); lua_pushnumber(l, value); lua_rawset(l, -3); }
28#define LUA_TPUSHBOOLEAN(l, param, value) { lua_pushstring(l, param); lua_pushboolean(l, value); lua_rawset(l, -3); }
2da56f0d 29
fdcb5d66 30#define LUA_PUSHNICK(l, np) { lua_newtable(l); LUA_TPUSHSTRING(l, "nick", np->nick); LUA_TPUSHSTRING(l, "ident", np->ident); LUA_TPUSHSTRING(l, "hostname", np->host->name->content); LUA_TPUSHSTRING(l, "realname", np->realname->name->content); LUA_TPUSHSTRING(l, "account", np->authname); LUA_TPUSHNUMBER(l, "numeric", np->numeric); LUA_TPUSHSTRING(l, "ip", IPtostr(np->ipaddress)); }
2da56f0d 31
68c9a3de 32#define LUA_PUSHCHAN(l, cp) { lua_newtable(l); LUA_TPUSHNUMBER(l, "timestamp", cp->timestamp); LUA_TPUSHNUMBER(l, "totalusers", cp->users->totalusers); if(cp->topic) { LUA_TPUSHSTRING(l, "topic", cp->topic->content); }; LUA_TPUSHSTRING(l, "modes", printallmodes(cp)); }
d0d1e2a3
CP
33
34#define LUA_PUSHNICKCHANMODES(l, lp) { lua_newtable(l); LUA_TPUSHBOOLEAN(l, "opped", (*lp & CUMODE_OP) != 0); LUA_TPUSHBOOLEAN(l, "voiced", (*lp & CUMODE_VOICE) != 0); }
2da56f0d
CP
35
36#define LUA_RETURN(l, n) { lua_pushnumber(l, n); return 1; }
37
0225bed3
CP
38#define lua_vpcall(L2, F2, S2, ...) _lua_vpcall(L2, F2, LUA_CHARMODE, S2 , ##__VA_ARGS__)
39#define lua_vlpcall(L2, F2, N2, S2, ...) _lua_vpcall(L2->l, (void *)F2->handler, LUA_POINTERMODE, "Ns" S2 , F2->nick, N2, ##__VA_ARGS__)
40
3522f515
CP
41#define lua_avpcall(F2, S2, ...) { lua_State *l; LUA_STARTLOOP(l); lua_vpcall(l, F2, S2 , ##__VA_ARGS__); LUA_ENDLOOP(); }
42
2da56f0d 43#endif