// Let's read the alias file
std::ifstream initFile(initFileName);
- if (initFile) {
- String temp, alias, command;
- int line = 0;
- while (initFile >> temp, temp.length() != 0) {
- line++;
- StringTokenizer st(temp);
- temp = Utils::trim_str (temp);
- if (temp[(unsigned int)0]=='#') continue;
- if (st.count_tokens (' ') != 2) {
- std::cerr << "Error when reading alias file (" << initFileName
- << ") line " << line << "...\n";
- continue;
- }
- alias = Utils::to_upper (st.next_token());
- command = Utils::to_upper (st.next_token());
-
- // Does the function already exist ?
- if (!userFunctions[alias])
+ if (initFile)
+ {
+ // FIXME: these variables are current String instead of
+ // std::string because String>> reads an entire line. This code
+ // needs to be rewritten to use std::string and std::getline (or
+ // better yet, be removed entirely once BotConfig is in place)
+ String temp, alias, command;
+ int line = 0;
+
+ while (initFile >> temp, temp.length() != 0)
{
- if (userFunction *u = userFunctions[command])
- userFunctions[alias] =
- new
- userFunction(u->function,
- u->minLevel,
- u->needsChannelName);
+ StringTokenizer st(temp);
+
+ line++;
+ temp = Utils::trim_str (temp);
+
+ if (temp[0]=='#')
+ {
+ continue;
+ }
+
+ if (st.count_tokens (' ') != 2)
+ {
+ std::cerr << "Error when reading alias file (" << initFileName
+ << ") line " << line << "...\n";
+ continue;
+ }
+
+ alias = Utils::to_upper (st.next_token());
+ command = Utils::to_upper (st.next_token());
+
+ // Does the function already exist ?
+ if (!userFunctions[alias])
+ {
+ if (userFunction *u = userFunctions[command])
+ userFunctions[alias] =
+ new
+ userFunction(u->function,
+ u->minLevel,
+ u->needsChannelName);
+ }
}
}
- }
std::srand (std::time (0)); // srand for bot-random
+
#ifdef USESCRIPTS
botInterp = new BotInterp(this, logs_dir + scriptLogFileName);
botInterp->LoadScript(autoexecFileName);
{
char s[6];
std::sprintf(s, "%2d:%2d", thisTime->tm_hour, thisTime->tm_min);
- // FIXME: uses gh_list
+
botInterp->RunHooks(Hook::TIMER, String(s),
- gh_list(Utils::str2scm (std::string (s)),
- SCM_UNDEFINED));
+ scm_list_n (Utils::str2scm (std::string (s)),
+ SCM_UNDEFINED));
}
#endif
serverConnection->queue->sendJoin((*it).first, (*it).second->key);
}
- if (currentTime >= (std::time_t)(serverConnection->serverLastSpoken + Bot::PING_TIME) && !sentPing) {
- serverConnection->queue->sendPing("Testing connection");
- sentPing = true;
- }
+ if (currentTime >= (std::time_t)(serverConnection->serverLastSpoken
+ + Bot::PING_TIME) && !sentPing)
+ {
+ serverConnection->queue->sendPing("Testing connection");
+ sentPing = true;
+ }
- if (currentTime >= (std::time_t)(serverConnection->serverLastSpoken + Bot::TIMEOUT)) {
- sentPing = false;
- nextServer();
- }
+ if (currentTime >= (std::time_t)(serverConnection->serverLastSpoken
+ + Bot::TIMEOUT))
+ {
+ sentPing = false;
+ nextServer();
+ }
}
// We can change server if we will not lose op on a channel
DCCConnection *d = 0;
if (type == CHAT)
- d = new DCCChatConnection(this, from->getAddress (),
- address, port);
+ {
+ d = new DCCChatConnection(this, from->getAddress (),
+ address, port);
+ }
else
- return;
+ {
+ return;
+ }
if (!d->connect())
{
logLine ("DCC Connection failed from " + from->getAddress ());
return;
}
+
logLine ("DCC CHAT accepted from" + from->getAddress ());
dccConnections->addConnection (d);
}