libircbot
library providing a framework for implementing an IRC bot
Loading...
Searching...
No Matches
ircbot.h
Go to the documentation of this file.
1#ifndef IRCBOT_IRCBOT_H
2#define IRCBOT_IRCBOT_H
3
4#include <ircbot/decl.h>
5
17C_CLASS_DECL(IrcBotEvent);
18
22C_CLASS_DECL(IrcBotResponse);
23
24C_CLASS_DECL(IrcChannel);
25C_CLASS_DECL(IrcServer);
26
30C_CLASS_DECL(IBThreadOpts);
31
35typedef enum IrcBotEventType
36{
44
49typedef void (*IrcBotHandler)(IrcBotEvent *event) ATTR_NONNULL((1));
50
51#define ORIGIN_PRIVATE ":"
52#define ORIGIN_CHANNEL "#"
58DECLEXPORT IBThreadOpts *IrcBot_threadOpts(void) ATTR_RETNONNULL;
59
67DECLEXPORT void IBThreadOpts_setNThreads(IBThreadOpts *self, int num)
68 CMETHOD;
69
78DECLEXPORT void IBThreadOpts_setMaxThreads(IBThreadOpts *self, int num)
79 CMETHOD;
80
87DECLEXPORT void IBThreadOpts_setNPerCpu(IBThreadOpts *self, int num)
88 CMETHOD;
89
98DECLEXPORT void IBThreadOpts_setDefNThreads(IBThreadOpts *self, int num)
99 CMETHOD;
100
107DECLEXPORT void IBThreadOpts_setQueueLen(IBThreadOpts *self, int num)
108 CMETHOD;
109
116DECLEXPORT void IBThreadOpts_setMaxQueueLen(IBThreadOpts *self, int num)
117 CMETHOD;
118
125DECLEXPORT void IBThreadOpts_setMinQueueLen(IBThreadOpts *self, int num)
126 CMETHOD;
127
134DECLEXPORT void IBThreadOpts_setQLenPerThread(IBThreadOpts *self, int num)
135 CMETHOD;
136
146DECLEXPORT void IrcBot_daemonize(long uid, long gid,
147 const char *pidfile, void (*started)(void));
148
158DECLEXPORT void IrcBot_startup(int (*startup)(void));
159
166DECLEXPORT void IrcBot_shutdown(void (*shutdown)(void));
167
182DECLEXPORT void IrcBot_addHandler(IrcBotEventType eventType,
183 const char *serverId, const char *origin, const char *filter,
184 IrcBotHandler handler);
185
192DECLEXPORT void IrcBot_addServer(IrcServer *server) ATTR_NONNULL((1));
193
202DECLEXPORT int IrcBot_run(void);
203
209DECLEXPORT IrcBotEventType IrcBotEvent_type(const IrcBotEvent *self) CMETHOD;
210
216DECLEXPORT const IrcServer *IrcBotEvent_server(const IrcBotEvent *self)
217 CMETHOD;
218
224DECLEXPORT const IrcChannel *IrcBotEvent_channel(const IrcBotEvent *self)
225 CMETHOD;
226
233DECLEXPORT const char *IrcBotEvent_origin(const IrcBotEvent *self) CMETHOD;
234
240DECLEXPORT const char *IrcBotEvent_command(const IrcBotEvent *self) CMETHOD;
241
247DECLEXPORT const char *IrcBotEvent_from(const IrcBotEvent *self) CMETHOD;
248
254DECLEXPORT const char *IrcBotEvent_arg(const IrcBotEvent *self) CMETHOD;
255
262 CMETHOD ATTR_RETNONNULL;
263
272 const char *to, const char *msg, int action)
273 CMETHOD ATTR_NONNULL((2)) ATTR_NONNULL((3));
274
275#endif
A configuration object for the integrated thread pool.
void IBThreadOpts_setQueueLen(IBThreadOpts *self, int num)
Set a fixed size for the queue of waiting thread jobs.
void IBThreadOpts_setMinQueueLen(IBThreadOpts *self, int num)
Set the minimum size for the queue of waiting thread jobs.
void IBThreadOpts_setNPerCpu(IBThreadOpts *self, int num)
Set number of threads per CPU.
void IBThreadOpts_setQLenPerThread(IBThreadOpts *self, int num)
Set the number of queue entries per thread.
void IBThreadOpts_setMaxThreads(IBThreadOpts *self, int num)
Set maximum number of threads.
void IBThreadOpts_setNThreads(IBThreadOpts *self, int num)
Set fixed number of threads.
void IBThreadOpts_setMaxQueueLen(IBThreadOpts *self, int num)
Set the maximum size for the queue of waiting thread jobs.
void IBThreadOpts_setDefNThreads(IBThreadOpts *self, int num)
Set default number of threads.
A bot event to be handled.
const IrcChannel * IrcBotEvent_channel(const IrcBotEvent *self)
The channel the event occured on.
IrcBotEventType IrcBotEvent_type(const IrcBotEvent *self)
The type of the event.
const char * IrcBotEvent_arg(const IrcBotEvent *self)
Additional arguments of the event.
const char * IrcBotEvent_from(const IrcBotEvent *self)
The sender of the message.
const char * IrcBotEvent_origin(const IrcBotEvent *self)
The origin of the event.
IrcBotResponse * IrcBotEvent_response(IrcBotEvent *self)
Obtain a response object to configure.
const char * IrcBotEvent_command(const IrcBotEvent *self)
The bot command.
const IrcServer * IrcBotEvent_server(const IrcBotEvent *self)
The server the event came from.
void IrcBot_shutdown(void(*shutdown)(void))
Set a custom shutdown function.
void IrcBot_startup(int(*startup)(void))
Set a custom startup function.
void IrcBot_addServer(IrcServer *server)
Add an IRC server to be managed by the bot.
void IrcBot_addHandler(IrcBotEventType eventType, const char *serverId, const char *origin, const char *filter, IrcBotHandler handler)
Register a handler for a bot event.
IBThreadOpts * IrcBot_threadOpts(void)
Obtain the current thread pool options for configuration.
void IrcBot_daemonize(long uid, long gid, const char *pidfile, void(*started)(void))
Request the bot to deamonize first when running.
int IrcBot_run(void)
Run the IRC bot.
A response to a bot event, to be filled by a handler.
void IrcBotResponse_addMsg(IrcBotResponse *self, const char *to, const char *msg, int action)
Add a message to a bot response.
An IRC channel.
An IRC server.
Common preprocessor declarations for libircbot.
void(* IrcBotHandler)(IrcBotEvent *event)
Handler for a bot event.
Definition: ircbot.h:49
IrcBotEventType
Type of a bot event.
Definition: ircbot.h:36
@ IBET_BOTCOMMAND
A bot command, !-prefixed or sent private.
Definition: ircbot.h:37
@ IBET_CONNECTED
Connected to IRC server.
Definition: ircbot.h:39
@ IBET_CHANJOINED
Channel joined by bot.
Definition: ircbot.h:40
@ IBET_PRIVMSG
A generic PRIVMSG (channel or private)
Definition: ircbot.h:38
@ IBET_JOINED
Channel joined by other user.
Definition: ircbot.h:41
@ IBET_PARTED
Channel left by other user.
Definition: ircbot.h:42