IRC-TK Project



F.A.Q. List

  1. Intro
  2. IRC-TK Details
  3. IRC-TK License

I.1 :: About IRC-TK

IRC-TK (IRC ToolKit) is a library written in C++ for C++ developers, that deals with all the secondary business an IRC application is supposed to do and allows the developer to focus on the main points of his application, thus making IRC programming easier and quicker.

Currently IRC-TK consists of:

  • The IRC Replies section: This section contains all the standard IRC numeric replies that an IRC application is bound to get from an IRC server. Those numeric replies have been copied from the IRC RFC (RFC 1459).
  • The IRC Library section: When your program receives a reply from an IRC server, it needs to parse it... This is what the IRC-TK IRC Lib does for you. Not only does it take care of the parsing business, but it also provides an IRC socket handling class designed specifically for sockets connecting to IRC servers.
  • The IRC Bot section: Since you are using IRC-TK, you probably want to make an IRC Bot. Instead of making one of your own from scratch trying to be as compatible as possible with the IRC-TK IRC Lib, IRC-TK provides you with an IRC Bot class. It is 100% IRC-TK IRC Lib compliant, and 100% customizeable.

I.2 :: Why use IRC-TK anyway?

To make things easier for you of course! Using IRC-TK prevents you from having to write all the socket handling code, writing all the IRC message handling code and way more things; not to mention that with IRC-TK you will not even have to spend time designing classes and such things that are going to handle the IRC connection. The following examples show the difference between a normal IRC program (with socket handling) and a program that uses IRC-TK:

#include < iostream >
#include < string >
#include < cstdio >
#include < sstream >
#include < sys/socket.h >
#include < sys/types.h >
#include < netdb.h >
#include < arpa/inet.h >
#include < unistd.h >
#include < netinet/in.h >

using namespace std;

int serverport;
string servername;
int sockfd;

int main(int argc, char **argv) {
   if (argc < 3) {
     cerr << "Must have at least 3 arguments\n";
     cerr << "Example: # ./MyBot 6667\n";
     return 1;

   servername = string(argv[1]);
   stringstream sstemp;
   sstemp << argv[2];
   sstemp >> serverport;

   if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
     return 1;

   sockaddr_in serversocket;
   serversocket.sin_family = AF_INET;
   serversocket.sin_port = htons(serverport);
   memset(&(serversocket.sin_zero), '\0', 8);
   if (connect(sockfd, (sockaddr *)&server_addr, sizeof(sockaddr)) == -1) {
     return 1;

   //And the real IRC work only begins here... Nice eh?
   //IRC stuff
   //okay done

   return 0;

And now a program that uses IRC-TK:

#include < irctk/irc_lib.h >
#include < string >
using namespace std;

int main(int argc, int **argv) {
   if (argc < 3) {
     cerr << "Must have at least 3 arguments\n";
     cerr << "./MyBot 6667\n";
     return 1;

   IRC_Socker ircsocket = IRC_Socket(string(argv[1]), argv[2]);
   if (!ircsocket.Connect())
     return 1;

   //And the real IRC begins here... Nice eh?
   //IRC stuff
   //okay done

   return 0;

Please note that the above programs only connect to an IRC server; they do nothing more. The IRC-TK saves you from a lot more extra coding than shown above.

I.3 :: I need help on IRC-TK!

If you need some help on an IRC-TK matter, please feel free to e-mail someone from the development team.

Development team:

I.4. :: I found a bug. What do I do now?

Aside from fixing it on your own for personal use, it would be great to sumbit the bug to the development team, so that it can be fixed in the next version. Please fetch the development team's e-mails from above.

II.1 :: IRC-TK Requirements

Below is a list of what IRC-TK is tested on. If you find find out that IRC-TK works on something else, please communicate with the development team:

  • OS: Linux
  • Compiler: GNU G++ [the compiler must conform to the C++ '99 standard]

Note that IRC-TK does not require extra libraries for the compiler.

II.2 :: IRC Replies section

The IRC replies are stored in the file irc_replies.h in the irctk directory, under the IRCTK namespace. All the IRC replies are of type "const int".

If you want to see a list of the replies, either look at the irc_replies.h file or take a look at the REPLIES section in RFC 1459.

II.3 :: IRC Lib section

The IRC lib is stored in the file irc_lib.h in the irctk directory, under the IRCTK namespace. The IRC lib contains functions that allow you to easily manipulate the IRC messages you get from an IRC server. It also contains the IRC_Socket class.

IRC_Socket is a class designed to make socket handling easier, for sockets connecting to an IRC server. The protocol type used for the socket creation is AF_INET (IPv4), the socket type is SOCK_STREAM and no parameters are passed. Then the class IRC_Socket establishes a connection with the given server at the given port using the previously created socket. Please note that in the current version (0.1 PreAlpha) the IRC_Socket class is not highly customizeable, as far as socket creation is concerned. In future versions IRC-TK is going to decide if AF_INET (IPv4) or AF_INET6 (IPv6) is going to be used. Last, IRC_Socket provides you with its own send() and recv() functions that make it more simple for you to communicate with the IRC server.

The rest of the IRC-TK IRC lib consists of functions. With the IRC-TK IRC Lib, you can deal with IRC messages in two ways:

  1. Parse the IRC message and create a std::vector < std::string > containing the message parameters.
  2. Do not parse the IRC message and deal with the raw message.

The advantage of the 1st way is that once you parse the message, you have a vector containing the IRC message parameters and you can handle that vector in any way you can. In the current version (0.1 PreAlpha) you are provided with functions that help you deal with the vector, although it's not really needed. This might be removed in the next versions.

The disadvantage of the 1st way is that... It doesn't feel natural. The 2nd way would be the most logical way to treat an IRC message. I daresay that the 2nd way is close to mIRC scripts' parameter handling method.

The disadvantage of the 2nd way is that the message is kind of reparsed every time you try to do an operation on it; however with modern computers the time difference is insignificant.

You are also provided with a number of address handling functions. They allow you do grab only some stuff from the address of the sender of the IRC message:

address: nickname!username@hostname

  1. Get the nickname from the address. Return result: "nickname".
  2. Get the username from the address. Return result: "username".
  3. Get the hostname from the address. Return result: "hostname".
  4. Get the nickname from the address in a match style. Return result: "nickname!*@*".
  5. Get the username from the address in a match style. Return result: "*!username@*".
  6. Get the hostname from the address in a match style. Return result: "*!*@hostname".

And many other variations of the above.

Hosted by logo