|
libircbot
library providing a framework for implementing an IRC bot
|
Static class containing the primary IRC bot API. More...
#include <ircbot/ircbot.h>
Public Member Functions | |
| IBThreadOpts * | IrcBot_threadOpts (void) |
| Obtain the current thread pool options for configuration. More... | |
| void | IrcBot_daemonize (long uid, long gid, const char *pidfile, void(*started)(void)) |
| Request the bot to deamonize first when running. More... | |
| void | IrcBot_startup (int(*startup)(void)) |
| Set a custom startup function. More... | |
| void | IrcBot_shutdown (void(*shutdown)(void)) |
| Set a custom shutdown function. More... | |
| void | IrcBot_addHandler (IrcBotEventType eventType, const char *serverId, const char *origin, const char *filter, IrcBotHandler handler) |
| Register a handler for a bot event. More... | |
| void | IrcBot_addServer (IrcServer *server) |
| Add an IRC server to be managed by the bot. More... | |
| int | IrcBot_run (void) |
| Run the IRC bot. More... | |
Static class containing the primary IRC bot API.
| void IrcBot_addHandler | ( | IrcBotEventType | eventType, |
| const char * | serverId, | ||
| const char * | origin, | ||
| const char * | filter, | ||
| IrcBotHandler | handler | ||
| ) |
Register a handler for a bot event.
The handler registered will be executed on a worker thread when a matching bot event occurs. It should examine the IrcBotEvent it gets passed and then configure the IrcBotResponse that can be obtained from that event.
| eventType | the type of the event |
| serverId | the id of the IrcServer, or NULL for any server |
| origin | the channel name or the nick of the bot, or ORIGIN_CHANNEL for any channel, or ORIGIN_PRIVATE for any message received privately, or NULL for any message |
| filter | an additional filter depending on the eventType, e.g. the command for IBET_BOTCOMMAND, or NULL for any |
| handler | the handler to execute for the event |
| void IrcBot_addServer | ( | IrcServer * | server | ) |
Add an IRC server to be managed by the bot.
Any server added will be automatically connected to. The bot will also destroy the server on shutdown.
| server | the server |
| void IrcBot_daemonize | ( | long | uid, |
| long | gid, | ||
| const char * | pidfile, | ||
| void(*)(void) | started | ||
| ) |
Request the bot to deamonize first when running.
If a pidfile is given, it is also used to check for an already running instance.
| uid | the user id to run as, -1 to not change |
| gid | the group id to run as, -1 for default or no change |
| pidfile | full path to the pidfile to use, or NULL for none |
| started | callback to run when the daemon launched successfully, or NULL |
| int IrcBot_run | ( | void | ) |
Run the IRC bot.
This should typically be the last function to call in your main(). It will launch a thread pool, a service loop and run the bot as previously configured, e.g. daemonize if requested and connect to all servers that were added.
| void IrcBot_shutdown | ( | void(*)(void) | shutdown | ) |
Set a custom shutdown function.
This function will be called during shutdown of the bot. It can for example be used to free resources that were allocated during startup.
| shutdown | the function to call on shutdown |
| void IrcBot_startup | ( | int(*)(void) | startup | ) |
Set a custom startup function.
This function will be run during startup of the bot. It should return EXIT_SUCCESS if everything is fine. If it returns EXIT_FAILURE, startup is aborted and the bot exits. This function is called after the bot successfully started some internal things and, if requested to do so, changed its user id.
| startup | the function to call on startup |
| IBThreadOpts * IrcBot_threadOpts | ( | void | ) |
Obtain the current thread pool options for configuration.