Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 28.02 KB | None | 0 0
  1. #include <ctime>
  2.  
  3. #include <iostream>
  4.  
  5. #include <my_global.h>
  6.  
  7. #include <mysql.h>
  8.  
  9.  
  10.  
  11. #include "bot.h"
  12.  
  13. #include "sicl.h"
  14.  
  15. #include "srfl.h"
  16.  
  17. #include "stristr.cpp"
  18.  
  19.  
  20.  
  21. using namespace SPS;
  22.  
  23. using namespace std;
  24.  
  25.  
  26.  
  27. int main()
  28.  
  29. {
  30.  
  31.     SICL *irc = new SICL();
  32.  
  33.     SRFL *misc = new SRFL();
  34.  
  35.  
  36.  
  37.     cout << "WAT " << VERSION_STR << " -- Using MySQL " << mysql_get_client_info() << ", SICL " << irc->GetVersion() << ", and SRFL " << misc->GetVersion() << "\n";
  38.  
  39.     cout << "Created by Snai\n\n";
  40.  
  41.  
  42.  
  43.     FILE *ini = fopen("bot.ini", "r");
  44.  
  45.  
  46.  
  47.     if(ini)
  48.  
  49.     {
  50.  
  51.         bool direct = false;
  52.  
  53.         bool directed = false;
  54.  
  55.         bool first = true;
  56.  
  57.         bool first2 = true;
  58.  
  59.         bool flood = false;
  60.  
  61.         bool waitForAnswer = false;
  62.  
  63.         bool waitForNick = false;
  64.  
  65.  
  66.  
  67.         char *buf353 = new char[1024];
  68.  
  69.         char *channel = new char[1024];
  70.  
  71.         char *contents = new char[1024 * 64];
  72.  
  73.         char *direct2 = new char[1024];
  74.  
  75.         char *email = new char[1024];
  76.  
  77.         char *lastChannel = new char[1024];
  78.  
  79.         char *lastNick = new char[1024];
  80.  
  81.         char *lastQuestion = new char[1024 * 64];
  82.  
  83.         char *lastQuestion2 = new char[1024 * 64];
  84.  
  85.         char *master = new char[1024];
  86.  
  87.         char *mysqlDatabase = new char[1024];
  88.  
  89.         char *mysqlPassword = new char[1024];
  90.  
  91.         char *mysqlPort = new char[1024];
  92.  
  93.         char *mysqlServer = new char[1024];
  94.  
  95.         char *mysqlUser = new char[1024];
  96.  
  97.         char *nick = new char[1024];
  98.  
  99.         char *password = new char[1024];
  100.  
  101.         char *port = new char[1024];
  102.  
  103.         char *server = new char[1024];
  104.  
  105.         char *user = new char[1024];
  106.  
  107.         char *users[1024];
  108.  
  109.         char *happy[5];
  110.  
  111.         char *responses[5];
  112.  
  113.  
  114.  
  115.         for(int i = 0; i < 5; i++)
  116.  
  117.         {
  118.  
  119.             happy[i] = new char[1024];
  120.  
  121.  
  122.  
  123.             responses[i] = new char[1024];
  124.  
  125.  
  126.  
  127.             memset(happy[i], 0, 1024);
  128.  
  129.             memset(responses[i], 0, 1024);
  130.  
  131.         }
  132.  
  133.  
  134.  
  135.         _snprintf(responses[0], 1023, "You fucking spammer.");
  136.  
  137.         _snprintf(responses[1], 1023, "Why so spam");
  138.  
  139.         _snprintf(responses[2], 1023, "SPAMMAR");
  140.  
  141.         _snprintf(responses[3], 1023, "%cACTION goes brb for 60 secs.%c", 1, 1);
  142.  
  143.         _snprintf(responses[4], 1023, "YOU ARE A DAMN SPAMMER");
  144.  
  145.         _snprintf(happy[0], 1023, "kdone");
  146.  
  147.         _snprintf(happy[1], 1023, "i r back");
  148.  
  149.         _snprintf(happy[2], 1023, "I decided to get some lube. But I am back now.");
  150.  
  151.         _snprintf(happy[3], 1023, "Back. Please do not feather me.");
  152.  
  153.         _snprintf(happy[4], 1023, "%cACTION walks back into the room without realizing he forgot his dildo%c", 1, 1);
  154.  
  155.  
  156.  
  157.         float currentTickCount = 0.0f;
  158.  
  159.         float lastTickCount = 0.0f;
  160.  
  161.  
  162.  
  163.         int count = 0;
  164.  
  165.  
  166.  
  167.         for(int i = 0; i < 1023; i++)
  168.  
  169.         {
  170.  
  171.             users[i] = new char[1024];
  172.  
  173.  
  174.  
  175.             memset(users[i], 0, 1024);
  176.  
  177.         }
  178.  
  179.  
  180.  
  181.         int position = 0;
  182.  
  183.  
  184.  
  185.         memset(buf353, 0, 1024);
  186.  
  187.         memset(channel, 0, 1024);
  188.  
  189.         memset(contents, 0, 1024 * 64);
  190.  
  191.         memset(direct2, 0, 1024);
  192.  
  193.         memset(email, 0, 1024);
  194.  
  195.         memset(lastChannel, 0, 1024);
  196.  
  197.         memset(lastNick, 0, 1024);
  198.  
  199.         memset(lastQuestion, 0, 1024);
  200.  
  201.         memset(master, 0, 1024);
  202.  
  203.         memset(mysqlDatabase, 0, 1024);
  204.  
  205.         memset(mysqlPassword, 0, 1024);
  206.  
  207.         memset(mysqlPort, 0, 1024);
  208.  
  209.         memset(mysqlServer, 0, 1024);
  210.  
  211.         memset(mysqlUser, 0, 1024);
  212.  
  213.         memset(nick, 0, 1024);
  214.  
  215.         memset(password, 0, 1024);
  216.  
  217.         memset(port, 0, 1024);
  218.  
  219.         memset(server, 0, 1024);
  220.  
  221.         memset(user, 0, 1024);
  222.  
  223.  
  224.  
  225.         fread(contents, 1, (1024 * 64) - 1, ini);
  226.  
  227.         fclose(ini);
  228.  
  229.  
  230.  
  231.         char *silentTest = new char[1024];
  232.  
  233.  
  234.  
  235.         memset(silentTest, 0, 1024);
  236.  
  237.  
  238.  
  239.         misc->CopyIniValue(contents, "[irc]", "direct = ", direct2);
  240.  
  241.         misc->CopyIniValue(contents, "[irc]", "silent = ", silentTest);
  242.  
  243.  
  244.  
  245.         bool silent = false;
  246.  
  247.  
  248.  
  249.         if(!_stricmp(silentTest, "false"))
  250.  
  251.             silent = false;
  252.  
  253.  
  254.  
  255.         else if(!_stricmp(silentTest, "true"))
  256.  
  257.             silent = true;
  258.  
  259.  
  260.  
  261.         else
  262.  
  263.             silent = false;
  264.  
  265.  
  266.  
  267.         if(!_stricmp(direct2, "false"))
  268.  
  269.             direct = false;
  270.  
  271.  
  272.  
  273.         else if(!_stricmp(direct2, "true"))
  274.  
  275.             direct = true;
  276.  
  277.  
  278.  
  279.         else
  280.  
  281.             direct = false;
  282.  
  283.  
  284.  
  285.         delete direct2;
  286.  
  287.         delete silentTest;
  288.  
  289.  
  290.  
  291.         misc->CopyIniValue(contents, "[irc]", "channel = ", channel);
  292.  
  293.         misc->CopyIniValue(contents, "[irc]", "email = ", email);
  294.  
  295.         misc->CopyIniValue(contents, "[irc]", "master = ", master);
  296.  
  297.         misc->CopyIniValue(contents, "[irc]", "nick = ", nick);
  298.  
  299.         misc->CopyIniValue(contents, "[irc]", "password = ", password);
  300.  
  301.         misc->CopyIniValue(contents, "[irc]", "port = ", port);
  302.  
  303.         misc->CopyIniValue(contents, "[irc]", "server = ", server);
  304.  
  305.         misc->CopyIniValue(contents, "[irc]", "user = ", user);
  306.  
  307.         misc->CopyIniValue(contents, "[mysql]", "database = ", mysqlDatabase);
  308.  
  309.         misc->CopyIniValue(contents, "[mysql]", "password = ", mysqlPassword);
  310.  
  311.         misc->CopyIniValue(contents, "[mysql]", "port = ", mysqlPort);
  312.  
  313.         misc->CopyIniValue(contents, "[mysql]", "server = ", mysqlServer);
  314.  
  315.         misc->CopyIniValue(contents, "[mysql]", "user = ", mysqlUser);
  316.  
  317.  
  318.  
  319.         _snprintf(buf353, 1023, " 353 %s", nick);
  320.  
  321.        
  322.  
  323.         irc->Connect(server, atoi(port));
  324.  
  325.         irc->Send("USER %s %s %s :%s\r\n", user, user, user, user);
  326.  
  327.         irc->Send("NICK %s\r\n", nick);
  328.  
  329.  
  330.  
  331.         char *received = new char[1024 * 64];
  332.  
  333.  
  334.  
  335.         memset(received, 0, (1024 * 64) - 1);
  336.  
  337.  
  338.  
  339.         MYSQL *mysql = mysql_init(0);
  340.  
  341.  
  342.  
  343.         if(mysql)
  344.  
  345.         {
  346.  
  347.             if(mysql_real_connect(mysql, mysqlServer, mysqlUser, mysqlPassword, mysqlDatabase, atoi(mysqlPort), 0, 0))
  348.  
  349.             {
  350.  
  351.                 bool answer = false;
  352.  
  353.  
  354.  
  355.                 cout << "Connected to " << mysqlServer << ":" << mysqlPort << "\n";
  356.  
  357.  
  358.  
  359.                 while(irc->Receive(received, (1024 * 64) - 1) > 0)
  360.  
  361.                 {
  362.  
  363.                     currentTickCount = clock() * 0.001f;
  364.  
  365.  
  366.  
  367.                     for(int i = 0; i < (int)strlen(received); i++)
  368.  
  369.                     {
  370.  
  371.                         if(received[i] == '%')
  372.  
  373.                             received[i] = '^';
  374.  
  375.                     }
  376.  
  377.  
  378.  
  379.                     if(strstr(received, "PING :"))
  380.  
  381.                     {
  382.  
  383.                         if(first)
  384.  
  385.                         {
  386.  
  387.                             irc->Send("PRIVMSG NickServ :REGISTER %s %s\r\n", password, email);
  388.  
  389.                             irc->Send("PRIVMSG NickServ :REGISTER %s %s %s %s\r\n", password, password, email, email);
  390.  
  391.                             irc->Send("PRIVMSG NickServ :IDENTIFY %s\r\n", password);
  392.  
  393.  
  394.  
  395.                             first = false;
  396.  
  397.                         }
  398.  
  399.  
  400.  
  401.                         char *pong = new char[1024];
  402.  
  403.  
  404.  
  405.                         memset(pong, 0, 1024);
  406.  
  407.  
  408.  
  409.                         misc->CopySubString(received, "PING :", "\r", pong);
  410.  
  411.  
  412.  
  413.                         irc->Send("PONG :%s\r\n", pong);
  414.  
  415.  
  416.  
  417.                         delete pong;
  418.  
  419.                     }
  420.  
  421.  
  422.  
  423.                     if(stristr(received, "End") && first2)
  424.  
  425.                     {
  426.  
  427.                         first2 = false;
  428.  
  429.  
  430.  
  431.                         irc->Send("PRIVMSG NickServ :IDENTIFY %s\r\n", password);
  432.  
  433.                         irc->Send("JOIN %s\r\n", channel);
  434.  
  435.                         irc->Send("NAMES %s\r\n", channel);
  436.  
  437.  
  438.  
  439.                         cout << "Connected to " << server << ":" << port << "\n";
  440.  
  441.                     }
  442.  
  443.  
  444.  
  445.                     if(stristr(received, " KICK #") && !stristr(received, "PRIVMSG"))
  446.  
  447.                     {
  448.  
  449.                         char *nickname2 = new char[1024];
  450.  
  451.                         char *channel2 = new char[1024];
  452.  
  453.  
  454.  
  455.                         memset(nickname2, 0, 1024);
  456.  
  457.                         memset(channel2, 0, 1024);
  458.  
  459.  
  460.  
  461.                         misc->CopySubString(received, " KICK #", " ", channel2);
  462.  
  463.                         misc->CopySubString(stristr(received, " KICK #"), channel2, " :", nickname2);
  464.  
  465.  
  466.  
  467.                         char *nickname3 = (nickname2 + 1);
  468.  
  469.  
  470.  
  471.                         if(!_stricmp(nick, nickname3))
  472.  
  473.                             irc->Send("JOIN #%s\r\n", channel2);
  474.  
  475.  
  476.  
  477.                         delete nickname2;
  478.  
  479.                         delete channel2;
  480.  
  481.                     }
  482.  
  483.  
  484.  
  485.                     if(stristr(received, "Cannot join channel") && !stristr(received, "PRIVMSG"))
  486.  
  487.                     {
  488.  
  489.                         char *channel2 = new char[1024];
  490.  
  491.  
  492.  
  493.                         memset(channel2, 0, 1024);
  494.  
  495.  
  496.  
  497.                         misc->CopySubString(received, nick, " :Cannot join channel", channel2);
  498.  
  499.  
  500.  
  501.                         char *channel3 = (channel2 + 2);
  502.  
  503.  
  504.  
  505.                         irc->Send("JOIN #%s\r\n", channel3);
  506.  
  507.  
  508.  
  509.                         delete channel2;
  510.  
  511.                     }
  512.  
  513.  
  514.  
  515.                     if(strstr(received, " JOIN :#") && !stristr(received, "PRIVMSG"))
  516.  
  517.                     {
  518.  
  519.                         char *nickname = new char[1024];
  520.  
  521.  
  522.  
  523.                         memset(nickname, 0, 1024);
  524.  
  525.  
  526.  
  527.                         misc->CopySubString(received, ":", "!", nickname);
  528.  
  529.  
  530.  
  531.                         bool nickFound = false;
  532.  
  533.  
  534.  
  535.                         char *nickname2 = nickname;
  536.  
  537.  
  538.  
  539.                         if(stristr(nickname2, ":") == nickname2)
  540.  
  541.                             nickname2++;
  542.  
  543.  
  544.  
  545.                         for(int i = 0; i < position; i++)
  546.  
  547.                         {
  548.  
  549.                             if(!strcmp(users[i], nickname2))
  550.  
  551.                                 nickFound = true;
  552.  
  553.                         }
  554.  
  555.  
  556.  
  557.                         if(!nickFound)
  558.  
  559.                         {
  560.  
  561.                             if(position >= 1022)
  562.  
  563.                             {
  564.  
  565.                                 position = 0;
  566.  
  567.  
  568.  
  569.                                 for(int i = 0; i < 1023; i++)
  570.  
  571.                                     memset(users[i], 0, 1024);
  572.  
  573.  
  574.  
  575.                                 irc->Send("NAMES %s\r\n", channel);
  576.  
  577.                             }
  578.  
  579.                             else
  580.  
  581.                             {
  582.  
  583.                                 _snprintf(users[position], 1023, nickname2);
  584.  
  585.  
  586.  
  587.                                 cout << "Nick found: " << users[position] << "\n";
  588.  
  589.  
  590.  
  591.                                 position++;
  592.  
  593.                             }
  594.  
  595.                         }
  596.  
  597.  
  598.  
  599.                         delete nickname;
  600.  
  601.                     }
  602.  
  603.                    
  604.  
  605.                     if(strstr(received, " NICK ") && !stristr(received, "PRIVMSG"))
  606.  
  607.                     {
  608.  
  609.                         char *nickname = new char[1024];
  610.  
  611.  
  612.  
  613.                         memset(nickname, 0, 1024);
  614.  
  615.  
  616.  
  617.                         misc->CopySubString(received, " NICK ", "\r", nickname);
  618.  
  619.  
  620.  
  621.                         bool nickFound = false;
  622.  
  623.  
  624.  
  625.                         char *nickname2 = nickname;
  626.  
  627.  
  628.  
  629.                         if(stristr(nickname2, ":") == nickname2)
  630.  
  631.                             nickname2++;
  632.  
  633.  
  634.  
  635.                         for(int i = 0; i < position; i++)
  636.  
  637.                         {
  638.  
  639.                             if(!strcmp(users[i], nickname2))
  640.  
  641.                                 nickFound = true;
  642.  
  643.                         }
  644.  
  645.  
  646.  
  647.                         if(!nickFound)
  648.  
  649.                         {
  650.  
  651.                             if(position >= 1024)
  652.  
  653.                             {
  654.  
  655.                                 position = 0;
  656.  
  657.  
  658.  
  659.                                 for(int i = 0; i < 1023; i++)
  660.  
  661.                                     memset(users[i], 0, 1024);
  662.  
  663.  
  664.  
  665.                                 irc->Send("NAMES %s\r\n", channel);
  666.  
  667.                             }
  668.  
  669.                             else
  670.  
  671.                             {
  672.  
  673.                                 _snprintf(users[position], 1023, nickname2);
  674.  
  675.  
  676.  
  677.                                 cout << "Nick found: " << users[position] << "\n";
  678.  
  679.  
  680.  
  681.                                 position++;
  682.  
  683.                             }
  684.  
  685.                         }
  686.  
  687.  
  688.  
  689.                         delete nickname;
  690.  
  691.                     }
  692.  
  693.                    
  694.  
  695.                     if(strstr(received, buf353) && !stristr(received, "PRIVMSG #"))
  696.  
  697.                     {
  698.  
  699.                         char *buf = new char[1024 * 64];
  700.  
  701.  
  702.  
  703.                         memset(buf, 0, (1024 * 64) - 1);
  704.  
  705.  
  706.  
  707.                         misc->CopySubString(received, buf353, "\r", buf);
  708.  
  709.  
  710.  
  711.                         char *place = (strstr(buf, " :") + 2);
  712.  
  713.  
  714.  
  715.                         place = strtok(place, " ");
  716.  
  717.  
  718.  
  719.                         bool nickFound = false;
  720.  
  721.  
  722.  
  723.                         char *place2;
  724.  
  725.  
  726.  
  727.                         while(place)
  728.  
  729.                         {
  730.  
  731.                             if((place[0] == '+') || (place[0] == '@') || (place[0] == '^') || (place[0] == '~') || (place[0] == '&'))
  732.  
  733.                             {
  734.  
  735.                                 if((place[1] == '+') || (place[1] == '@') || (place[1] == '^') || (place[1] == '~') || (place[1] == '&'))
  736.  
  737.                                     place2 = (place + 2);
  738.  
  739.  
  740.  
  741.                                 else
  742.  
  743.                                     place2 = (place + 1);
  744.  
  745.                             }
  746.  
  747.                             else
  748.  
  749.                                 place2 = place;
  750.  
  751.  
  752.  
  753.                             char *nickname2 = place2;
  754.  
  755.  
  756.  
  757.                             if(stristr(nickname2, ":") == nickname2)
  758.  
  759.                                 nickname2++;
  760.  
  761.  
  762.  
  763.                             for(int i = 0; i < position; i++)
  764.  
  765.                             {
  766.  
  767.                                 if(!strcmp(users[i], nickname2))
  768.  
  769.                                     nickFound = true;
  770.  
  771.                             }
  772.  
  773.  
  774.  
  775.                             if(!nickFound)
  776.  
  777.                             {
  778.  
  779.                                 if(position >= 1024)
  780.  
  781.                                 {
  782.  
  783.                                     position = 0;
  784.  
  785.  
  786.  
  787.                                     for(int i = 0; i < 1023; i++)
  788.  
  789.                                         memset(users[i], 0, 1024);
  790.  
  791.  
  792.  
  793.                                     irc->Send("NAMES %s\r\n", channel);
  794.  
  795.                                 }
  796.  
  797.                                 else
  798.  
  799.                                 {
  800.  
  801.                                     _snprintf(users[position], 1023, nickname2);
  802.  
  803.  
  804.  
  805.                                     cout << "Nick found: " << users[position] << "\n";
  806.  
  807.  
  808.  
  809.                                     position++;
  810.  
  811.                                 }
  812.  
  813.                             }
  814.  
  815.  
  816.  
  817.                             nickFound = false;
  818.  
  819.  
  820.  
  821.                             place = strtok(0, " ");
  822.  
  823.                         }
  824.  
  825.  
  826.  
  827.                         delete buf;
  828.  
  829.                     }
  830.  
  831.                    
  832.  
  833.                     if(strstr(received, " PRIVMSG #"))
  834.  
  835.                     {
  836.  
  837.                         char *currentChannel = new char[1024];
  838.  
  839.                         char *host = new char[1024];
  840.  
  841.                         char *mastername = new char[1024];
  842.  
  843.                         char *nickname = new char[1024];
  844.  
  845.                         char *question = new char[1024 * 64];
  846.  
  847.                         char *username = new char[1024];
  848.  
  849.  
  850.  
  851.                         memset(currentChannel, 0, 1024);
  852.  
  853.                         memset(host, 0, 1024);
  854.  
  855.                         memset(mastername, 0, 1024);
  856.  
  857.                         memset(nickname, 0, 1024);
  858.  
  859.                         memset(question, 0, 1024 * 64);
  860.  
  861.                         memset(username, 0, 1024);
  862.  
  863.  
  864.  
  865.                         misc->CopySubString(received, "#", " :", currentChannel);
  866.  
  867.                         misc->CopySubString(received, ":", " ", mastername);
  868.  
  869.                         misc->CopySubString(received, ":", "!", nickname);
  870.  
  871.                         misc->CopySubString(received, "!", "@", username);
  872.  
  873.                         misc->CopySubString(received, "@", " ", host);
  874.  
  875.                         misc->CopySubString(received, " :", "\r", question);
  876.  
  877.  
  878.  
  879.                         for(int i = 0; i < (int)strlen(question); i++)
  880.  
  881.                         {
  882.  
  883.                             if(question[i] == '\'')
  884.  
  885.                                 question[i] = '`';
  886.  
  887.  
  888.  
  889.                             else if(question[i] == '\\')
  890.  
  891.                                 question[i] = '/';
  892.  
  893.                         }
  894.  
  895.  
  896.  
  897.                         if(!strcmp(mastername, master))
  898.  
  899.                         {
  900.  
  901.                             if(stristr(question, "!join #") == question)
  902.  
  903.                             {
  904.  
  905.                                 char *join = (stristr(question, "!join #") + strlen("!join #"));
  906.  
  907.  
  908.  
  909.                                 irc->Send("JOIN #%s\r\n", join);
  910.  
  911.                             }
  912.  
  913.                             else if(stristr(question, "!part #") == question)
  914.  
  915.                             {
  916.  
  917.                                 char *part = (stristr(question, "!part #") + strlen("!part #"));
  918.  
  919.  
  920.  
  921.                                 irc->Send("PART #%s\r\n", part);
  922.  
  923.                             }
  924.  
  925.                             else if(stristr(question, "!master ") == question)
  926.  
  927.                             {
  928.  
  929.                                 char *mastername2 = (stristr(question, "!master ") + strlen("!master "));
  930.  
  931.  
  932.  
  933.                                 memset(master, 0, 1023);
  934.  
  935.  
  936.  
  937.                                 _snprintf(master, 1023, mastername2);
  938.  
  939.  
  940.  
  941.                                 irc->Send("PRIVMSG #%s :'%s' is now my master.\r\n", currentChannel, master);
  942.  
  943.                             }
  944.  
  945.                             else if(!_stricmp(question, "!silent = false"))
  946.  
  947.                                 silent = false;
  948.  
  949.  
  950.  
  951.                             else if(!_stricmp(question, "!silent = true"))
  952.  
  953.                                 silent = true;
  954.  
  955.  
  956.  
  957.                             else if(!_stricmp(question, "!direct = false"))
  958.  
  959.                                 direct = false;
  960.  
  961.  
  962.  
  963.                             else if(!_stricmp(question, "!direct = true"))
  964.  
  965.                                 direct = true;
  966.  
  967.  
  968.  
  969.                             else if(!_stricmp(question, "!quit"))
  970.  
  971.                                 irc->Send("QUIT :WAT %s -- Using MySQL %s, SICL %s, and SRFL %s -- Created by Snail\r\n", VERSION_STR, mysql_get_client_info(), irc->GetVersion(), misc->GetVersion());
  972.  
  973.  
  974.  
  975.                             else if(!_stricmp(question, "!stats"))
  976.  
  977.                             {
  978.  
  979.                                 mysql_query(mysql, "SELECT * FROM data");
  980.  
  981.  
  982.  
  983.                                 MYSQL_RES *result = mysql_store_result(mysql);
  984.  
  985.                                 MYSQL_ROW row;
  986.  
  987.  
  988.  
  989.                                 int questions = 0;
  990.  
  991.  
  992.  
  993.                                 unsigned long bytes = 0;
  994.  
  995.  
  996.  
  997.                                 while((row = mysql_fetch_row(result)))
  998.  
  999.                                 {
  1000.  
  1001.                                     for(int i = 0; i < (int)mysql_num_fields(result); i++)
  1002.  
  1003.                                         bytes += strlen(row[i]);
  1004.  
  1005.  
  1006.  
  1007.                                     questions++;
  1008.  
  1009.                                 }
  1010.  
  1011.  
  1012.  
  1013.                                 mysql_free_result(result);
  1014.  
  1015.  
  1016.  
  1017.                                 mysql_query(mysql, "SELECT * FROM users");
  1018.  
  1019.  
  1020.  
  1021.                                 result = mysql_store_result(mysql);
  1022.  
  1023.  
  1024.  
  1025.                                 int users = 0;
  1026.  
  1027.  
  1028.  
  1029.                                 while((row = mysql_fetch_row(result)))
  1030.  
  1031.                                 {
  1032.  
  1033.                                     for(int i = 0; i < (int)mysql_num_fields(result); i++)
  1034.  
  1035.                                         bytes += strlen(row[i]);
  1036.  
  1037.  
  1038.  
  1039.                                     users++;
  1040.  
  1041.                                 }
  1042.  
  1043.  
  1044.  
  1045.                                 mysql_free_result(result);
  1046.  
  1047.  
  1048.  
  1049.                                 char *buft = new char[1024 * 64];
  1050.  
  1051.  
  1052.  
  1053.                                 memset(buft, 0, 1024 * 64);
  1054.  
  1055.  
  1056.  
  1057.                                 _snprintf(buft, (1024 * 64) - 1, "PRIVMSG #%s :My database contains %u unique entries from %u different users. Also, I think the size of my database is about %.02f MB.\r\n", currentChannel, questions, users, (bytes / 1024.0f) / 1024.0f);
  1058.  
  1059.  
  1060.  
  1061.                                 irc->Send(buft);
  1062.  
  1063.  
  1064.  
  1065.                                 delete buft;
  1066.  
  1067.                             }
  1068.  
  1069.                             else if(stristr(question, "!rewrite |q|") == question)
  1070.  
  1071.                             {
  1072.  
  1073.                                 if(stristr(question, "|a|"))
  1074.  
  1075.                                 {
  1076.  
  1077.                                     char *answer = (stristr(question, "|a|") + 3);
  1078.  
  1079.                                     char *question2 = new char[1024 * 64];
  1080.  
  1081.  
  1082.  
  1083.                                     memset(question2, 0, 1024 * 64);
  1084.  
  1085.  
  1086.  
  1087.                                     misc->CopySubStringI(question, "|q|", "|a|", question2);
  1088.  
  1089.  
  1090.  
  1091.                                     char *bufz = new char[1024 * 64];
  1092.  
  1093.  
  1094.  
  1095.                                     memset(bufz, 0, 1024 * 64);
  1096.  
  1097.  
  1098.  
  1099.                                     _snprintf(bufz, (1024 * 64) - 1, "UPDATE data set answer = '%s' WHERE question = '%s';", answer, question2);
  1100.  
  1101.  
  1102.  
  1103.                                     mysql_query(mysql, bufz);
  1104.  
  1105.  
  1106.  
  1107.                                     delete bufz;
  1108.  
  1109.                                     delete question2;
  1110.  
  1111.                                 }
  1112.  
  1113.                             }
  1114.  
  1115.                             else if(stristr(question, "!lookup "))
  1116.  
  1117.                             {
  1118.  
  1119.                                 mysql_query(mysql, "SELECT * FROM users");
  1120.  
  1121.  
  1122.  
  1123.                                 MYSQL_RES *result = mysql_store_result(mysql);
  1124.  
  1125.                                 MYSQL_ROW row;
  1126.  
  1127.  
  1128.  
  1129.                                 char *nicktmp = (stristr(question, "!lookup ") + strlen("!lookup "));
  1130.  
  1131.  
  1132.  
  1133.                                 irc->Send("PRIVMSG %s :Here is a list of records containing the nick '%s':\r\n", nickname, nicktmp);
  1134.  
  1135.  
  1136.  
  1137.                                 bool found = false;
  1138.  
  1139.  
  1140.  
  1141.                                 while((row = mysql_fetch_row(result)))
  1142.  
  1143.                                 {
  1144.  
  1145.                                     if(stristr(row[1], nicktmp))
  1146.  
  1147.                                     {
  1148.  
  1149.                                         irc->Send("PRIVMSG %s :- %s!%s@%s\r\n", nickname, row[1], row[2], row[3]);
  1150.  
  1151.  
  1152.  
  1153.                                         found = true;
  1154.  
  1155.  
  1156.  
  1157.                                         Sleep(500);
  1158.  
  1159.                                     }
  1160.  
  1161.                                 }
  1162.  
  1163.  
  1164.  
  1165.                                 mysql_free_result(result);
  1166.  
  1167.  
  1168.  
  1169.                                 if(!found)
  1170.  
  1171.                                     irc->Send("PRIVMSG %s :Sorry, no records of '%s' exist in my database.\r\n", nickname, nicktmp);
  1172.  
  1173.                             }
  1174.  
  1175.                             else if(stristr(question, "!lookuphost "))
  1176.  
  1177.                             {
  1178.  
  1179.                                 mysql_query(mysql, "SELECT * FROM users");
  1180.  
  1181.  
  1182.  
  1183.                                 MYSQL_RES *result = mysql_store_result(mysql);
  1184.  
  1185.                                 MYSQL_ROW row;
  1186.  
  1187.  
  1188.  
  1189.                                 char *nicktmp = (stristr(question, "!lookuphost ") + strlen("!lookuphost "));
  1190.  
  1191.  
  1192.  
  1193.                                 irc->Send("PRIVMSG %s :Here is a list of records containing the host '%s':\r\n", nickname, nicktmp);
  1194.  
  1195.  
  1196.  
  1197.                                 bool found = false;
  1198.  
  1199.  
  1200.  
  1201.                                 while((row = mysql_fetch_row(result)))
  1202.  
  1203.                                 {
  1204.  
  1205.                                     if(stristr(row[3], nicktmp))
  1206.  
  1207.                                     {
  1208.  
  1209.                                         irc->Send("PRIVMSG %s :- %s!%s@%s\r\n", nickname, row[1], row[2], row[3]);
  1210.  
  1211.  
  1212.  
  1213.                                         found = true;
  1214.  
  1215.  
  1216.  
  1217.                                         Sleep(500);
  1218.  
  1219.                                     }
  1220.  
  1221.                                 }
  1222.  
  1223.  
  1224.  
  1225.                                 mysql_free_result(result);
  1226.  
  1227.  
  1228.  
  1229.                                 if(!found)
  1230.  
  1231.                                     irc->Send("PRIVMSG %s :Sorry, no records of '%s' exist in my database.\r\n", nickname, nicktmp);
  1232.  
  1233.                             }
  1234.  
  1235.                             else if(stristr(question, "!lookupuser "))
  1236.  
  1237.                             {
  1238.  
  1239.                                 mysql_query(mysql, "SELECT * FROM users");
  1240.  
  1241.  
  1242.  
  1243.                                 MYSQL_RES *result = mysql_store_result(mysql);
  1244.  
  1245.                                 MYSQL_ROW row;
  1246.  
  1247.  
  1248.  
  1249.                                 char *nicktmp = (stristr(question, "!lookupuser ") + strlen("!lookupuser "));
  1250.  
  1251.  
  1252.  
  1253.                                 irc->Send("PRIVMSG %s :Here is a list of records containing the user '%s':\r\n", nickname, nicktmp);
  1254.  
  1255.  
  1256.  
  1257.                                 bool found = false;
  1258.  
  1259.  
  1260.  
  1261.                                 while((row = mysql_fetch_row(result)))
  1262.  
  1263.                                 {
  1264.  
  1265.                                     if(stristr(row[2], nicktmp))
  1266.  
  1267.                                     {
  1268.  
  1269.                                         irc->Send("PRIVMSG %s :- %s!%s@%s\r\n", nickname, row[1], row[2], row[3]);
  1270.  
  1271.  
  1272.  
  1273.                                         found = true;
  1274.  
  1275.  
  1276.  
  1277.                                         Sleep(500);
  1278.  
  1279.                                     }
  1280.  
  1281.                                 }
  1282.  
  1283.  
  1284.  
  1285.                                 mysql_free_result(result);
  1286.  
  1287.  
  1288.  
  1289.                                 if(!found)
  1290.  
  1291.                                     irc->Send("PRIVMSG %s :Sorry, no records of '%s' exist in my database.\r\n", nickname, nicktmp);
  1292.  
  1293.                             }
  1294.  
  1295.                             else if(stristr(question, "!quit ") == question)
  1296.  
  1297.                             {
  1298.  
  1299.                                 char *quit = (stristr(question, "!quit ") + strlen("!quit "));
  1300.  
  1301.  
  1302.  
  1303.                                 irc->Send("QUIT :%s\r\n", quit);
  1304.  
  1305.                             }
  1306.  
  1307.                         }
  1308.  
  1309.  
  1310.  
  1311.                         if(answer && waitForNick && (strstr(question, "!") != question) && (strcmp(lastNick, nickname) != 0) && !strcmp(lastChannel, currentChannel))
  1312.  
  1313.                         {
  1314.  
  1315.                             waitForAnswer = false;
  1316.  
  1317.  
  1318.  
  1319.                             mysql_query(mysql, "SELECT * FROM users");
  1320.  
  1321.  
  1322.  
  1323.                             MYSQL_RES *result = mysql_store_result(mysql);
  1324.  
  1325.                             MYSQL_ROW row;
  1326.  
  1327.  
  1328.  
  1329.                             bool found = false;
  1330.  
  1331.  
  1332.  
  1333.                             while((row = mysql_fetch_row(result)))
  1334.  
  1335.                             {
  1336.  
  1337.                                 if((!strcmp(row[1], nickname)) && (!strcmp(row[2], username)) && (!strcmp(row[3], host)))
  1338.  
  1339.                                 {
  1340.  
  1341.                                     found = true;
  1342.  
  1343.  
  1344.  
  1345.                                     break;
  1346.  
  1347.                                 }
  1348.  
  1349.                             }
  1350.  
  1351.  
  1352.  
  1353.                             if(!found)
  1354.  
  1355.                             {
  1356.  
  1357.                                 char *buf = new char[1024 * 64];
  1358.  
  1359.  
  1360.  
  1361.                                 memset(buf, 0, 1024 * 64);
  1362.  
  1363.  
  1364.  
  1365.                                 _snprintf(buf, (1024 * 64) - 1, "INSERT INTO users (nick, user, host) VALUES ('%s', '%s', '%s');", nickname, username, host);
  1366.  
  1367.  
  1368.  
  1369.                                 mysql_query(mysql, buf);
  1370.  
  1371.  
  1372.  
  1373.                                 cout << "New user: " << nickname << "!" << username << "@" << host << "\n";
  1374.  
  1375.  
  1376.  
  1377.                                 delete buf;
  1378.  
  1379.                             }
  1380.  
  1381.  
  1382.  
  1383.                             mysql_free_result(result);
  1384.  
  1385.  
  1386.  
  1387.                             char *buf = new char[1024 * 64];
  1388.  
  1389.  
  1390.  
  1391.                             memset(buf, 0, 1024 * 64);
  1392.  
  1393.  
  1394.  
  1395.                             char *questionx = question;
  1396.  
  1397.  
  1398.  
  1399.                             for(int i = 0; i < position; i++)
  1400.  
  1401.                             {
  1402.  
  1403.                                 if((stristr(questionx, users[i]) == questionx) && ((strstr(questionx, ":") == (questionx + strlen(users[i]))) || (strstr(questionx, ",") == (questionx + strlen(users[i])))))
  1404.  
  1405.                                     questionx += (strlen(users[i]) + 2);
  1406.  
  1407.                                    
  1408.  
  1409.                                 else if((stristr(questionx, users[i]) == questionx) && (strstr(questionx, " ") == (questionx + strlen(users[i]))))
  1410.  
  1411.                                     questionx += (strlen(users[i]) + 1);
  1412.  
  1413.  
  1414.  
  1415.                                 else if((questionx[0] == '@') && (stristr(questionx, users[i]) == (questionx + 1)) && (stristr(questionx, " ") == (questionx + (strlen(users[i]) + 1))))
  1416.  
  1417.                                     questionx += (strlen(users[i]) + 2);
  1418.  
  1419.  
  1420.  
  1421.                                 else if((questionx[0] == '@') && (stristr(questionx, users[i]) == (questionx + 1)) && (stristr(questionx, " ") == (questionx + (strlen(users[i]) + 2))) && ((stristr(questionx, ",") == (questionx + (strlen(users[i]) + 1)))) || (stristr(questionx, ":") == (questionx + (strlen(users[i]) + 1))))
  1422.  
  1423.                                     questionx += (strlen(users[i]) + 3);
  1424.  
  1425.                             }
  1426.  
  1427.  
  1428.  
  1429.                             _snprintf(buf, (1024 * 64) - 1, "UPDATE data set answer = '%s' WHERE question = '%s';", questionx, lastQuestion);
  1430.  
  1431.  
  1432.  
  1433.                             cout << "Found new entry: " << lastQuestion << " -> " << questionx << "\n";
  1434.  
  1435.  
  1436.  
  1437.                             mysql_query(mysql, buf);
  1438.  
  1439.  
  1440.  
  1441.                             if(directed && !silent)
  1442.  
  1443.                                 directed = false;
  1444.  
  1445.                         }
  1446.  
  1447.  
  1448.  
  1449.                         if((strstr(question, "!") != question))
  1450.  
  1451.                         {
  1452.  
  1453.                             mysql_query(mysql, "SELECT * FROM users");
  1454.  
  1455.  
  1456.  
  1457.                             MYSQL_RES *result = mysql_store_result(mysql);
  1458.  
  1459.                             MYSQL_ROW row;
  1460.  
  1461.  
  1462.  
  1463.                             bool found = false;
  1464.  
  1465.  
  1466.  
  1467.                             while((row = mysql_fetch_row(result)))
  1468.  
  1469.                             {
  1470.  
  1471.                                 if((!strcmp(row[1], nickname)) && (!strcmp(row[2], username)) && (!strcmp(row[3], host)))
  1472.  
  1473.                                 {
  1474.  
  1475.                                     found = true;
  1476.  
  1477.  
  1478.  
  1479.                                     break;
  1480.  
  1481.                                 }
  1482.  
  1483.                             }
  1484.  
  1485.  
  1486.  
  1487.                             if(!found)
  1488.  
  1489.                             {
  1490.  
  1491.                                 char *buf = new char[1024 * 64];
  1492.  
  1493.  
  1494.  
  1495.                                 memset(buf, 0, 1024 * 64);
  1496.  
  1497.  
  1498.  
  1499.                                 _snprintf(buf, (1024 * 64) - 1, "INSERT INTO users (nick, user, host) VALUES ('%s', '%s', '%s');", nickname, username, host);
  1500.  
  1501.  
  1502.  
  1503.                                 mysql_query(mysql, buf);
  1504.  
  1505.  
  1506.  
  1507.                                 cout << "New user: " << nickname << "!" << username << "@" << host << "\n";
  1508.  
  1509.  
  1510.  
  1511.                                 delete buf;
  1512.  
  1513.                             }
  1514.  
  1515.  
  1516.  
  1517.                             found = false;
  1518.  
  1519.  
  1520.  
  1521.                             mysql_free_result(result);
  1522.  
  1523.                             mysql_query(mysql, "SELECT * FROM data");
  1524.  
  1525.  
  1526.  
  1527.                             result = mysql_store_result(mysql);
  1528.  
  1529.  
  1530.  
  1531.                             char *questionx = question;
  1532.  
  1533.  
  1534.  
  1535.                             for(int i = 0; i < position; i++)
  1536.  
  1537.                             {
  1538.  
  1539.                                 if((stristr(questionx, users[i]) == questionx) && ((strstr(questionx, ":") == (questionx + strlen(users[i]))) || (strstr(questionx, ",") == (questionx + strlen(users[i])))))
  1540.  
  1541.                                     questionx += (strlen(users[i]) + 2);
  1542.  
  1543.                                    
  1544.  
  1545.                                 else if((stristr(questionx, users[i]) == questionx) && (strstr(questionx, " ") == (questionx + strlen(users[i]))))
  1546.  
  1547.                                     questionx += (strlen(users[i]) + 1);
  1548.  
  1549.  
  1550.  
  1551.                                 else if((questionx[0] == '@') && (stristr(questionx, users[i]) == (questionx + 1)) && (stristr(questionx, " ") == (questionx + (strlen(users[i]) + 1))))
  1552.  
  1553.                                     questionx += (strlen(users[i]) + 2);
  1554.  
  1555.  
  1556.  
  1557.                                 else if((questionx[0] == '@') && (stristr(questionx, users[i]) == (questionx + 1)) && (stristr(questionx, " ") == (questionx + (strlen(users[i]) + 2))) && ((stristr(questionx, ",") == (questionx + (strlen(users[i]) + 1)))) || (stristr(questionx, ":") == (questionx + (strlen(users[i]) + 1))))
  1558.  
  1559.                                     questionx += (strlen(users[i]) + 3);
  1560.  
  1561.                             }
  1562.  
  1563.  
  1564.  
  1565.                             while((row = mysql_fetch_row(result)))
  1566.  
  1567.                             {
  1568.  
  1569.                                 if(!_stricmp(row[1], questionx))
  1570.  
  1571.                                 {
  1572.  
  1573.                                     found = true;
  1574.  
  1575.  
  1576.  
  1577.                                     break;
  1578.  
  1579.                                 }
  1580.  
  1581.                             }
  1582.  
  1583.  
  1584.  
  1585.                             if(flood)
  1586.  
  1587.                             {
  1588.  
  1589.                                 if((currentTickCount - lastTickCount) >= 60.0f)
  1590.  
  1591.                                 {
  1592.  
  1593.                                     flood = false;
  1594.  
  1595.  
  1596.  
  1597.                                     count = 0;
  1598.  
  1599.  
  1600.  
  1601.                                     memset(lastQuestion2, 0, 1024 * 64);
  1602.  
  1603.  
  1604.  
  1605.                                     if(!silent)
  1606.  
  1607.                                     {
  1608.  
  1609.                                         srand((unsigned int)time(0));
  1610.  
  1611.  
  1612.  
  1613.                                         irc->Send("PRIVMSG #%s :%s\r\n", currentChannel, happy[rand() % 5]);
  1614.  
  1615.                                        
  1616.  
  1617.                                     }
  1618.  
  1619.                                 }
  1620.  
  1621.                             }
  1622.  
  1623.  
  1624.  
  1625.                             if(found && !silent && !flood)
  1626.  
  1627.                             {
  1628.  
  1629.                                 bool go = false;
  1630.  
  1631.  
  1632.  
  1633.                                 if((stristr(question, nick) == question) && (question[0] != '@') && direct)
  1634.  
  1635.                                 {
  1636.  
  1637.                                     if(_stricmp(lastQuestion2, row[2]) != 0)
  1638.  
  1639.                                         go = true;
  1640.  
  1641.                                 }
  1642.  
  1643.                                 else if((stristr(question, nick) == (question + 1)) && (question[0] == '@') && direct)
  1644.  
  1645.                                 {
  1646.  
  1647.                                     if(_stricmp(lastQuestion2, row[2]) != 0)
  1648.  
  1649.                                         go = true;
  1650.  
  1651.                                 }
  1652.  
  1653.                                 else if((stristr(question, nick) == (question + 1)) && (question[0] == '@') && !direct)
  1654.  
  1655.                                 {
  1656.  
  1657.                                     if(_stricmp(lastQuestion2, row[2]) != 0)
  1658.  
  1659.                                         go = true;
  1660.  
  1661.                                 }
  1662.  
  1663.                                 else if((stristr(question, nick) == question) && (question[0] != '@') && !direct)
  1664.  
  1665.                                 {
  1666.  
  1667.                                     if(_stricmp(lastQuestion2, row[2]) != 0)
  1668.  
  1669.                                         go = true;
  1670.  
  1671.                                 }
  1672.  
  1673.                                 else if((stristr(question, nick) != question) && !direct)
  1674.  
  1675.                                 {
  1676.  
  1677.                                     if(_stricmp(lastQuestion2, row[2]) != 0)
  1678.  
  1679.                                         go = true;
  1680.  
  1681.                                 }
  1682.  
  1683.  
  1684.  
  1685.                                 if(go)
  1686.  
  1687.                                 {
  1688.  
  1689.                                     count = 0;
  1690.  
  1691.  
  1692.  
  1693.                                     memset(lastQuestion2, 0, 1024 * 64);
  1694.  
  1695.  
  1696.  
  1697.                                     _snprintf(lastQuestion2, (1024 * 64) - 1, row[2]);
  1698.  
  1699.                                 }
  1700.  
  1701.  
  1702.  
  1703.                                 if((count < 2) && ((direct && stristr(question, nick)) || !direct))
  1704.  
  1705.                                     irc->Send("PRIVMSG #%s :%s\r\n", currentChannel, row[2]);
  1706.  
  1707.  
  1708.  
  1709.                                 if(!_stricmp(lastQuestion2, row[2]))
  1710.  
  1711.                                 {
  1712.  
  1713.                                     count++;
  1714.  
  1715.  
  1716.  
  1717.                                     memset(lastQuestion2, 0, 1024 * 64);
  1718.  
  1719.  
  1720.  
  1721.                                     _snprintf(lastQuestion2, (1024 * 64) - 1, row[2]);
  1722.  
  1723.  
  1724.  
  1725.                                     if(count >= 3)
  1726.  
  1727.                                     {
  1728.  
  1729.                                         flood = true;
  1730.  
  1731.  
  1732.  
  1733.                                         lastTickCount = currentTickCount;
  1734.  
  1735.  
  1736.  
  1737.                                         srand((unsigned int)time(0));
  1738.  
  1739.  
  1740.  
  1741.                                         irc->Send("PRIVMSG #%s :%s, %s\r\n", currentChannel, nickname, responses[rand() % 5]);
  1742.  
  1743.                                     }
  1744.  
  1745.                                 }
  1746.  
  1747.                             }
  1748.  
  1749.                             else if(!waitForAnswer && !found && !answer && !waitForNick)
  1750.  
  1751.                             {
  1752.  
  1753.                                 waitForAnswer = true;
  1754.  
  1755.                                 waitForNick = true;
  1756.  
  1757.  
  1758.  
  1759.                                 char *buf = new char[1024 * 64];
  1760.  
  1761.  
  1762.  
  1763.                                 memset(buf, 0, 1024 * 64);
  1764.  
  1765.  
  1766.  
  1767.                                 _snprintf(buf, (1024 * 64) - 1, "INSERT INTO data (question) VALUES ('%s');", questionx);
  1768.  
  1769.  
  1770.  
  1771.                                 memset(lastQuestion, 0, 1024 * 64);
  1772.  
  1773.  
  1774.  
  1775.                                 _snprintf(lastQuestion, (1024 * 64) - 1, questionx);
  1776.  
  1777.  
  1778.  
  1779.                                 mysql_query(mysql, buf);
  1780.  
  1781.  
  1782.  
  1783.                                 delete buf;
  1784.  
  1785.  
  1786.  
  1787.                                 answer = true;
  1788.  
  1789.  
  1790.  
  1791.                                 memset(lastNick, 0, 1024);
  1792.  
  1793.  
  1794.  
  1795.                                 _snprintf(lastNick, 1023, nickname);
  1796.  
  1797.  
  1798.  
  1799.                                 memset(lastChannel, 0, 1024);
  1800.  
  1801.  
  1802.  
  1803.                                 _snprintf(lastChannel, 1023, currentChannel);
  1804.  
  1805.  
  1806.  
  1807.                                 if(stristr(question, nick) && !silent)
  1808.  
  1809.                                     directed = true;
  1810.  
  1811.                             }
  1812.  
  1813.  
  1814.  
  1815.                             mysql_free_result(result);
  1816.  
  1817.                         }
  1818.  
  1819.  
  1820.  
  1821.                         delete currentChannel;
  1822.  
  1823.                         delete host;
  1824.  
  1825.                         delete nickname;
  1826.  
  1827.                         delete question;
  1828.  
  1829.                         delete username;
  1830.  
  1831.  
  1832.  
  1833.                         if(!waitForAnswer)
  1834.  
  1835.                         {
  1836.  
  1837.                             answer = false;
  1838.  
  1839.  
  1840.  
  1841.                             waitForNick = false;
  1842.  
  1843.                         }
  1844.  
  1845.                     }
  1846.  
  1847.  
  1848.  
  1849.                     memset(received, 0, (1024 * 64) - 1);
  1850.  
  1851.                 }
  1852.  
  1853.  
  1854.  
  1855.                 mysql_close(mysql);
  1856.  
  1857.             }
  1858.  
  1859.             else
  1860.  
  1861.                 cout << "Error #" << mysql_errno(mysql) << ": " << mysql_error(mysql) << "\n";
  1862.  
  1863.         }
  1864.  
  1865.         else
  1866.  
  1867.             cout << "Error #" << mysql_errno(mysql) << ": " << mysql_error(mysql) << "\n";
  1868.  
  1869.  
  1870.  
  1871.         delete buf353;
  1872.  
  1873.         delete channel;
  1874.  
  1875.         delete contents;
  1876.  
  1877.         delete email;
  1878.  
  1879.         delete lastChannel;
  1880.  
  1881.         delete lastNick;
  1882.  
  1883.         delete lastQuestion;
  1884.  
  1885.         delete lastQuestion2;
  1886.  
  1887.         delete master;
  1888.  
  1889.         delete mysqlDatabase;
  1890.  
  1891.         delete mysqlPassword;
  1892.  
  1893.         delete mysqlPort;
  1894.  
  1895.         delete mysqlServer;
  1896.  
  1897.         delete mysqlUser;
  1898.  
  1899.         delete nick;
  1900.  
  1901.         delete password;
  1902.  
  1903.         delete port;
  1904.  
  1905.         delete received;
  1906.  
  1907.         delete server;
  1908.  
  1909.         delete user;
  1910.  
  1911.  
  1912.  
  1913.         for(int i = 0; i < 1023; i++)
  1914.  
  1915.             delete users[i];
  1916.  
  1917.  
  1918.  
  1919.         for(int i = 0; i < 5; i++)
  1920.  
  1921.         {
  1922.  
  1923.             delete happy[i];
  1924.  
  1925.             delete responses[i];
  1926.  
  1927.         }
  1928.  
  1929.     }
  1930.  
  1931.     else
  1932.  
  1933.         cout << "Error: could not load 'bot.ini'\n";
  1934.  
  1935.  
  1936.  
  1937.     irc->~SICL();
  1938.  
  1939.  
  1940.  
  1941.     misc->~SRFL();
  1942.  
  1943.  
  1944.  
  1945.     delete irc;
  1946.  
  1947.     delete misc;
  1948.  
  1949.  
  1950.  
  1951.     Sleep(10000);
  1952.  
  1953.  
  1954.  
  1955.     return 0;
  1956.  
  1957. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement