1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 08:43:13 +02:00

Fixed calculating bots channel count of assigned channels and fixed the order of saving memos (among other things)

This commit is contained in:
Adam
2012-02-24 14:53:34 -05:00
parent 24811e5970
commit 2337b7717d
7 changed files with 26 additions and 25 deletions
+4 -1
View File
@@ -39,7 +39,6 @@ static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF
class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable
{
public:
uint32_t chancount;
time_t created; /* Birth date ;) */
time_t lastmsg; /* Last time we said something */
typedef Anope::insensitive_map<CommandInfo> command_map;
@@ -89,6 +88,10 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
*/
void UnAssign(User *u, ChannelInfo *ci);
/** Get the number of channels this bot is assigned to
*/
unsigned GetChannelCount();
/** Join this bot to a channel
* @param c The channel
* @param status The status the bot should have on the channel
+1 -1
View File
@@ -71,7 +71,7 @@ class CommandBSInfo : public Command
info[_("Real name")] = bi->realname;
info[_("Created")] = do_strftime(bi->created);
info[_("Options")] = bi->HasFlag(BI_PRIVATE) ? _("Private") : _("None");
info[_("Used on")] = stringify(bi->chancount) + " channel(s)";
info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)";
std::vector<Anope::string> replies;
info.Process(replies);
-1
View File
@@ -622,7 +622,6 @@ static void LoadBots()
BotInfo *bi = new BotInfo(nick, user, host, real);
bi->created = created;
bi->chancount = chancount;
if (flags & OLD_BI_PRIVATE)
bi->SetFlag(BI_PRIVATE);
+2 -2
View File
@@ -507,7 +507,7 @@ static void LoadBotInfo(const std::vector<Anope::string> &params)
bi = new BotInfo(params[0], params[1], params[2]);
bi->created = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0;
bi->chancount = params[4].is_pos_number_only() ? convertTo<uint32_t>(params[4]) : 0;
//bi->chancount = params[4].is_pos_number_only() ? convertTo<uint32_t>(params[4]) : 0;
bi->realname = params[5];
Log(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick;
@@ -736,7 +736,7 @@ class DBPlain : public Module
if (bi->HasFlag(BI_CONF))
continue;
db_buffer << "BI " << bi->nick << " " << bi->GetIdent() << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->realname << endl;
db_buffer << "BI " << bi->nick << " " << bi->GetIdent() << " " << bi->host << " " << bi->created << " " << bi->GetChannelCount() << " :" << bi->realname << endl;
if (bi->FlagCount())
db_buffer << "MD FLAGS " << bi->ToString() << endl;
}
+13 -7
View File
@@ -25,7 +25,6 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
this->realname = nreal;
this->server = Me;
this->chancount = 0;
this->lastmsg = this->created = Anope::CurTime;
this->introduced = false;
@@ -85,7 +84,6 @@ Serializable::serialized_data BotInfo::serialize()
data["host"] << this->host;
data["realname"] << this->realname;
data["created"] << this->created;
data["chancount"] << this->chancount;
data["flags"] << this->ToString();
return data;
@@ -97,7 +95,6 @@ void BotInfo::unserialize(serialized_data &data)
if (bi == NULL)
bi = new BotInfo(data["nick"].astr(), data["user"].astr(), data["host"].astr(), data["realname"].astr());
data["created"] >> bi->created;
data["chancount"] >> bi->chancount;
bi->FromString(data["flags"].astr());
}
@@ -142,8 +139,6 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
if (ci->bi)
ci->bi->UnAssign(u, ci);
++this->chancount;
ci->bi = this;
if (ci->c && ci->c->users.size() >= Config->BSMinUsers)
this->Join(ci->c, &Config->BotModeList);
@@ -164,11 +159,22 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
ci->bi->Part(ci->c);
}
--this->chancount;
ci->bi = NULL;
}
unsigned BotInfo::GetChannelCount()
{
unsigned count = 0;
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
{
ChannelInfo *ci = it->second;
if (ci->bi == this)
++count;
}
return count;
}
void BotInfo::Join(Channel *c, ChannelStatus *status)
{
if (c->FindUser(this) != NULL)
-9
View File
@@ -246,9 +246,6 @@ ChannelInfo::ChannelInfo(ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(Chann
this->akick.clear();
this->badwords.clear();
if (this->bi)
++this->bi->chancount;
for (int i = 0; i < TTB_SIZE; ++i)
this->ttb[i] = ci.ttb[i];
@@ -397,13 +394,7 @@ void ChannelInfo::unserialize(serialized_data &data)
ci->levels[v[i]] = convertTo<int16_t>(v[i + 1]);
}
if (data.count("bi") > 0)
{
if (ci->bi)
ci->bi->chancount--;
ci->bi = findbot(data["bi"].astr());
if (ci->bi)
ci->bi->chancount++;
}
data["capsmin"] >> ci->capsmin;
data["capspercent"] >> ci->capspercent;
data["floodlines"] >> ci->floodlines;
+6 -4
View File
@@ -74,14 +74,16 @@ Serializable::Serializable()
{
if (serizliable_items == NULL)
serizliable_items = new std::list<Serializable *>();
serizliable_items->push_front(this);
this->s_iter = serizliable_items->begin();
serizliable_items->push_back(this);
this->s_iter = serizliable_items->end();
--this->s_iter;
}
Serializable::Serializable(const Serializable &)
{
serizliable_items->push_front(this);
this->s_iter = serizliable_items->begin();
serizliable_items->push_back(this);
this->s_iter = serizliable_items->end();
--this->s_iter;
}
Serializable::~Serializable()