summaryrefslogtreecommitdiff
path: root/modules/commands/bs_assign.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-04-14 17:39:01 -0500
committerAdam <Adam@anope.org>2013-04-14 17:39:01 -0500
commitf08dbced60d59de28d13efee2e19097e0b42f4c7 (patch)
treeb3aae56d92e788e7ca386258ac81ba8a259a8c48 /modules/commands/bs_assign.cpp
parentbaabc91ead367a9461bce20dfa1a0e6d44043358 (diff)
Allow assigning service bots via /invite
Diffstat (limited to 'modules/commands/bs_assign.cpp')
-rw-r--r--modules/commands/bs_assign.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp
index 027193f62..bbac6e689 100644
--- a/modules/commands/bs_assign.cpp
+++ b/modules/commands/bs_assign.cpp
@@ -156,7 +156,37 @@ class BSAssign : public Module
BSAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandbsassign(this), commandbsunassign(this)
{
+ Implementation i[] = { I_OnInvite };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+ }
+
+ void OnInvite(User *source, Channel *c, User *targ) anope_override
+ {
+ BotInfo *bi;
+ if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = dynamic_cast<BotInfo *>(targ)))
+ return;
+
+ AccessGroup access = c->ci->AccessFor(source);
+ if (c->ci->HasExt("BS_NOBOT") || (!access.HasPriv("ASSIGN") && !source->HasPriv("botserv/administration")))
+ {
+ targ->SendMessage(bi, ACCESS_DENIED);
+ return;
+ }
+
+ if (bi->oper_only && !source->HasPriv("botserv/administration"))
+ {
+ targ->SendMessage(bi, ACCESS_DENIED);
+ return;
+ }
+
+ if (c->ci->bi == bi)
+ {
+ targ->SendMessage(bi, _("Bot \002%s\002 is already assigned to channel \002%s\002."), c->ci->bi->nick.c_str(), c->name.c_str());
+ return;
+ }
+ bi->Assign(source, c->ci);
+ targ->SendMessage(bi, _("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), c->name.c_str());
}
};