summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-07-09 20:01:03 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-27 18:32:32 +0200
commit86f8294c2de86b8d060abbb02f7c51c0ca0d9ead (patch)
tree0231a6f54a4721b4237dfe699656ab86bee25cf5 /src/modules
parentb55c842c9d8730e50865fb7dd98bce4aa85af0d7 (diff)
m_permchannels Save channel TS, topic set time and set by information
When loading, ignore and log channels with a name longer than Limits.MaxChan
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_permchannels.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index bd65c5822..1bcb2ac17 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -58,12 +58,20 @@ static bool WriteDatabase()
if (!chan->IsModeSet('P'))
continue;
+ std::string chants = ConvToStr(chan->age);
+ std::string topicts = ConvToStr(chan->topicset);
const char* items[] =
{
"<permchannels channel=",
chan->name.c_str(),
+ " ts=",
+ chants.c_str(),
" topic=",
chan->topic.c_str(),
+ " topicts=",
+ topicts.c_str(),
+ " topicsetby=",
+ chan->setby.c_str(),
" modes=",
chan->ChanModes(true),
">\n"
@@ -71,7 +79,7 @@ static bool WriteDatabase()
line.clear();
int item = 0, ipos = 0;
- while (item < 7)
+ while (item < 13)
{
char c = items[item][ipos++];
if (c == 0)
@@ -222,9 +230,9 @@ public:
std::string topic = tag->getString("topic");
std::string modes = tag->getString("modes");
- if (channel.empty())
+ if ((channel.empty()) || (channel.length() > ServerInstance->Config->Limits.ChanMax))
{
- ServerInstance->Logs->Log("m_permchannels", DEBUG, "Malformed permchannels tag with empty channel name.");
+ ServerInstance->Logs->Log("m_permchannels", DEFAULT, "Ignoring permchannels tag with empty or too long channel name (\"" + channel + "\")");
continue;
}
@@ -232,19 +240,16 @@ public:
if (!c)
{
- c = new Channel(channel, ServerInstance->Time());
- if (!topic.empty())
- {
- c->SetTopic(NULL, topic, true);
-
- /*
- * Due to the way protocol works in 1.2, we need to hack the topic TS in such a way that this
- * topic will always win over others.
- *
- * This is scheduled for (proper) fixing in a later release, and can be removed at a later date.
- */
- c->topicset = 42;
- }
+ time_t TS = tag->getInt("ts");
+ c = new Channel(channel, ((TS > 0) ? TS : ServerInstance->Time()));
+
+ c->SetTopic(NULL, topic, true);
+ c->setby = tag->getString("topicsetby");
+ unsigned int topicset = tag->getInt("topicts");
+ // SetTopic() sets the topic TS to now, if there was no topicts saved then don't overwrite that with a 0
+ if (topicset > 0)
+ c->topicset = topicset;
+
ServerInstance->Logs->Log("m_permchannels", DEBUG, "Added %s with topic %s", channel.c_str(), topic.c_str());
if (modes.empty())