summaryrefslogtreecommitdiff
path: root/modules/commands/bs_bot.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-05 01:55:04 -0400
committerAdam <Adam@anope.org>2013-05-05 01:55:04 -0400
commit1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch)
tree4486f0784bdf050fd7eb225c0cb9df352ce1f45a /modules/commands/bs_bot.cpp
parent781defb7076ddfddf723ca08cd0a518b6657b64f (diff)
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'modules/commands/bs_bot.cpp')
-rw-r--r--modules/commands/bs_bot.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp
index f8ecb1a1d..16fd9f2f2 100644
--- a/modules/commands/bs_bot.cpp
+++ b/modules/commands/bs_bot.cpp
@@ -29,21 +29,23 @@ class CommandBSBot : public Command
return;
}
- if (nick.length() > Config->NickLen)
+ Configuration::Block *networkinfo = Config->GetBlock("networkinfo");
+
+ if (nick.length() > networkinfo->Get<unsigned>("nicklen"))
{
- source.Reply(_("Bot nicks may only be %d characters long."), Config->NickLen);
+ source.Reply(_("Bot nicks may only be %d characters long."), networkinfo->Get<unsigned>("nicklen"));
return;
}
- if (user.length() > Config->UserLen)
+ if (user.length() > networkinfo->Get<unsigned>("userlen"))
{
- source.Reply(_("Bot idents may only be %d characters long."), Config->UserLen);
+ source.Reply(_("Bot idents may only be %d characters long."), networkinfo->Get<unsigned>("userlen"));
return;
}
- if (host.length() > Config->HostLen)
+ if (host.length() > networkinfo->Get<unsigned>("hostlen"))
{
- source.Reply(_("Bot hosts may only be %d characters long."), Config->HostLen);
+ source.Reply(_("Bot hosts may only be %d characters long."), networkinfo->Get<unsigned>("hostlen"));
return;
}
@@ -112,21 +114,23 @@ class CommandBSBot : public Command
return;
}
- if (nick.length() > Config->NickLen)
+ Configuration::Block *networkinfo = Config->GetBlock("networkinfo");
+
+ if (nick.length() > networkinfo->Get<unsigned>("nicklen"))
{
- source.Reply(_("Bot nicks may only be %d characters long."), Config->NickLen);
+ source.Reply(_("Bot nicks may only be %d characters long."), networkinfo->Get<unsigned>("nicklen"));
return;
}
- if (!user.empty() && user.length() > Config->UserLen)
+ if (user.length() > networkinfo->Get<unsigned>("userlen"))
{
- source.Reply(_("Bot idents may only be %d characters long."), Config->UserLen);
+ source.Reply(_("Bot idents may only be %d characters long."), networkinfo->Get<unsigned>("userlen"));
return;
}
- if (!host.empty() && host.length() > Config->HostLen)
+ if (host.length() > networkinfo->Get<unsigned>("hostlen"))
{
- source.Reply(_("Bot hosts may only be %d characters long."), Config->HostLen);
+ source.Reply(_("Bot hosts may only be %d characters long."), networkinfo->Get<unsigned>("hostlen"));
return;
}
@@ -204,7 +208,15 @@ class CommandBSBot : public Command
if (!user.empty())
{
IRCD->SendClientIntroduction(bi);
- bi->RejoinAll();
+ unsigned minusers = Config->GetBlock("botserv")->Get<unsigned>("minusers");
+ const std::set<ChannelInfo *> &channels = bi->GetChannels();
+ for (std::set<ChannelInfo *>::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it)
+ {
+ const ChannelInfo *ci = *it;
+
+ if (ci->c && ci->c->users.size() >= minusers)
+ bi->Join(ci->c);
+ }
}
source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)."), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str());