summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>2008-09-30 18:45:11 +0000
committerRobin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>2008-09-30 18:45:11 +0000
commitc4d520b465f8aa7f5924b17b697fa760b6ead409 (patch)
tree96f6c2164077f7319bc6be855ce250e23ec9f07d
parent76cc8d0462422eed9d7af255b152c24697821309 (diff)
Move some stuff to BotInfo methods.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1232 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/bots.h12
-rw-r--r--include/extern.h1
-rw-r--r--src/bots.cpp29
-rw-r--r--src/botserv.c16
-rw-r--r--src/core/bs_assign.c8
-rw-r--r--src/core/bs_unassign.c2
6 files changed, 43 insertions, 25 deletions
diff --git a/include/bots.h b/include/bots.h
index 50fb844e2..6573903be 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -44,5 +44,17 @@ class BotInfo
* Used on /kill, rename, etc.
*/
void RejoinAll();
+
+ /** Assign this bot to a given channel, removing the existing assigned bot if one exists.
+ * @param u The user assigning the bot, or NULL
+ * @param ci The channel registration to assign the bot to.
+ */
+ void Assign(User *u, ChannelInfo *ci);
+
+ /** Remove this bot from a given channel.
+ * @param u The user requesting the unassign, or NULL.
+ * @param ci The channel registration to remove the bot from.
+ */
+ void UnAssign(User *u, ChannelInfo *ci);
};
diff --git a/include/extern.h b/include/extern.h
index 94a6328ac..54e9134e8 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -74,7 +74,6 @@ E void save_bs_rdb_dbase(void);
E BotInfo *findbot(const char *nick);
E void bot_join(ChannelInfo *ci);
E char *normalizeBuffer(const char *);
-E void unassign(User * u, ChannelInfo * ci);
E void insert_bot(BotInfo * bi);
E void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, char *reason);
diff --git a/src/bots.cpp b/src/bots.cpp
index 487cc6dc7..29f51f0e0 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -45,3 +45,32 @@ void BotInfo::RejoinAll()
if (ci->bi == this && ci->c && (ci->c->usercount >= BSMinUsers))
bot_join(ci);
}
+
+void BotInfo::Assign(User *u, ChannelInfo *ci)
+{
+ if (ci->bi)
+ {
+ if (u)
+ ci->bi->UnAssign(u, ci);
+ else
+ ci->bi->UnAssign(NULL, ci);
+ }
+
+ ci->bi = this;
+ this->chancount++;
+ if (ci->c && ci->c->usercount >= BSMinUsers)
+ bot_join(ci);
+}
+
+void BotInfo::UnAssign(User *u, ChannelInfo *ci)
+{
+ send_event(EVENT_BOT_UNASSIGN, 2, ci->name, ci->bi->nick);
+
+ if (u && ci->c && ci->c->usercount >= BSMinUsers)
+ anope_cmd_part(ci->bi->nick, ci->name, "UNASSIGN from %s", u->nick);
+
+ ci->bi->chancount--;
+ ci->bi = NULL;
+}
+
+
diff --git a/src/botserv.c b/src/botserv.c
index 7fd029153..745acb47c 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -617,22 +617,6 @@ BotInfo *findbot(const char *nick)
/*************************************************************************/
-/* Unassign a bot from a channel. Assumes u, ci and ci->bi are not NULL */
-
-void unassign(User * u, ChannelInfo * ci)
-{
- send_event(EVENT_BOT_UNASSIGN, 2, ci->name, ci->bi->nick);
-
- if (ci->c && ci->c->usercount >= BSMinUsers) {
- anope_cmd_part(ci->bi->nick, ci->name, "UNASSIGN from %s",
- u->nick);
- }
- ci->bi->chancount--;
- ci->bi = NULL;
-}
-
-/*************************************************************************/
-
/* Returns ban data associated with an user if it exists, allocates it
otherwise. */
diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c
index e34ca7d81..22c9d9c17 100644
--- a/src/core/bs_assign.c
+++ b/src/core/bs_assign.c
@@ -88,13 +88,7 @@ int do_assign(User * u)
|| (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u)))
notice_lang(s_BotServ, u, PERMISSION_DENIED);
else {
- if (ci->bi)
- unassign(u, ci);
- ci->bi = bi;
- bi->chancount++;
- if (ci->c && ci->c->usercount >= BSMinUsers) {
- bot_join(ci);
- }
+
notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name);
send_event(EVENT_BOT_ASSIGN, 2, ci->name, bi->nick);
}
diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c
index a5e0af6bb..3dcb15506 100644
--- a/src/core/bs_unassign.c
+++ b/src/core/bs_unassign.c
@@ -82,7 +82,7 @@ int do_unassign(User * u)
else if (!ci->bi)
notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
else {
- unassign(u, ci);
+ ci->bi->UnAssign(u, ci);
notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name);
}
return MOD_CONT;