summaryrefslogtreecommitdiff
path: root/modules/protocol
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-09-15 16:40:55 -0400
committerAdam <Adam@anope.org>2010-09-15 16:40:55 -0400
commit813185105823daa6a1b574d86053950382343589 (patch)
tree793d4f54cddc88275b4372839f93bba01301b427 /modules/protocol
parent6239b5a053fc8fd94b798495f8e189a2e2bda285 (diff)
Rewrote all of the topic code, fixes a few topic related problems on some older IRCds
Diffstat (limited to 'modules/protocol')
-rw-r--r--modules/protocol/bahamut.cpp18
-rw-r--r--modules/protocol/inspircd11.cpp45
-rw-r--r--modules/protocol/inspircd12.cpp46
-rw-r--r--modules/protocol/inspircd20.cpp46
-rw-r--r--modules/protocol/ratbox.cpp82
-rw-r--r--modules/protocol/unreal32.cpp32
6 files changed, 100 insertions, 169 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 65924c97f..c1a223672 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -23,10 +23,7 @@ IRCDVar myIrcd[] = {
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
- 0, /* Join 2 Set */
0, /* Join 2 Message */
- 0, /* TS Topic Forward */
- 0, /* TS Topci Backward */
1, /* Chan SQlines */
1, /* Quit on Kill */
1, /* SVSMODE unban */
@@ -174,9 +171,9 @@ class BahamutIRCdProto : public IRCDProto
}
/* TOPIC */
- void SendTopic(const BotInfo *whosets, const Channel *c, const Anope::string &whosetit, const Anope::string &topic)
+ void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->nick, "TOPIC %s %s %lu :%s", c->name.c_str(), whosetit.c_str(), static_cast<unsigned long>(c->topic_time), topic.c_str());
+ send_cmd(whosets->nick, "TOPIC %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time), c->topic.c_str());
}
/* UNSQLINE */
@@ -565,7 +562,16 @@ int anope_event_topic(const Anope::string &source, int ac, const char **av)
{
if (ac != 4)
return MOD_CONT;
- do_topic(source, ac, av);
+
+ Channel *c = findchan(av[0]);
+ if (!c)
+ {
+ Log() << "TOPIC for nonexistant channel " << av[0];
+ return MOD_CONT;
+ }
+
+ c->ChangeTopicInternal(av[1], av[3], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : Anope::CurTime);
+
return MOD_CONT;
}
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 557fe7389..8053a577a 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -24,10 +24,7 @@ IRCDVar myIrcd[] = {
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
- 0, /* Join 2 Set */
1, /* Join 2 Message */
- 1, /* TS Topic Forward */
- 0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
@@ -92,9 +89,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(Config->s_OperServ, "GLINE %s", x->Mask.c_str());
}
- void SendTopic(const BotInfo *whosets, const Channel *c, const Anope::string &whosetit, const Anope::string &topic)
+ void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->nick, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit.c_str(), topic.c_str());
+ send_cmd(whosets->nick, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic_setter.c_str(), c->topic.c_str());
}
void SendVhostDel(User *u)
@@ -303,13 +300,18 @@ class InspIRCdProto : public IRCDProto
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
- const char *temp;
if (ac < 4)
return MOD_CONT;
- temp = av[1]; /* temp now holds ts */
- av[1] = av[2]; /* av[1] now holds set by */
- av[2] = temp; /* av[2] now holds ts */
- do_topic(source, ac, av);
+
+ Channel *c = findchan(av[0]);
+ if (!c)
+ {
+ Log() << "TOPIC for nonexistant channel " << av[0];
+ return MOD_CONT;
+ }
+
+ c->ChangeTopicInternal(av[2], av[3], Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime);
+
return MOD_CONT;
}
@@ -517,30 +519,11 @@ int anope_event_topic(const Anope::string &source, int ac, const char **av)
if (!c)
{
- Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
return MOD_CONT;
}
- if (check_topiclock(c, Anope::CurTime))
- return MOD_CONT;
-
- c->topic.clear();
- if (ac > 1 && *av[1])
- c->topic = av[1];
-
- c->topic_setter = source;
- c->topic_time = Anope::CurTime;
-
- record_topic(av[0]);
-
- if (ac > 1 && *av[1])
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[1]));
- }
- else
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
- }
+ c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""), Anope::CurTime);
return MOD_CONT;
}
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 9532e7669..592fc9e1a 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -24,10 +24,7 @@ IRCDVar myIrcd[] = {
0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
- 0, /* Join 2 Set */
0, /* Join 2 Message */
- 1, /* TS Topic Forward */
- 0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
@@ -95,9 +92,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(OperServ->GetUID(), "GLINE %s", x->Mask.c_str());
}
- void SendTopic(const BotInfo *whosets, const Channel *c, const Anope::string &whosetit, const Anope::string &topic)
+ void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit.c_str(), topic.c_str());
+ send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic_setter.c_str(), c->topic.c_str());
}
void SendVhostDel(User *u)
@@ -313,13 +310,18 @@ class InspIRCdProto : public IRCDProto
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
- const char *temp;
if (ac < 4)
return MOD_CONT;
- temp = av[1]; /* temp now holds ts */
- av[1] = av[2]; /* av[1] now holds set by */
- av[2] = temp; /* av[2] now holds ts */
- do_topic(source, ac, av);
+
+ Channel *c = findchan(av[0]);
+ if (!c)
+ {
+ Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ return MOD_CONT;
+ }
+
+ c->ChangeTopicInternal(av[2], av[2], Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime);
+
return MOD_CONT;
}
@@ -554,34 +556,14 @@ int anope_event_away(const Anope::string &source, int ac, const char **av)
int anope_event_topic(const Anope::string &source, int ac, const char **av)
{
Channel *c = findchan(av[0]);
- User *u = finduser(source);
if (!c)
{
- Log(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
return MOD_CONT;
}
- if (check_topiclock(c, Anope::CurTime))
- return MOD_CONT;
-
- c->topic.clear();
- if (ac > 1 && *av[1])
- c->topic = av[1];
-
- c->topic_setter = u ? u->nick : source;
- c->topic_time = Anope::CurTime;
-
- record_topic(av[0]);
-
- if (ac > 1 && *av[1])
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[0]));
- }
- else
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
- }
+ c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""), Anope::CurTime);
return MOD_CONT;
}
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 47413da23..5d0f9436e 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -24,10 +24,7 @@ IRCDVar myIrcd[] = {
0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
- 0, /* Join 2 Set */
0, /* Join 2 Message */
- 1, /* TS Topic Forward */
- 0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
@@ -93,9 +90,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(OperServ->GetUID(), "GLINE %s", x->Mask.c_str());
}
- void SendTopic(const BotInfo *whosets, const Channel *c, const Anope::string &whosetit, const Anope::string &topic)
+ void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit.c_str(), topic.c_str());
+ send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic_setter.c_str(), c->topic.c_str());
}
void SendVhostDel(User *u)
@@ -311,13 +308,18 @@ class InspIRCdProto : public IRCDProto
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
- const char *temp;
if (ac < 4)
return MOD_CONT;
- temp = av[1]; /* temp now holds ts */
- av[1] = av[2]; /* av[1] now holds set by */
- av[2] = temp; /* av[2] now holds ts */
- do_topic(source, ac, av);
+
+ Channel *c = findchan(av[0]);
+ if (!c)
+ {
+ Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ return MOD_CONT;
+ }
+
+ c->ChangeTopicInternal(av[2], av[2], Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime);
+
return MOD_CONT;
}
@@ -552,34 +554,14 @@ int anope_event_away(const Anope::string &source, int ac, const char **av)
int anope_event_topic(const Anope::string &source, int ac, const char **av)
{
Channel *c = findchan(av[0]);
- User *u = finduser(source);
if (!c)
{
- Log(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
return MOD_CONT;
}
- if (check_topiclock(c, Anope::CurTime))
- return MOD_CONT;
-
- c->topic.clear();
- if (ac > 1 && *av[1])
- c->topic = av[1];
-
- c->topic_setter = u ? u->nick : source;
- c->topic_time = Anope::CurTime;
-
- record_topic(av[0]);
-
- if (ac > 1 && *av[1])
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[0]));
- }
- else
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
- }
+ c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""), Anope::CurTime);
return MOD_CONT;
}
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 505d143fd..807abf202 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -23,10 +23,7 @@ IRCDVar myIrcd[] = {
1, /* Supports SNlines */
1, /* Supports SQlines */
0, /* Supports SZlines */
- 1, /* Join 2 Set */
1, /* Join 2 Message */
- 0, /* TS Topic Forward */
- 0, /* TS Topci Backward */
1, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
@@ -249,9 +246,22 @@ class RatboxProto : public IRCDProto
return true;
}
- void SendTopic(const BotInfo *bi, const Channel *c, const Anope::string &, const Anope::string &topic)
+ void SendTopic(BotInfo *bi, Channel *c)
{
- send_cmd(bi->GetUID(), "TOPIC %s :%s", c->name.c_str(), topic.c_str());
+ bool needjoin = c->FindUser(bi) != NULL;
+ if (needjoin)
+ {
+ ChannelStatus status;
+ status .SetFlag(CMODE_OP);
+ ChannelContainer cc(c);
+ cc.Status = &status;
+ ircdproto->SendJoin(bi, &cc);
+ }
+ send_cmd(bi->GetUID(), "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
+ if (needjoin)
+ {
+ ircdproto->SendPart(bi, c, NULL);
+ }
}
void SetAutoIdentificationToken(User *u)
@@ -417,75 +427,41 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
int anope_event_topic(const Anope::string &source, int ac, const char **av)
{
- User *u;
+ Channel *c = findchan(av[0]);
+ if (!c)
+ {
+ Log() << "TOPIC for nonexistant channel " << av[0];
+ return MOD_CONT;
+ }
if (ac == 4)
- do_topic(source, ac, av);
+ {
+ c->ChangeTopicInternal(av[1], av[3], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : Anope::CurTime);
+ }
else
{
- Channel *c = findchan(av[0]);
-
- if (!c)
- {
- Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
- return MOD_CONT;
- }
-
- if (check_topiclock(c, Anope::CurTime))
- return MOD_CONT;
-
- c->topic.clear();
- if (ac > 1 && *av[1])
- c->topic = av[1];
-
- u = finduser(source);
- c->topic_setter = u ? u->nick : source;
- c->topic_time = Anope::CurTime;
-
- record_topic(av[0]);
-
- if (ac > 1 && *av[1])
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[1]));
- }
- else
- {
- FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
- }
+ c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""));
}
return MOD_CONT;
}
int anope_event_tburst(const Anope::string &source, int ac, const char **av)
{
- Channel *c;
- time_t topic_time;
-
if (ac != 4)
return MOD_CONT;
Anope::string setter = myStrGetToken(av[2], '!', 0);
-
- c = findchan(av[0]);
- topic_time = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
+ time_t topic_time = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime;
+ Channel *c = findchan(av[0]);
if (!c)
{
- Log(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
return MOD_CONT;
}
- if (check_topiclock(c, topic_time))
- return MOD_CONT;
-
- c->topic.clear();
- if (ac > 1 && *av[3])
- c->topic = av[3];
-
- c->topic_setter = setter;
- c->topic_time = topic_time;
+ c->ChangeTopicInternal(setter, ac > 3 && *av[3] ? av[3] : "", topic_time);
- record_topic(av[0]);
return MOD_CONT;
}
diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp
index 0b5b56b08..892c4fc57 100644
--- a/modules/protocol/unreal32.cpp
+++ b/modules/protocol/unreal32.cpp
@@ -23,10 +23,7 @@ IRCDVar myIrcd[] = {
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
- 0, /* Join 2 Set */
0, /* Join 2 Message */
- 1, /* TS Topic Forward */
- 0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
1, /* SVSMODE unban */
@@ -112,9 +109,9 @@ class UnrealIRCdProto : public IRCDProto
send_cmd("", "BD - G %s %s %s", x->GetUser().c_str(), x->GetHost().c_str(), Config->s_OperServ.c_str());
}
- void SendTopic(const BotInfo *whosets, const Channel *c, const Anope::string &whosetit, const Anope::string &topic)
+ void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->nick, ") %s %s %lu :%s", c->name.c_str(), whosetit.c_str(), static_cast<unsigned long>(c->topic_time), topic.c_str());
+ send_cmd(whosets->nick, ") %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic.c_str());
}
void SendVhostDel(User *u)
@@ -612,21 +609,26 @@ int anope_event_away(const Anope::string &source, int ac, const char **av)
/*
** m_topic
-** parv[0] = sender prefix
-** parv[1] = topic text
-**
-** For servers using TS:
-** parv[0] = sender prefix
-** parv[1] = channel name
-** parv[2] = topic nickname
-** parv[3] = topic time
-** parv[4] = topic text
+** source = sender prefix
+** parv[0] = channel name
+** parv[1] = topic nickname
+** parv[2] = topic time
+** parv[3] = topic text
*/
int anope_event_topic(const Anope::string &source, int ac, const char **av)
{
if (ac != 4)
return MOD_CONT;
- do_topic(source, ac, av);
+
+ Channel *c = findchan(av[0]);
+ if (!c)
+ {
+ Log() << "TOPIC for nonexistant channel " << av[0];
+ return MOD_CONT;
+ }
+
+ c->ChangeTopicInternal(av[1], av[3], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : Anope::CurTime);
+
return MOD_CONT;
}