diff options
-rw-r--r-- | include/bots.h | 9 | ||||
-rw-r--r-- | src/bots.cpp | 16 | ||||
-rw-r--r-- | src/init.c | 82 |
3 files changed, 53 insertions, 54 deletions
diff --git a/include/bots.h b/include/bots.h index 6573903be..e73b325ed 100644 --- a/include/bots.h +++ b/include/bots.h @@ -20,6 +20,7 @@ class BotInfo public: BotInfo *next, *prev; + std::string uid; /* required for UID supporting servers, as opposed to the shitty struct Uid. */ char *nick; /* Nickname of the bot */ char *user; /* Its user name */ char *host; /* Its hostname */ @@ -31,9 +32,17 @@ class BotInfo time_t lastmsg; /* Last time we said something */ /** Create a new bot. + * XXX: Note - this constructor is considered obsolete. Use the four parameter form. * @param nick The nickname to assign to the bot. */ BotInfo(const char *nick); + /** Create a new bot. + * @param nick The nickname to assign to the bot. + * @param user The ident to give the bot. + * @param host The hostname to give the bot. + * @param real The realname to give the bot. + */ + BotInfo(const char *nick, const char *user, const char *host, const char *real); /** Change the nickname set on a bot. * @param newnick The nick to change to diff --git a/src/bots.cpp b/src/bots.cpp index 2cd4a10fd..f58858d48 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -15,10 +15,26 @@ BotInfo::BotInfo(const char *nnick) { this->nick = sstrdup(nnick); this->lastmsg = time(NULL); + this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? + new_uid(nnick, (char *)this->uid.c_str()); // XXX: this is required because we still pass nick prefix to protocol modules, DO AWAY WITH IT. insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. nbots++; } +BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const char *nreal) +{ + this->nick = sstrdup(nnick); + this->user = sstrdup(nuser); + this->host = sstrdup(nhost); + this->real = sstrdup(nreal); + this->lastmsg = time(NULL); + this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? + new_uid(nnick, (char *)this->uid.c_str()); // XXX: this is required because we still pass nick prefix to protocol modules, DO AWAY WITH IT. + insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. + nbots++; +} + + void BotInfo::ChangeNick(const char *newnick) { if (this->next) diff --git a/src/init.c b/src/init.c index 973acb13f..da46d296b 100644 --- a/src/init.c +++ b/src/init.c @@ -33,48 +33,6 @@ void introduce_user(const char *user) lasttimes[LTSIZE - 1] = time(NULL); #undef LTSIZE - /* Introduce OperServ first because on some IRCd's send - * we send data from OperServ before introduction completes. - * Patch fixing ratbox RESV support provided by Jobe. */ - if (!user || stricmp(user, s_OperServ) == 0) { - anope_cmd_nick(s_OperServ, desc_OperServ, ircd->operservmode); - } - - /* NickServ */ - if (!user || stricmp(user, s_NickServ) == 0) { - anope_cmd_nick(s_NickServ, desc_NickServ, ircd->nickservmode); - } - - /* ChanServ */ - if (!user || stricmp(user, s_ChanServ) == 0) { - anope_cmd_nick(s_ChanServ, desc_ChanServ, ircd->chanservmode); - } - if (s_HostServ && ircd->vhost - && (!user || stricmp(user, s_HostServ) == 0)) { - anope_cmd_nick(s_HostServ, desc_HostServ, ircd->hostservmode); - } - - if (!user || stricmp(user, s_MemoServ) == 0) { - anope_cmd_nick(s_MemoServ, desc_MemoServ, ircd->memoservmode); - } - - if (s_BotServ && (!user || stricmp(user, s_BotServ) == 0)) { - anope_cmd_nick(s_BotServ, desc_BotServ, ircd->botservmode); - } - - if (!user || stricmp(user, s_HelpServ) == 0) { - anope_cmd_nick(s_HelpServ, desc_HelpServ, ircd->helpservmode); - } - - if (s_DevNull && (!user || stricmp(user, s_DevNull) == 0)) { - anope_cmd_nick(s_DevNull, desc_DevNull, ircd->devnullmode); - } - - if (!user || stricmp(user, s_GlobalNoticer) == 0) { - anope_cmd_nick(s_GlobalNoticer, desc_GlobalNoticer, - ircd->globalmode); - } - /* We make aliases go online */ if (s_NickServAlias && (!user || stricmp(user, s_NickServAlias) == 0)) { anope_cmd_nick(s_NickServAlias, desc_NickServAlias, @@ -122,18 +80,18 @@ void introduce_user(const char *user) } /* We make the bots go online */ - if (s_BotServ) { - BotInfo *bi; - int i; - - for (i = 0; i < 256; i++) - for (bi = botlists[i]; bi; bi = bi->next) { - - if (!user || !stricmp(user, bi->nick)) - anope_cmd_bot_nick(bi->nick, bi->user, bi->host, - bi->real, ircd->botserv_bot_mode); - } - } + BotInfo *bi; + int i; + + /* XXX: it might be nice to have this inside BotInfo's constructor, or something? */ + for (i = 0; i < 256; i++) + { + for (bi = botlists[i]; bi; bi = bi->next) + { + if (!user || !stricmp(user, bi->nick)) + anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real, ircd->botserv_bot_mode); + } + } } /*************************************************************************/ @@ -692,6 +650,22 @@ int init_secondary(int ac, char **av) #endif alog("Databases loaded"); + + /* this is only used on the first run of Anope. */ + BotInfo *bi = findbot("NickServ"); + if (!bi) + { + bi = new BotInfo(s_OperServ, ServiceUser, ServiceHost, desc_OperServ); + bi = new BotInfo(s_NickServ, ServiceUser, ServiceHost, desc_NickServ); + bi = new BotInfo(s_ChanServ, ServiceUser, ServiceHost, desc_ChanServ); + bi = new BotInfo(s_HostServ, ServiceUser, ServiceHost, desc_HostServ); + bi = new BotInfo(s_MemoServ, ServiceUser, ServiceHost, desc_MemoServ); + bi = new BotInfo(s_BotServ, ServiceUser, ServiceHost, desc_BotServ); + bi = new BotInfo(s_HelpServ, ServiceUser, ServiceHost, desc_HelpServ); + bi = new BotInfo(s_DevNull, ServiceUser, ServiceHost, desc_DevNull); + bi = new BotInfo(s_GlobalNoticer, ServiceUser, ServiceHost, desc_GlobalNoticer); + } + /* Save the databases back to file/mysql to reflect any changes */ #ifdef USE_RDB if (!UseRDB) { /* Only save if we are not using remote databases |