LibIRCClient 1.10 Used by Probotic
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
To repozytorium jest zarchiwizowane. Możesz wyświetlać pliki i je sklonować, ale nie możesz do niego przepychać zmian lub otwierać zgłoszeń/Pull Requestów.

390 wiersze
16KB

  1. /*
  2. * Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
  3. *
  4. * This library is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  12. * License for more details.
  13. */
  14. #ifndef INCLUDE_IRC_EVENTS_H
  15. #define INCLUDE_IRC_EVENTS_H
  16. #ifndef IN_INCLUDE_LIBIRC_H
  17. #error This file should not be included directly, include just libircclient.h
  18. #endif
  19. /*!
  20. * \fn typedef void (*irc_event_callback_t) (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
  21. * \brief A most common event callback
  22. *
  23. * \param session the session, which generates an event
  24. * \param event the text name of the event. Useful in case you use a single
  25. * event handler for several events simultaneously.
  26. * \param origin the originator of the event. See the note below.
  27. * \param params a list of event params. Depending on the event nature, it
  28. * could have zero or more params. The actual number of params
  29. * is specified in count. None of the params can be NULL, but
  30. * 'params' pointer itself could be NULL for some events.
  31. * \param count the total number of params supplied.
  32. *
  33. * Every event generates a callback. This callback is generated by most events.
  34. * Depending on the event nature, it can provide zero or more params. For each
  35. * event, the number of provided params is fixed, and their meaning is
  36. * described.
  37. *
  38. * Every event has origin, though the \a origin variable may be NULL, which
  39. * means that event origin is unknown. The origin usually looks like
  40. * nick!host\@ircserver, i.e. like tim!home\@irc.krasnogorsk.ru. Such origins
  41. * can not be used in IRC commands, and need to be stripped (i.e. host and
  42. * server part should be cut off) before using. This can be done either
  43. * explicitly, by calling irc_target_get_nick(), or implicitly for all the
  44. * events - by setting the #LIBIRC_OPTION_STRIPNICKS option with irc_option_set().
  45. *
  46. * \ingroup events
  47. */
  48. typedef void (*irc_event_callback_t) (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count);
  49. /*!
  50. * \fn typedef void (*irc_eventcode_callback_t) (irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count)
  51. * \brief A numeric event callback
  52. *
  53. * \param session the session, which generates an event
  54. * \param event the numeric code of the event. Useful in case you use a
  55. * single event handler for several events simultaneously.
  56. * \param origin the originator of the event. See the note below.
  57. * \param params a list of event params. Depending on the event nature, it
  58. * could have zero or more params. The actual number of params
  59. * is specified in count. None of the params can be NULL, but
  60. * 'params' pointer itself could be NULL for some events.
  61. * \param count the total number of params supplied.
  62. *
  63. * Most times in reply to your actions the IRC server generates numeric
  64. * callbacks. Most of them are error codes, and some of them mark list start
  65. * and list stop markers. Every code has its own set of params; for details
  66. * you can either experiment, or read RFC 1459.
  67. *
  68. * Every event has origin, though the \a origin variable may be NULL, which
  69. * means that event origin is unknown. The origin usually looks like
  70. * nick!host\@ircserver, i.e. like tim!home\@irc.krasnogorsk.ru. Such origins
  71. * can not be used in IRC commands, and need to be stripped (i.e. host and
  72. * server part should be cut off) before using. This can be done either
  73. * explicitly, by calling irc_target_get_nick(), or implicitly for all the
  74. * events - by setting the #LIBIRC_OPTION_STRIPNICKS option with irc_option_set().
  75. *
  76. * \ingroup events
  77. */
  78. typedef void (*irc_eventcode_callback_t) (irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count);
  79. /*!
  80. * \fn typedef void (*irc_event_dcc_chat_t) (irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid)
  81. * \brief A remote DCC CHAT request callback
  82. *
  83. * \param session the session, which generates an event
  84. * \param nick the person who requested DCC CHAT with you.
  85. * \param addr the person's IP address in decimal-dot notation.
  86. * \param dccid an id associated with this request. Use it in calls to
  87. * irc_dcc_accept() or irc_dcc_decline().
  88. *
  89. * This callback is called when someone requests DCC CHAT with you. In respond
  90. * you should call either irc_dcc_accept() to accept chat request, or
  91. * irc_dcc_decline() to decline chat request.
  92. *
  93. * \sa irc_dcc_accept or irc_dcc_decline
  94. * \ingroup events
  95. */
  96. typedef void (*irc_event_dcc_chat_t) (irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid);
  97. /*!
  98. * \fn typedef void (*irc_event_dcc_send_t) (irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid)
  99. * \brief A remote DCC CHAT request callback
  100. *
  101. * \param session the session, which generates an event
  102. * \param nick the person who requested DCC CHAT with you.
  103. * \param addr the person's IP address in decimal-dot notation.
  104. * \param filename the sent filename.
  105. * \param size the filename size.
  106. * \param dccid an id associated with this request. Use it in calls to
  107. * irc_dcc_accept() or irc_dcc_decline().
  108. *
  109. * This callback is called when someone wants to send a file to you using
  110. * DCC SEND. As with chat, in respond you should call either irc_dcc_accept()
  111. * to accept this request and receive the file, or irc_dcc_decline() to
  112. * decline this request.
  113. *
  114. * \sa irc_dcc_accept or irc_dcc_decline
  115. * \ingroup events
  116. */
  117. typedef void (*irc_event_dcc_send_t) (irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid);
  118. /*! \brief Event callbacks structure.
  119. *
  120. * All the communication with the IRC network is based on events. Generally
  121. * speaking, event is anything generated by someone else in the network,
  122. * or by the IRC server itself. "Someone sends you a message", "Someone
  123. * has joined the channel", "Someone has quits IRC" - all these messages
  124. * are events.
  125. *
  126. * Every event has its own event handler, which is called when the
  127. * appropriate event is received. You don't have to define all the event
  128. * handlers; define only the handlers for the events you need to intercept.
  129. *
  130. * Most event callbacks are the types of ::irc_event_callback_t. There are
  131. * also events, which generate ::irc_eventcode_callback_t,
  132. * ::irc_event_dcc_chat_t and ::irc_event_dcc_send_t callbacks.
  133. *
  134. * \ingroup events
  135. */
  136. typedef struct
  137. {
  138. /*!
  139. * The "on_connect" event is triggered when the client successfully
  140. * connects to the server, and could send commands to the server.
  141. * No extra params supplied; \a params is 0.
  142. */
  143. irc_event_callback_t event_connect;
  144. /*!
  145. * The "nick" event is triggered when the client receives a NICK message,
  146. * meaning that someone (including you) on a channel with the client has
  147. * changed their nickname.
  148. *
  149. * \param origin the person, who changes the nick. Note that it can be you!
  150. * \param params[0] mandatory, contains the new nick.
  151. */
  152. irc_event_callback_t event_nick;
  153. /*!
  154. * The "quit" event is triggered upon receipt of a QUIT message, which
  155. * means that someone on a channel with the client has disconnected.
  156. *
  157. * \param origin the person, who is disconnected
  158. * \param params[0] optional, contains the reason message (user-specified).
  159. */
  160. irc_event_callback_t event_quit;
  161. /*!
  162. * The "join" event is triggered upon receipt of a JOIN message, which
  163. * means that someone has entered a channel that the client is on.
  164. *
  165. * \param origin the person, who joins the channel. By comparing it with
  166. * your own nickname, you can check whether your JOIN
  167. * command succeed.
  168. * \param params[0] mandatory, contains the channel name.
  169. */
  170. irc_event_callback_t event_join;
  171. /*!
  172. * The "part" event is triggered upon receipt of a PART message, which
  173. * means that someone has left a channel that the client is on.
  174. *
  175. * \param origin the person, who leaves the channel. By comparing it with
  176. * your own nickname, you can check whether your PART
  177. * command succeed.
  178. * \param params[0] mandatory, contains the channel name.
  179. * \param params[1] optional, contains the reason message (user-defined).
  180. */
  181. irc_event_callback_t event_part;
  182. /*!
  183. * The "mode" event is triggered upon receipt of a channel MODE message,
  184. * which means that someone on a channel with the client has changed the
  185. * channel's parameters.
  186. *
  187. * \param origin the person, who changed the channel mode.
  188. * \param params[0] mandatory, contains the channel name.
  189. * \param params[1] mandatory, contains the changed channel mode, like
  190. * '+t', '-i' and so on.
  191. * \param params[2] optional, contains the mode argument (for example, a
  192. * key for +k mode, or user who got the channel operator status for
  193. * +o mode)
  194. */
  195. irc_event_callback_t event_mode;
  196. /*!
  197. * The "umode" event is triggered upon receipt of a user MODE message,
  198. * which means that your user mode has been changed.
  199. *
  200. * \param origin the person, who changed the channel mode.
  201. * \param params[0] mandatory, contains the user changed mode, like
  202. * '+t', '-i' and so on.
  203. */
  204. irc_event_callback_t event_umode;
  205. /*!
  206. * The "topic" event is triggered upon receipt of a TOPIC message, which
  207. * means that someone on a channel with the client has changed the
  208. * channel's topic.
  209. *
  210. * \param origin the person, who changes the channel topic.
  211. * \param params[0] mandatory, contains the channel name.
  212. * \param params[1] optional, contains the new topic.
  213. */
  214. irc_event_callback_t event_topic;
  215. /*!
  216. * The "kick" event is triggered upon receipt of a KICK message, which
  217. * means that someone on a channel with the client (or possibly the
  218. * client itself!) has been forcibly ejected.
  219. *
  220. * \param origin the person, who kicked the poor.
  221. * \param params[0] mandatory, contains the channel name.
  222. * \param params[0] optional, contains the nick of kicked person.
  223. * \param params[1] optional, contains the kick text
  224. */
  225. irc_event_callback_t event_kick;
  226. /*!
  227. * The "channel" event is triggered upon receipt of a PRIVMSG message
  228. * to an entire channel, which means that someone on a channel with
  229. * the client has said something aloud. Your own messages don't trigger
  230. * PRIVMSG event.
  231. *
  232. * \param origin the person, who generates the message.
  233. * \param params[0] mandatory, contains the channel name.
  234. * \param params[1] optional, contains the message text
  235. */
  236. irc_event_callback_t event_channel;
  237. /*!
  238. * The "privmsg" event is triggered upon receipt of a PRIVMSG message
  239. * which is addressed to one or more clients, which means that someone
  240. * is sending the client a private message.
  241. *
  242. * \param origin the person, who generates the message.
  243. * \param params[0] mandatory, contains your nick.
  244. * \param params[1] optional, contains the message text
  245. */
  246. irc_event_callback_t event_privmsg;
  247. /*!
  248. * The "notice" event is triggered upon receipt of a NOTICE message
  249. * which means that someone has sent the client a public or private
  250. * notice. According to RFC 1459, the only difference between NOTICE
  251. * and PRIVMSG is that you should NEVER automatically reply to NOTICE
  252. * messages. Unfortunately, this rule is frequently violated by IRC
  253. * servers itself - for example, NICKSERV messages require reply, and
  254. * are NOTICEs.
  255. *
  256. * \param origin the person, who generates the message.
  257. * \param params[0] mandatory, contains the target nick name.
  258. * \param params[1] optional, contains the message text
  259. */
  260. irc_event_callback_t event_notice;
  261. /*!
  262. * The "channel_notice" event is triggered upon receipt of a NOTICE
  263. * message which means that someone has sent the client a public
  264. * notice. According to RFC 1459, the only difference between NOTICE
  265. * and PRIVMSG is that you should NEVER automatically reply to NOTICE
  266. * messages. Unfortunately, this rule is frequently violated by IRC
  267. * servers itself - for example, NICKSERV messages require reply, and
  268. * are NOTICEs.
  269. *
  270. * \param origin the person, who generates the message.
  271. * \param params[0] mandatory, contains the channel name.
  272. * \param params[1] optional, contains the message text
  273. */
  274. irc_event_callback_t event_channel_notice;
  275. /*!
  276. * The "invite" event is triggered upon receipt of an INVITE message,
  277. * which means that someone is permitting the client's entry into a +i
  278. * channel.
  279. *
  280. * \param origin the person, who INVITEs you.
  281. * \param params[0] mandatory, contains your nick.
  282. * \param params[1] mandatory, contains the channel name you're invited into.
  283. *
  284. * \sa irc_cmd_invite irc_cmd_chanmode_invite
  285. */
  286. irc_event_callback_t event_invite;
  287. /*!
  288. * The "ctcp" event is triggered when the client receives the CTCP
  289. * request. By default, the built-in CTCP request handler is used. The
  290. * build-in handler automatically replies on most CTCP messages, so you
  291. * will rarely need to override it.
  292. *
  293. * \param origin the person, who generates the message.
  294. * \param params[0] mandatory, the complete CTCP message, including its
  295. * arguments.
  296. *
  297. * Mirc generates PING, FINGER, VERSION, TIME and ACTION messages,
  298. * check the source code of \c libirc_event_ctcp_internal function to
  299. * see how to write your own CTCP request handler. Also you may find
  300. * useful this question in FAQ: \ref faq4
  301. */
  302. irc_event_callback_t event_ctcp_req;
  303. /*!
  304. * The "ctcp" event is triggered when the client receives the CTCP reply.
  305. *
  306. * \param origin the person, who generates the message.
  307. * \param params[0] mandatory, the CTCP message itself with its arguments.
  308. */
  309. irc_event_callback_t event_ctcp_rep;
  310. /*!
  311. * The "action" event is triggered when the client receives the CTCP
  312. * ACTION message. These messages usually looks like:\n
  313. * \code
  314. * [23:32:55] * Tim gonna sleep.
  315. * \endcode
  316. *
  317. * \param origin the person, who generates the message.
  318. * \param params[0] mandatory, the ACTION message.
  319. */
  320. irc_event_callback_t event_ctcp_action;
  321. /*!
  322. * The "unknown" event is triggered upon receipt of any number of
  323. * unclassifiable miscellaneous messages, which aren't handled by the
  324. * library.
  325. */
  326. irc_event_callback_t event_unknown;
  327. /*!
  328. * The "numeric" event is triggered upon receipt of any numeric response
  329. * from the server. There is a lot of such responses, see the full list
  330. * here: \ref rfcnumbers.
  331. *
  332. * See the params in ::irc_eventcode_callback_t specification.
  333. */
  334. irc_eventcode_callback_t event_numeric;
  335. /*!
  336. * The "dcc chat" event is triggered when someone requests a DCC CHAT from
  337. * you.
  338. *
  339. * See the params in ::irc_event_dcc_chat_t specification.
  340. */
  341. irc_event_dcc_chat_t event_dcc_chat_req;
  342. /*!
  343. * The "dcc chat" event is triggered when someone wants to send a file
  344. * to you via DCC SEND request.
  345. *
  346. * See the params in ::irc_event_dcc_send_t specification.
  347. */
  348. irc_event_dcc_send_t event_dcc_send_req;
  349. } irc_callbacks_t;
  350. #endif /* INCLUDE_IRC_EVENTS_H */