From 6c56c238372bf7dbed58fe3dc3ea56d76e6f736b Mon Sep 17 00:00:00 2001 From: Adam- Date: Thu, 13 May 2010 06:27:16 +0000 Subject: [PATCH] Update core bot client names if the config is changed git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2953 5417fbe8-f217-4b02-8779-1006273d7864 --- src/init.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/init.c b/src/init.c index dfbdfbd80..d71366968 100644 --- a/src/init.c +++ b/src/init.c @@ -340,7 +340,6 @@ int init_primary(int ac, char **av) int init_secondary(int ac, char **av) { #ifndef _WIN32 - int i; int started_from_term = isatty(0) && isatty(1) && isatty(2); #endif @@ -348,7 +347,9 @@ int init_secondary(int ac, char **av) moduleAddMsgs(); #ifndef _WIN32 - if (!nofork) { + if (!nofork) + { + int i; if ((i = fork()) < 0) { perror("fork()"); return -1; @@ -487,6 +488,30 @@ int init_secondary(int ac, char **av) if (Config.s_GlobalNoticer) new BotInfo(Config.s_GlobalNoticer, Config.ServiceUser, Config.ServiceHost, Config.desc_GlobalNoticer); } + else + { + /* If a botname was changed in the config, reflect it */ + for (int i = 0; i < 256; ++i) + { + for (BotInfo *bi = botlists[i]; bi; bi = bi->next) + { + if (bi->HasFlag(BI_OPERSERV) && bi->nick != Config.s_OperServ) + bi->ChangeNick(Config.s_OperServ); + else if (bi->HasFlag(BI_NICKSERV) && bi->nick != Config.s_NickServ) + bi->ChangeNick(Config.s_NickServ); + else if (bi->HasFlag(BI_CHANSERV) && bi->nick != Config.s_ChanServ) + bi->ChangeNick(Config.s_ChanServ); + else if (bi->HasFlag(BI_HOSTSERV) && bi->nick != Config.s_HostServ) + bi->ChangeNick(Config.s_HostServ); + else if (bi->HasFlag(BI_MEMOSERV) && bi->nick != Config.s_MemoServ) + bi->ChangeNick(Config.s_MemoServ); + else if (bi->HasFlag(BI_BOTSERV) && bi->nick != Config.s_BotServ) + bi->ChangeNick(Config.s_BotServ); + else if (bi->HasFlag(BI_GLOBAL) && bi->nick != Config.s_GlobalNoticer) + bi->ChangeNick(Config.s_GlobalNoticer); + } + } + } FOREACH_MOD(I_OnPostLoadDatabases, OnPostLoadDatabases());