@defun bot:getserverlist
@end defun
+@c (0, 0, 0)
+@defun bot:getversion
+Return the long bot version string (same as returned by a CTCP VERSION
+request, e.g. ``bobotpp version 2.3.1.1-8cd2-dirty by
+unknown_lamer@@FreeNode <clinton@@unknownlamer.org>\n1.97 and below by
+eb@@IRCNet <eb@@via.ecp.fr>'').
+@end defun
+
+@c (0, 0, 0)
+@defun bot:getreleasrevision
+Return the bot version only (e.g. ``2.3.1.1-8cd2'').
+@end defun
+
@c (0, 0, 0)
@defun bot:flush
[ Flushes the socket to the server? ]
unsigned int Bot::MAX_MESSAGES = 2;
unsigned int Bot::MAX_NICKLENGTH = 9;
+const std::string Bot::release_revision = VERSION;
+
#define DEFAULT_NICKNAME "Bobot"
#define DEFAULT_USERNAME "bobot"
#define DEFAULT_IRCNAME "I'm a bobot++!"
receivedUserhostID(0),
logFileName(DEFAULT_LOGFILENAME),
logs_dir (DEFAULT_LOGDIR),
- configFileName (filename)
+ configFileName (filename),
+ version_mutex(true)
#ifdef USESCRIPTS
,scriptLogFileName(DEFAULT_SCRIPTLOGFILENAME),
autoexecFileName(DEFAULT_AUTOEXECFILENAME)
closedir (temp);
}
}
+
+void
+Bot::set_version (String new_version)
+{
+ BotLock setter_lock (version_mutex);
+
+ versionString = new_version;
+}
+
+String
+Bot::get_version () const
+{
+ BotLock getter_lock (version_mutex);
+
+ return versionString;
+}
#include <string>
#include <map>
+#include "BotThreading.H"
#include "String.H"
#define VERSION_STRING PACKAGE " version " VERSION " by unknown_lamer@FreeNode <clinton@unknownlamer.org>\n1.97 and below by eb@IRCNet <eb@via.ecp.fr>"
String wantedNickName;
String userName;
String ircName;
- String versionString;
String userHost;
String localIP;
char commandChar;
static const std::time_t PING_TIME = 90;
static const std::time_t TIMEOUT = 120;
+ static const std::string release_revision;
+
private:
String logFileName;
String logs_dir;
String configFileName;
+ String versionString;
+
+ // mutexes (one per settable variable, although a global lock on bot
+ // state might not be unreasonable since setting is so rare)
+ mutable BotMutex version_mutex;
+
#ifdef USESCRIPTS
String scriptLogFileName;
String autoexecFileName;
void set_log_dir (String);
void set_log_file (String);
+ String get_version () const;
+ void set_version (String);
+
friend class Parser;
friend class DCCParser;
friend class Person;
if (str.length() == 0)
return InvalidParameters;
- bot->versionString = str;
+ bot->set_version (str);
return Ok;
}
bot_new_procedure ("bot:getnickname", (SCMFunc)ScriptCommands::getNickname,
0, 0, 0);
+ bot_new_procedure ("bot:getreleaserevision",
+ (SCMFunc)ScriptCommands::getReleaseRevision, 0, 0, 0);
bot_new_procedure ("bot:getserver", (SCMFunc)ScriptCommands::getServer,
0, 0, 0);
- bot_new_procedure ("bot:getserverlist",
+ bot_new_procedure ("bot:getserverlist",
(SCMFunc)ScriptCommands::getServerList, 0, 0, 0);
+ bot_new_procedure ("bot:getversion",
+ (SCMFunc)ScriptCommands::getVersion, 0, 0, 0);
bot_new_procedure ("bot:flush", (SCMFunc)ScriptCommands::flushQueue,
0, 0, 0);
bot_new_procedure ("bot:flushport", (SCMFunc)ScriptCommands::flushPort,
else if (command == "VERSION")
{
Commands::CTCPReply (cnx->bot, nick, "VERSION",
- cnx->bot->versionString);
+ cnx->bot->get_version ());
}
else if (command == "CLOCK")
{
return res;
}
+SCM ScriptCommands::getVersion(void)
+{
+ return Utils::str2scm (Interp::bot->get_version ());
+}
+
+SCM ScriptCommands::getReleaseRevision(void)
+{
+ return Utils::str2scm (Interp::bot->release_revision);
+}
+
SCM
ScriptCommands::flushQueue(void)
{
static SCM Whois(SCM);
static SCM getNickname(void);
+ static SCM getReleaseRevision(void);
static SCM getServer(void);
static SCM getServerList(void);
+ static SCM getVersion(void);
static SCM flushQueue(void);
static SCM flushPort(void);
static SCM random(SCM);