diff options
| author | Adam <Adam@anope.org> | 2016-10-15 16:25:57 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2016-10-15 16:25:57 -0400 |
| commit | 1ba242179fee46583098f48421af39ce9a8985a1 (patch) | |
| tree | a276cd7bd53e7270c86ab3744bd6a568a016501b /modules/botserv | |
| parent | 696239e93391f3dfd6459857fb02a6006048093a (diff) | |
Various improvements/bugfixes to extdb stuff
Diffstat (limited to 'modules/botserv')
| -rw-r--r-- | modules/botserv/assign.cpp | 4 | ||||
| -rw-r--r-- | modules/botserv/bot.cpp | 26 | ||||
| -rw-r--r-- | modules/botserv/info.cpp | 7 | ||||
| -rw-r--r-- | modules/botserv/set.cpp | 2 |
4 files changed, 28 insertions, 11 deletions
diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp index eb6b8da10..a26b869fe 100644 --- a/modules/botserv/assign.cpp +++ b/modules/botserv/assign.cpp @@ -67,7 +67,7 @@ class CommandBSAssign : public Command return; } - if (bi->bi->GetOperOnly() && !source.HasPriv("botserv/administration")) + if (bi->bi && bi->bi->GetOperOnly() && !source.HasPriv("botserv/administration")) { source.Reply(_("Access denied. Bot \002{0}\002 is for operators only."), bi->nick); return; @@ -265,7 +265,7 @@ class BSAssign : public Module return; } - if (bi->bi->GetOperOnly() && !source->HasPriv("botserv/administration")) + if (bi->bi && bi->bi->GetOperOnly() && !source->HasPriv("botserv/administration")) { targ->SendMessage(bi, _("Access denied. Bot \002{0}\002 is for operators only."), bi->nick); return; diff --git a/modules/botserv/bot.cpp b/modules/botserv/bot.cpp index c93c4cf50..2e33b7ccb 100644 --- a/modules/botserv/bot.cpp +++ b/modules/botserv/bot.cpp @@ -93,6 +93,16 @@ class CommandBSBot : public Command ServiceBot *bi = new ServiceBot(nick, user, host, real); + BotInfo *botinfo = Serialize::New<BotInfo *>(); + botinfo->SetNick(nick); + botinfo->SetUser(user); + botinfo->SetHost(host); + botinfo->SetRealName(real); + botinfo->SetCreated(Anope::CurTime); + + bi->bi = botinfo; + botinfo->bot = bi; + Log(LOG_ADMIN, source, this) << "ADD " << bi->GetMask() << " " << bi->realname; source.Reply(_("\002{0}!{1}@{2}\002 (\002{3}\002) added to the bot list."), bi->nick, bi->GetIdent(), bi->host, bi->realname); @@ -121,7 +131,7 @@ class CommandBSBot : public Command return; } - if (bi->bi->conf) + if (bi->bi && bi->bi->conf) { source.Reply(_("Bot \002{0}\002 is not changeable because it is configured in services configuration."), bi->nick.c_str()); return; @@ -226,23 +236,27 @@ class CommandBSBot : public Command if (!nick.equals_cs(bi->nick)) { bi->SetNewNick(nick); - bi->bi->SetNick(nick); + if (bi->bi != nullptr) + bi->bi->SetNick(nick); } if (!user.equals_cs(bi->GetIdent())) { bi->SetIdent(user); - bi->bi->SetUser(user); + if (bi->bi != nullptr) + bi->bi->SetUser(user); } if (!host.equals_cs(bi->host)) { bi->host = host; - bi->bi->SetHost(host); + if (bi->bi != nullptr) + bi->bi->SetHost(host); } if (real.equals_cs(bi->realname)) { bi->realname = real; - bi->bi->SetRealName(real); + if (bi->bi != nullptr) + bi->bi->SetRealName(real); } if (!user.empty()) @@ -271,7 +285,7 @@ class CommandBSBot : public Command return; } - if (bi->bi->conf) + if (bi->bi && bi->bi->conf) { source.Reply(_("Bot \002{0}\002 is can not be deleted because it is configured in services configuration."), bi->nick); return; diff --git a/modules/botserv/info.cpp b/modules/botserv/info.cpp index 94b1bbbd7..4de86643f 100644 --- a/modules/botserv/info.cpp +++ b/modules/botserv/info.cpp @@ -41,8 +41,11 @@ class CommandBSInfo : public Command source.Reply(_("Information for bot \002%s\002:"), bi->nick.c_str()); info[_("Mask")] = bi->GetIdent() + "@" + bi->host; info[_("Real name")] = bi->realname; - info[_("Created")] = Anope::strftime(bi->bi->GetCreated(), source.GetAccount()); - info[_("Options")] = bi->bi->GetOperOnly() ? _("Private") : _("None"); + if (bi->bi) + { + info[_("Created")] = Anope::strftime(bi->bi->GetCreated(), source.GetAccount()); + info[_("Options")] = bi->bi->GetOperOnly() ? _("Private") : _("None"); + } info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)"; EventManager::Get()->Dispatch(&Event::ServiceBotEvent::OnServiceBot, source, bi, ci, info); diff --git a/modules/botserv/set.cpp b/modules/botserv/set.cpp index 47c5337d2..bb432e3f0 100644 --- a/modules/botserv/set.cpp +++ b/modules/botserv/set.cpp @@ -174,7 +174,7 @@ class CommandBSSetPrivate : public Command source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); ServiceBot *bi = ServiceBot::Find(nick, true); - if (bi == NULL) + if (bi == NULL || !bi->bi) { source.Reply(_("Bot \002{0}\002 does not exist."), nick); return; |
