xbot/mods/lua/lua.h

106 lines
2.9 KiB
C
Raw Normal View History

2024-03-01 02:49:33 +00:00
#define MY_DLL_EXPORTS 1
2024-02-25 17:09:24 +00:00
#ifndef LUA_H
#define LUA_H
2024-03-01 02:49:33 +00:00
#ifdef _WIN32
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#else
2024-02-25 17:09:24 +00:00
#include <lua5.3/lua.h>
#include <lua5.3/lauxlib.h>
#include <lua5.3/lualib.h>
2024-03-01 02:49:33 +00:00
#endif
2024-02-25 17:09:24 +00:00
#include "irc.h"
struct lua_script
{
char name[25];
char author[50];
char version[10];
char description[256];
char fname[256];
int unload;
2024-02-25 17:09:24 +00:00
};
2024-02-27 07:16:58 +00:00
struct lua_event
{
char event[25];
int lreg;
};
2024-02-25 17:09:24 +00:00
struct lua_interp
{
2024-02-27 07:16:58 +00:00
int script_count;
int event_count;
2024-02-25 17:09:24 +00:00
lua_State *L;
2024-02-27 07:16:58 +00:00
2024-02-25 17:09:24 +00:00
struct lua_script *scripts;
2024-02-27 07:16:58 +00:00
struct lua_event *events;
2024-02-25 17:09:24 +00:00
};
struct script_list
{
int count;
char *scripts[512];
};
extern int block;
2024-02-27 07:16:58 +00:00
2024-02-25 17:09:24 +00:00
extern struct lua_interp lua;
2024-02-27 07:16:58 +00:00
extern struct irc_conn *instance;
// events.c
void lua_init_events();
int lua_add_handler(lua_State *L);
void lua_del_handler(lua_State *L);
void lua_fire_handlers(char *event, ...);
// wrappers.c
void lua_init_wrappers();
void raw_wrapper(lua_State *L);
void privmsg_wrapper(lua_State *L);
2024-03-02 08:11:50 +00:00
void notice_wrapper(lua_State *L);
void join_wrapper(lua_State *L);
void part_wrapper(lua_State *L);
void ban_wrapper(lua_State *L);
void kick_wrapper(lua_State *L);
void mode_wrapper(lua_State *L);
void ctcp_wrapper(lua_State *L);
2024-02-27 07:16:58 +00:00
// handlers.c
void lua_init_handlers();
void lua_unload_handlers();
MY_API void chanprivmsg_handler(struct irc_conn *bot, char *user, char *host, char *chan, const char *text);
MY_API void selfprivmsg_handler(struct irc_conn *bot, char *user, char *host, const char *text);
MY_API void tick_handler(struct irc_conn *bot);
MY_API void join_handler(struct irc_conn *bot, char *user, char *host, char *chan);
MY_API void joinmyself_handler(struct irc_conn *bot, char *chan);
MY_API void ircconnected_handler(struct irc_conn *bot);
MY_API void nickmyself_handler(struct irc_conn *bot, char *newnick);
MY_API void nickinuse_handler(struct irc_conn *bot, char *newnick);
MY_API void ctcp_handler(struct irc_conn *bot, char *user, char *host, char *chan, const char *text);
MY_API void ircnamreply_handler(struct irc_conn *bot, char *chan, char *nicks);
MY_API void ircwhoreply_handler(struct irc_conn *bot, char *chan, char *user, char *host, char *server, char *nick, char *flags, char *hops, char *realname);
MY_API void part_handler(struct irc_conn *bot, char *user, char *host, char *chan);
MY_API void partmyself_handler(struct irc_conn *bot, char *chan);
MY_API void quit_handler(struct irc_conn *bot, char *user, char *host, const char *text);
// lua.c
void lua_setvar(char *name, char *value);
int append_script(char *fname);
int remove_script(char *fname);
struct script_list get_scripts();
2024-03-01 02:49:33 +00:00
MY_API void mod_init();
MY_API void mod_unload();
2024-02-27 07:16:58 +00:00
MY_API void lua_eval(struct irc_conn *bot, char *user, char *host, char *chan, const char *text);
MY_API void lua_load_script(struct irc_conn *bot, char *user, char *host, char *chan, const char *text);
MY_API void lua_unload_script(struct irc_conn *bot, char *user, char *host, char *chan, const char *text);
2024-02-25 17:09:24 +00:00
#endif