diff options
author | Adam <Adam@anope.org> | 2011-08-13 21:52:21 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-09-10 01:52:46 -0400 |
commit | 8a6d6577bd6c9d5ca57c98d932a99ae890ba7cc8 (patch) | |
tree | c3d63ae7797a4c8d08cd7b75ef69a48720a9605d | |
parent | 4a7ba7ef4cd92263d8187b1385d8bf46102ef7b3 (diff) |
Removed log:inhabitlogchannel and replaced it with service:channels
-rw-r--r-- | data/botserv.example.conf | 7 | ||||
-rw-r--r-- | data/chanserv.example.conf | 7 | ||||
-rw-r--r-- | data/example.conf | 14 | ||||
-rw-r--r-- | data/global.example.conf | 7 | ||||
-rw-r--r-- | data/hostserv.example.conf | 7 | ||||
-rw-r--r-- | data/memoserv.example.conf | 7 | ||||
-rw-r--r-- | data/nickserv.example.conf | 7 | ||||
-rw-r--r-- | data/operserv.example.conf | 7 | ||||
-rw-r--r-- | include/bots.h | 1 | ||||
-rw-r--r-- | include/channels.h | 4 | ||||
-rw-r--r-- | include/logger.h | 3 | ||||
-rw-r--r-- | src/bots.cpp | 32 | ||||
-rw-r--r-- | src/channels.cpp | 2 | ||||
-rw-r--r-- | src/config.cpp | 153 | ||||
-rw-r--r-- | src/logger.cpp | 2 | ||||
-rw-r--r-- | src/servers.cpp | 18 |
16 files changed, 153 insertions, 125 deletions
diff --git a/data/botserv.example.conf b/data/botserv.example.conf index e52a88943..c896aff0b 100644 --- a/data/botserv.example.conf +++ b/data/botserv.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf index a108e2177..418f3ae86 100644 --- a/data/chanserv.example.conf +++ b/data/chanserv.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/data/example.conf b/data/example.conf index 4129b94db..72d06c3d5 100644 --- a/data/example.conf +++ b/data/example.conf @@ -617,7 +617,13 @@ log * - globops */ target = "services.log" - /* Log to both services.log and the channel #services */ + + /* Log to both services.log and the channel #services + * + * Note that some older IRCds, such as Ratbox, require services to be in the + * log channel to be able to message it. To do this, configure service:channels to + * join your logging channel. + */ #target = "services.log #services" /* @@ -635,12 +641,6 @@ log logage = 7 /* - * Enable to have the core services clients join and stay in the log channel(s) when logging. - * Note: on some IRCds this is not optional, and is enforced on. - */ - inhabitlogchannel = yes - - /* * What types of log messages should be logged by this block. There are nine general categories: * * admin - Execution of admin commands (OperServ, etc). diff --git a/data/global.example.conf b/data/global.example.conf index 41f1c9463..fb10dd47c 100644 --- a/data/global.example.conf +++ b/data/global.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/data/hostserv.example.conf b/data/hostserv.example.conf index 45693f011..2edc68e1c 100644 --- a/data/hostserv.example.conf +++ b/data/hostserv.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/data/memoserv.example.conf b/data/memoserv.example.conf index 181ee66d1..a0b16271a 100644 --- a/data/memoserv.example.conf +++ b/data/memoserv.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index c7dbaa68f..dfa3bf542 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/data/operserv.example.conf b/data/operserv.example.conf index bd922e92e..ad239dd3e 100644 --- a/data/operserv.example.conf +++ b/data/operserv.example.conf @@ -39,6 +39,13 @@ service * unable to do certain things if this option is enabled. */ #modes = "+o" + + /* + * An optional comma separated list of channels this service should join. Outside + * of log channels this is not very useful, as the service will just idle in the + * specified channels, and will not accept any types of commands. + */ + #channels = "@#services,#mychan" } /* diff --git a/include/bots.h b/include/bots.h index f5b4c528a..20daeddcf 100644 --- a/include/bots.h +++ b/include/bots.h @@ -41,6 +41,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END> typedef Anope::insensitive_map<CommandInfo> command_map; command_map commands; /* Commands, actual name to service name */ Anope::string botmodes; /* Modes the bot should have as configured in service:modes */ + std::vector<Anope::string> botchannels; /* Channels the bot should be in as configured in service:channels */ bool introduced; /* Whether or not this bot is introduced */ /** Create a new bot. diff --git a/include/channels.h b/include/channels.h index 113b5c1f9..5b8801406 100644 --- a/include/channels.h +++ b/include/channels.h @@ -30,9 +30,7 @@ enum ChannelFlag /* Channel still exists when emptied */ CH_PERSIST, /* If set the channel is syncing users (channel was just created) and it should not be deleted */ - CH_SYNCING, - /* Is a services log channel */ - CH_LOGCHAN + CH_SYNCING }; const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "CH_LOGCHAN", "" }; diff --git a/include/logger.h b/include/logger.h index d012c4450..423e096d3 100644 --- a/include/logger.h +++ b/include/logger.h @@ -73,7 +73,6 @@ class CoreExport LogInfo std::map<Anope::string, LogFile *> Logfiles; std::list<Anope::string> Sources; int LogAge; - bool Inhabit; std::list<Anope::string> Admin; std::list<Anope::string> Override; std::list<Anope::string> Commands; @@ -84,7 +83,7 @@ class CoreExport LogInfo bool RawIO; bool Debug; - LogInfo(int logage, bool inhabit, bool rawio, bool debug); + LogInfo(int logage, bool rawio, bool debug); ~LogInfo(); diff --git a/src/bots.cpp b/src/bots.cpp index b794610e6..379836ec2 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -38,32 +38,6 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A XLine x(this->nick, "Reserved for services"); ircdproto->SendSQLine(NULL, &x); } - - if (Config) - for (unsigned i = 0; i < Config->LogInfos.size(); ++i) - { - LogInfo *l = Config->LogInfos[i]; - - if (ircd && !ircd->join2msg && !l->Inhabit) - continue; - - for (std::list<Anope::string>::const_iterator sit = l->Targets.begin(), sit_end = l->Targets.end(); sit != sit_end; ++sit) - { - const Anope::string &target = *sit; - - if (target[0] == '#') - { - Channel *c = findchan(target); - if (!c) - c = new Channel(target); - c->SetFlag(CH_LOGCHAN); - c->SetFlag(CH_PERSIST); - - if (!c->FindUser(this)) - this->Join(c, &Config->BotModeList); - } - } - } } BotInfo::~BotInfo() @@ -160,6 +134,9 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci) void BotInfo::Join(Channel *c, ChannelStatus *status) { + if (c->FindUser(this) != NULL) + return; + if (Config && ircdproto && Config->BSSmartJoin) { std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = c->GetModeList(CMODE_BAN); @@ -199,6 +176,9 @@ void BotInfo::Join(const Anope::string &chname, ChannelStatus *status) void BotInfo::Part(Channel *c, const Anope::string &reason) { + if (c->FindUser(this) == NULL) + return; + ircdproto->SendPart(this, c, "%s", !reason.empty() ? reason.c_str() : ""); c->DeleteUser(this); } diff --git a/src/channels.cpp b/src/channels.cpp index 0cd5481eb..52b0b86c5 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -401,7 +401,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo if (EnforceMLock) { /* Reset modes on bots if we're supposed to */ - if (bi) + if (this->ci && this->ci->bi && this->ci->bi == bi) { if (Config->BotModeList.HasFlag(cm->Name)) this->SetMode(bi, cm, bi->nick); diff --git a/src/config.cpp b/src/config.cpp index 4a1f02f64..6f2557510 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -778,40 +778,7 @@ static bool DoneModules(ServerConfig *config, const Anope::string &) bool InitLogs(ServerConfig *config, const Anope::string &) { - for (unsigned i = 0; i < config->LogInfos.size(); ++i) - { - LogInfo *l = config->LogInfos[i]; - - for (std::list<Anope::string>::const_iterator sit = l->Targets.begin(), sit_end = l->Targets.end(); sit != sit_end; ++sit) - { - const Anope::string &target = *sit; - - if (target[0] == '#') - { - Channel *c = findchan(target); - if (c && c->HasFlag(CH_LOGCHAN)) - { - for (CUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) - { - UserContainer *uc = *cit; - BotInfo *bi = findbot(uc->user->nick); - - if (bi) - bi->Part(c, "Reloading configuration"); - } - - c->UnsetFlag(CH_PERSIST); - c->UnsetFlag(CH_LOGCHAN); - if (c->users.empty()) - delete c; - } - } - } - - delete config->LogInfos[i]; - } config->LogInfos.clear(); - return true; } @@ -825,18 +792,17 @@ static bool DoLogs(ServerConfig *config, const Anope::string &, const Anope::str Anope::string source = values[1].GetValue(); int logage = values[2].GetInteger(); - bool inhabit = values[3].GetBool(); - Anope::string admin = values[4].GetValue(); - Anope::string override = values[5].GetValue(); - Anope::string commands = values[6].GetValue(); - Anope::string servers = values[7].GetValue(); - Anope::string channels = values[8].GetValue(); - Anope::string users = values[9].GetValue(); - Anope::string normal = values[10].GetValue(); - bool rawio = values[11].GetBool(); - bool ldebug = values[12].GetBool(); - - LogInfo *l = new LogInfo(logage, inhabit, rawio, ldebug); + Anope::string admin = values[3].GetValue(); + Anope::string override = values[4].GetValue(); + Anope::string commands = values[5].GetValue(); + Anope::string servers = values[6].GetValue(); + Anope::string channels = values[7].GetValue(); + Anope::string users = values[8].GetValue(); + Anope::string normal = values[9].GetValue(); + bool rawio = values[10].GetBool(); + bool ldebug = values[11].GetBool(); + + LogInfo *l = new LogInfo(logage, rawio, ldebug); l->Targets = BuildStringList(targets); l->Sources = BuildStringList(source); l->Admin = BuildStringList(admin); @@ -855,36 +821,6 @@ static bool DoLogs(ServerConfig *config, const Anope::string &, const Anope::str static bool DoneLogs(ServerConfig *config, const Anope::string &) { Log() << "Loaded " << config->LogInfos.size() << " log blocks"; - - for (unsigned i = 0; i < config->LogInfos.size(); ++i) - { - LogInfo *l = config->LogInfos[i]; - - if ((!ircd || !ircd->join2msg) && !l->Inhabit) - continue; - - for (std::list<Anope::string>::const_iterator sit = l->Targets.begin(), sit_end = l->Targets.end(); sit != sit_end; ++sit) - { - const Anope::string &target = *sit; - - if (target[0] == '#') - { - Channel *c = findchan(target); - if (!c) - c = new Channel(target); - c->SetFlag(CH_LOGCHAN); - c->SetFlag(CH_PERSIST); - - for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) - { - BotInfo *bi = it->second; - if (!c->FindUser(bi)) - bi->Join(c, NULL); - } - } - } - } - return true; } @@ -948,6 +884,7 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope: Anope::string host = values[2].GetValue(); Anope::string gecos = values[3].GetValue(); Anope::string modes = values[4].GetValue(); + Anope::string channels = values[5].GetValue(); ValueItem vi(nick); if (!ValidateNotEmpty(config, "service", "nick", vi)) @@ -967,10 +904,58 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope: services.insert(nick); BotInfo *bi = findbot(nick); - if (bi != NULL) - return true; - bi = new BotInfo(nick, user, host, gecos, modes); + if (bi == NULL) + bi = new BotInfo(nick, user, host, gecos, modes); bi->SetFlag(BI_CONF); + + Anope::string token; + commasepstream sep(channels); + std::vector<Anope::string> oldchannels = bi->botchannels; + bi->botchannels.clear(); + while (sep.GetToken(token)) + { + bi->botchannels.push_back(token); + size_t ch = token.find('#'); + Anope::string chname, want_modes; + if (ch == Anope::string::npos) + chname = token; + else + { + want_modes = token.substr(0, ch); + chname = token.substr(ch); + } + bi->Join(chname); + Channel *c = findchan(chname); + if (!c) + continue; // Can't happen + + /* Remove all existing modes */ + for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) + { + ChannelMode *cm = ModeManager::ChannelModes[i]; + if (cm && cm->Type == MODE_STATUS) + c->RemoveMode(bi, cm, bi->nick); + } + /* Set the new modes */ + for (unsigned j = 0; j < want_modes.length(); ++j) + { + ChannelMode *cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_modes[j])); + if (cm && cm->Type == MODE_STATUS) + c->SetMode(bi, cm, bi->nick); + } + } + for (unsigned i = 0; i < oldchannels.size(); ++i) + { + size_t ch = oldchannels[i].find('#'); + Anope::string chname = oldchannels[i].substr(ch != Anope::string::npos ? ch : 0); + if (std::find(bi->botchannels.begin(), bi->botchannels.end(), chname) == bi->botchannels.end()) + { + Channel *c = findchan(chname); + if (c) + bi->Part(c); + } + } + return true; } @@ -1267,14 +1252,14 @@ ConfigItems::ConfigItems(ServerConfig *conf) {DT_STRING, DT_STRING, DT_STRING, DT_STRING}, InitOpers, DoOper, DoneOpers}, {"service", - {"nick", "user", "host", "gecos", "modes", ""}, - {"", "", "", "", "", ""}, - {DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING}, + {"nick", "user", "host", "gecos", "modes", "channels", ""}, + {"", "", "", "", "", "", ""}, + {DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING}, InitServices, DoServices, DoneServices}, {"log", - {"target", "source", "logage", "inhabitlogchannel", "admin", "override", "commands", "servers", "channels", "users", "other", "rawio", "debug", ""}, - {"", "", "7", "yes", "", "", "", "", "", "", "", "no", "no", ""}, - {DT_STRING, DT_STRING, DT_INTEGER, DT_BOOLEAN, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN, DT_BOOLEAN}, + {"target", "source", "logage", "admin", "override", "commands", "servers", "channels", "users", "other", "rawio", "debug", ""}, + {"", "", "7", "", "", "", "", "", "", "", "no", "no", ""}, + {DT_STRING, DT_STRING, DT_INTEGER, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN, DT_BOOLEAN}, InitLogs, DoLogs, DoneLogs}, {"command", {"service", "name", "command", "permission", ""}, diff --git a/src/logger.cpp b/src/logger.cpp index 1725e8670..dbaba975a 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -176,7 +176,7 @@ Log::~Log() } } -LogInfo::LogInfo(int logage, bool inhabit, bool rawio, bool ldebug) : LogAge(logage), Inhabit(inhabit), RawIO(rawio), Debug(ldebug) +LogInfo::LogInfo(int logage, bool rawio, bool ldebug) : LogAge(logage), RawIO(rawio), Debug(ldebug) { } diff --git a/src/servers.cpp b/src/servers.cpp index d1e20e515..dccea8929 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -52,7 +52,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A /* Check to be sure this isn't a juped server */ if (Me == this->UplinkServer && !this->HasFlag(SERVER_JUPED)) { - /* Load MLock from the database now that we know what modes exist */ + /* Now do mode related stuff as we know what modes exist .. */ for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) it->second->LoadMLock(); for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) @@ -60,6 +60,22 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A BotInfo *bi = it->second; Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : ircd->pseudoclient_mode; bi->SetModesInternal(modes.c_str()); + for (unsigned i = 0; i < bi->botchannels.size(); ++i) + { + size_t h = bi->botchannels[i].find('#'); + Anope::string chname = bi->botchannels[i].substr(h != Anope::string::npos ? h : 0); + Channel *c = findchan(chname); + if (c && c->FindUser(bi)) + { + Anope::string want_modes = bi->botchannels[i].substr(0, h); + for (unsigned j = 0; j < want_modes.length(); ++j) + { + ChannelMode *cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_modes[j])); + if (cm && cm->Type == MODE_STATUS) + c->SetModeInternal(cm, bi->nick); + } + } + } } ircdproto->SendBOB(); |