From 27a2645ed3a44cad9435a5315078bfd35d1c793f Mon Sep 17 00:00:00 2001 From: Robby Date: Fri, 25 Sep 2015 02:40:28 +0200 Subject: Fix chanserv botmodes. --- modules/pseudoclients/chanserv.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 0ceeded25..ee9ab59ff 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -12,6 +12,13 @@ #include "module.h" #include "modules/cs_mode.h" +inline static Anope::string BotModes() +{ + return Config->GetModule("botserv")->Get("botmodes", + Config->GetModule("chanserv")->Get("botmodes", "o") + ); +} + class ChanServCore : public Module, public ChanServService { Reference ChanServ; @@ -395,7 +402,7 @@ class ChanServCore : public Module, public ChanServService ci->WhoSends()->Assign(NULL, ci); if (ci->c->FindUser(ci->bi) == NULL) { - ChannelStatus status(Config->GetModule("botserv")->Get("botmodes")); + ChannelStatus status(BotModes()); ci->bi->Join(ci->c, &status); } } -- cgit From 80c332bc410cf08b9bef8995fe00441c6e736baa Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 4 Nov 2015 20:03:26 -0500 Subject: Fix logonnews to prioritize the newest entries if it can't show them all --- modules/commands/os_news.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index b74ca3b57..a0dc13407 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -403,23 +403,27 @@ class OSNews : public Module else if (Type == NEWS_RANDOM) msg = _("[\002Random News\002 - %s] %s"); - unsigned displayed = 0; - for (unsigned i = 0, end = newsList.size(); i < end; ++i) + int start = 0; + + if (type != NEWS_RANDOM) + { + start = newsList.size() - news_count; + if (start < 0) + start = 0; + } + + for (unsigned i = start, end = newsList.size(); i < end; ++i) { if (Type == NEWS_RANDOM && i != cur_rand_news) continue; u->SendMessage(bi, msg.c_str(), Anope::strftime(newsList[i]->time, u->Account(), true).c_str(), newsList[i]->text.c_str()); - ++displayed; - if (Type == NEWS_RANDOM) { ++cur_rand_news; break; } - else if (displayed >= news_count) - break; } /* Reset to head of list to get first random news value */ -- cgit From 4c1cc0e05d49b494b1462dba1d51d31cec384436 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 4 Nov 2015 20:51:02 -0500 Subject: Cleanup after xlines if directly removed --- include/xline.h | 2 ++ src/xline.cpp | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/include/xline.h b/include/xline.h index 2eae08dc8..50d17464f 100644 --- a/include/xline.h +++ b/include/xline.h @@ -113,6 +113,8 @@ class CoreExport XLineManager : public Service */ void AddXLine(XLine *x); + void RemoveXLine(XLine *); + /** Delete an entry from this XLineManager * @param x The entry * @return true if the entry was found and deleted, else false diff --git a/src/xline.cpp b/src/xline.cpp index 8f02b930e..2e48283d0 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -107,6 +107,9 @@ XLine::XLine(const Anope::string &ma, const Anope::string &b, const time_t ex, c XLine::~XLine() { + if (manager) + manager->RemoveXLine(this); + delete regex; delete c; } @@ -291,6 +294,30 @@ void XLineManager::AddXLine(XLine *x) x->manager = this; } +void XLineManager::RemoveXLine(XLine *x) +{ + /* called from the destructor */ + + std::vector::iterator it = std::find(this->xlines->begin(), this->xlines->end(), x); + + if (!x->id.empty()) + { + std::multimap::iterator it2 = XLinesByUID->find(x->id), it3 = XLinesByUID->upper_bound(x->id); + for (; it2 != XLinesByUID->end() && it2 != it3; ++it2) + if (it2->second == x) + { + XLinesByUID->erase(it2); + break; + } + } + + if (it != this->xlines->end()) + { + this->SendDel(x); + this->xlines->erase(it); + } +} + bool XLineManager::DelXLine(XLine *x) { std::vector::iterator it = std::find(this->xlines->begin(), this->xlines->end(), x); @@ -331,14 +358,16 @@ XLine* XLineManager::GetEntry(unsigned index) void XLineManager::Clear() { - for (unsigned i = 0; i < this->xlines->size(); ++i) + std::vector xl; + this->xlines->swap(xl); + + for (unsigned i = 0; i < xl.size(); ++i) { - XLine *x = this->xlines->at(i); + XLine *x = xl[i]; if (!x->id.empty()) XLinesByUID->erase(x->id); delete x; } - this->xlines->clear(); } bool XLineManager::CanAdd(CommandSource &source, const Anope::string &mask, time_t expires, const Anope::string &reason) -- cgit From d40edcae69092ab02fc302066a0aa968843fc963 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 5 Nov 2015 20:50:10 -0500 Subject: null xline manager when removing so removexline doesn't get called --- src/xline.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xline.cpp b/src/xline.cpp index 2e48283d0..49341072f 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -337,6 +337,7 @@ bool XLineManager::DelXLine(XLine *x) { this->SendDel(x); + x->manager = NULL; // Don't call remove delete x; this->xlines->erase(it); -- cgit From 252a65af7e63e7da7d4984f45aef49edbfbac2bd Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 8 Dec 2015 14:06:08 -0500 Subject: Update LOG dir in anoperc --- src/tools/anoperc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/anoperc.in b/src/tools/anoperc.in index 5f4e6c5eb..6fef1a125 100644 --- a/src/tools/anoperc.in +++ b/src/tools/anoperc.in @@ -16,7 +16,7 @@ ANOPEPID="@INSTDIR@/data/services.pid" ANOPROG="@INSTDIR@/bin/services" -LOG="@INSTDIR@/data/logs/" +LOG="@INSTDIR@/logs/" ARCVERSION="2" isAnopeRunning () { -- cgit From 16d08e57df9cc5909b3477e51fac7baa7f312aff Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Dec 2015 19:14:44 -0500 Subject: Fall back to account vhost in hs on/off --- modules/commands/hs_off.cpp | 3 +++ modules/commands/hs_on.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index 603b863c1..d0a64fb5b 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -23,7 +23,10 @@ class CommandHSOff : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { User *u = source.GetUser(); + const NickAlias *na = NickAlias::Find(u->nick); + if (!na || na->nc != u->Account() || !na->HasVhost()) + na = NickAlias::Find(u->Account()->display); if (!na || !na->HasVhost()) source.Reply(HOST_NOT_ASSIGNED); diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index d59206e27..26fa6266f 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -27,6 +27,8 @@ class CommandHSOn : public Command User *u = source.GetUser(); const NickAlias *na = NickAlias::Find(u->nick); + if (!na || na->nc != u->Account() || !na->HasVhost()) + na = NickAlias::Find(u->Account()->display); if (na && u->Account() == na->nc && na->HasVhost()) { if (!na->GetVhostIdent().empty()) -- cgit From c414433fae4a2890f6879f6b375fb002f87eebe0 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Dec 2015 19:18:12 -0500 Subject: Allow wildcard searching emails --- modules/commands/ns_getemail.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp index 8d7976bb0..39239e86f 100644 --- a/modules/commands/ns_getemail.cpp +++ b/modules/commands/ns_getemail.cpp @@ -35,16 +35,16 @@ class CommandNSGetEMail : public Command { const NickCore *nc = it->second; - if (!nc->email.empty() && nc->email.equals_ci(email)) + if (!nc->email.empty() && Anope::Match(nc->email, email)) { ++j; - source.Reply(_("Email matched: \002%s\002 to \002%s\002."), nc->display.c_str(), email.c_str()); + source.Reply(_("Email matched: \002%s\002 (\002%s\002) to \002%s\002."), nc->display.c_str(), nc->email.c_str(), email.c_str()); } } if (j <= 0) { - source.Reply(_("No nick registrations matching \002%s\002 found."), email.c_str()); + source.Reply(_("No registrations matching \002%s\002 were found."), email.c_str()); return; } @@ -55,10 +55,7 @@ class CommandNSGetEMail : public Command { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Returns the matching nicks that used given email. \002Note\002 that\n" - "you can not use wildcards. Whenever this command is used, a message\n" - "including the person who issued the command and the email it was used\n" - "on will be logged.")); + source.Reply(_("Returns the matching accounts that used given email.")); return true; } }; -- cgit From 5394f5433a1d85be9a35d9b46d9384a6b646106d Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Dec 2015 19:21:53 -0500 Subject: Fix SendNumericInternal on inspircd sending to the user's uid if dest is a uid --- modules/protocol/inspircd12.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index e3c61a442..c5c3a40e4 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -216,7 +216,8 @@ class InspIRCd12Proto : public IRCDProto void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override { - UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf; + User *u = User::Find(dest); + UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << (u ? u->nick : dest) << " " << buf; } void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override -- cgit From 56abaf8498db9f786dfa10eae87317ca5c14ce42 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Dec 2015 19:27:15 -0500 Subject: Add notice method to m_xmlrpc_main --- modules/m_xmlrpc_main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/m_xmlrpc_main.cpp b/modules/m_xmlrpc_main.cpp index 13645bc98..38cb4a8d7 100644 --- a/modules/m_xmlrpc_main.cpp +++ b/modules/m_xmlrpc_main.cpp @@ -59,6 +59,8 @@ class MyXMLRPCEvent : public XMLRPCEvent this->DoUser(iface, client, request); else if (request.name == "opers") this->DoOperType(iface, client, request); + else if (request.name == "notice") + this->DoNotice(iface, client, request); return true; } @@ -249,6 +251,21 @@ class MyXMLRPCEvent : public XMLRPCEvent request.reply(ot->GetName(), perms); } } + + void DoNotice(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + { + Anope::string from = request.data.size() > 0 ? request.data[0] : ""; + Anope::string to = request.data.size() > 1 ? request.data[1] : ""; + Anope::string message = request.data.size() > 2 ? request.data[2] : ""; + + BotInfo *bi = BotInfo::Find(from, true); + User *u = User::Find(to, true); + + if (!bi || !u || message.empty()) + return; + + u->SendMessage(bi, message); + } }; class ModuleXMLRPCMain : public Module -- cgit From 98b35dfab2d7e532e9634de4fc8c695d5911c351 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Dec 2015 19:28:31 -0500 Subject: Document m_xmlrpc_main notice --- docs/XMLRPC/XMLRPC | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/XMLRPC/XMLRPC b/docs/XMLRPC/XMLRPC index 95a18abc4..ee655cb19 100644 --- a/docs/XMLRPC/XMLRPC +++ b/docs/XMLRPC/XMLRPC @@ -17,6 +17,8 @@ channel - Takes one parameter, a channel name, and returns real time information user - Takes one parameter, a user name, and returns real time information regarding that user. +notice - Takes three parameters, source user, target user, and message. Sends a message to the user. + XMLRPC was designed to be used with db_sql, and will not return any information that can be pulled from the SQL database, such as accounts and registered channel information. It is instead used for pulling realtime data such as users and channels currently online. For examples on how to use these calls in PHP, see xmlrpc.php in docs/XMLRPC. -- cgit From ecdd046c80d696a882b12af615ed9f217afd40a9 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Dec 2015 19:37:24 -0500 Subject: Add some replacement tokens for akick reason and welcome notice --- data/nickserv.example.conf | 2 +- modules/commands/cs_akick.cpp | 6 +++++- modules/pseudoclients/nickserv.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index e12d5ec2b..4b383f80e 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -79,7 +79,7 @@ module confirmemailchanges = no /* - * A message sent to users on connect if they use an unregistered nick. + * A message sent to users on connect if they use an unregistered nick. %n will be replaced with the user's nickname. * * This directive is optional. */ diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 03db4c623..327b98b09 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -554,7 +554,11 @@ class CSAKick : public Module mask = autokick->mask; reason = autokick->reason; if (reason.empty()) - reason = Language::Translate(u, Config->GetModule(this)->Get("autokickreason").c_str()); + { + reason = Language::Translate(u, Config->GetModule(this)->Get("autokickreason").c_str()) + .replace_all_cs("%n", u->nick) + .replace_all_cs("%c", c->name); + } if (reason.empty()) reason = Language::Translate(u, _("User has been banned from the channel")); return EVENT_STOP; diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index ee1049195..5d3579ced 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -400,7 +400,7 @@ class NickServCore : public Module, public NickServService const Anope::string &unregistered_notice = Config->GetModule(this)->Get("unregistered_notice"); if (!Config->GetModule("nickserv")->Get("nonicknameownership") && !unregistered_notice.empty() && !na && !u->Account()) - u->SendMessage(NickServ, unregistered_notice); + u->SendMessage(NickServ, unregistered_notice.replace_all_cs("%n", u->nick)); else if (na && !u->IsIdentified(true)) this->Validate(u); } -- cgit