mirror of
https://github.com/anope/anope.git
synced 2026-06-18 16:34:47 +02:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1606bb01a3 | |||
| 3d86c82ac5 | |||
| a858a1e0a0 | |||
| eaa24d3b0a | |||
| 5355b53008 | |||
| 85a32077b5 | |||
| 5006993d0a | |||
| 1b2b4386c1 | |||
| b199d74088 | |||
| 7e2ef3774b | |||
| e002f39509 | |||
| d3395a5d39 | |||
| 1deff337fe | |||
| adf457ffb2 | |||
| 550adc13f3 | |||
| 04bdcb8ce6 | |||
| 0a99866e5b | |||
| c22f7a9038 | |||
| 074ad6556c | |||
| a657cb5edf | |||
| 63032dc8d9 | |||
| 404f55502e | |||
| 73f3621af6 | |||
| 2a1409face | |||
| f111e3b3ec | |||
| 22a1924bfd | |||
| fa5bb3f1bf | |||
| 12545ccbde | |||
| 98703052cc | |||
| 15635779af | |||
| 1fc58c7a57 |
@@ -77,7 +77,7 @@ jobs:
|
||||
|
||||
- name: Upload artifact
|
||||
if: "${{ github.event_name != 'release' }}"
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: windows-installer
|
||||
path: ${{ github.workspace }}\build\\anope-*.exe
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
# Anope Change Log
|
||||
|
||||
## Anope 2.1.23 (2026-04-01)
|
||||
|
||||
### Changes
|
||||
|
||||
* Added examples to several BotServ commands.
|
||||
|
||||
* Added missing fields to the `RPL_STATSLINKINFO` output.
|
||||
|
||||
* Added support for migrating access entries between systems (currently only `chanserv/flags` is supported).
|
||||
|
||||
* Added the default levels to the `chanserv/levels` DESC help.
|
||||
|
||||
* Changed access listing commands to only show their own access entries unless `ALL` is specified.
|
||||
|
||||
* Fixed a non-translatable string which has been marked as translatable.
|
||||
|
||||
* Fixed the missing AUTOLOGIN extension.
|
||||
|
||||
* Fixed translating the help output when the flexible layout is used.
|
||||
|
||||
* Improved the accuracy of the X-line expiry time in `operserv/stats`.
|
||||
|
||||
* Updated the Portuguese translation.
|
||||
|
||||
* Updated the Romanian translation.
|
||||
|
||||
## Anope 2.1.22 (2026-03-01)
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
+1
-1
@@ -189,5 +189,5 @@ public:
|
||||
* @param name If found, is set to the command name, eg REGISTER
|
||||
* @return true if the given command service exists
|
||||
*/
|
||||
static bool FindCommandFromService(const Anope::string &command_service, BotInfo *&bi, Anope::string &name);
|
||||
static bool FindFromService(const Anope::string &command_service, BotInfo *&bi, Anope::string &name);
|
||||
};
|
||||
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
|
||||
{
|
||||
T t;
|
||||
if (data[this->name] >> t)
|
||||
if (data.TryLoad(this->name, t))
|
||||
this->Set(e, t);
|
||||
else
|
||||
this->Unset(e);
|
||||
@@ -205,9 +205,7 @@ public:
|
||||
|
||||
void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
|
||||
{
|
||||
bool b = false;
|
||||
data[this->name] >> b;
|
||||
if (b)
|
||||
if (data.Load<bool>(this->name))
|
||||
this->Set(e);
|
||||
else
|
||||
this->Unset(e);
|
||||
|
||||
+6
-1
@@ -44,7 +44,7 @@ namespace Language
|
||||
/** Sets the locale to the specified language.
|
||||
* @param lang The language to translate to.
|
||||
*/
|
||||
extern CoreExport void SetLocale(const char* lang);
|
||||
extern CoreExport void SetLocale(const char *lang);
|
||||
|
||||
/** Sets the locale back to the default. */
|
||||
extern CoreExport void ResetLocale();
|
||||
@@ -141,6 +141,11 @@ namespace Language
|
||||
#define CHAN_ACCESS_LIMIT_DEEP N_("You can only have %u access entry on a channel, including access entries from other channels.", "You can only have %u access entries on a channel, including access entries from other channels.")
|
||||
#define CHAN_ACCESS_LEVEL_RANGE _("Access level must be between %d and %d inclusive.")
|
||||
#define CHAN_ACCESS_MALFORMED _("You cannot add a malformed mask to an access list. Did you mean to add %s instead?")
|
||||
#define CHAN_ACCESS_FOREIGN N_("%u access entry from other access systems not shown; use \002%s\033ALL\002 to view all access entries.", "%u access entries from other access systems not shown; use \002%s\033ALL\002 to view all access entries.")
|
||||
#define CHAN_ACCESS_MIGRATED_1 _("\002%s\002 has been migrated to the %s access system.")
|
||||
#define CHAN_ACCESS_MIGRATED_N N_("\002%u\002 entry has been migrated to the %s access system.", "\002%u\002 entries have been migrated to the %s access system.")
|
||||
#define CHAN_ACCESS_NOT_MIGRATED_1 _("\002%s\002 can not be migrated to the %s access system because they have privileges that you do not.")
|
||||
#define CHAN_ACCESS_NOT_MIGRATED_N N_("\002%u\002 entry can not be migrated to the %s access system because they have privileges that you do not.", "\002%u\002 entries can not be migrated to the %s access system because they have privileges that you do not.")
|
||||
#define CHAN_EXCEPTED _("\002%s\002 matches an except on %s and cannot be banned until the except has been removed.")
|
||||
#define CHAN_INFO_HEADER _("Information about channel \002%s\002:")
|
||||
#define CHAN_LIMIT_EXCEEDED _("You have already exceeded your limit of \002%d\002 channels.")
|
||||
|
||||
+4
-2
@@ -601,15 +601,17 @@ public:
|
||||
* @param ci The channel
|
||||
* @param source The source of the command
|
||||
* @param access The access entry that was removed
|
||||
* @param migrated Whether the access entry was deleted because of being migrated to another system.
|
||||
*/
|
||||
virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) ATTR_NOT_NULL(2, 4) { throw NotImplementedException(); }
|
||||
virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access, bool migrated) ATTR_NOT_NULL(2, 4) { throw NotImplementedException(); }
|
||||
|
||||
/** Called when access is added
|
||||
* @param ci The channel
|
||||
* @param source The source of the command
|
||||
* @param access The access changed
|
||||
* @param migrated Whether the access entry was added because of being migrated to another system.
|
||||
*/
|
||||
virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) ATTR_NOT_NULL(2, 4) { throw NotImplementedException(); }
|
||||
virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access, bool migrated) ATTR_NOT_NULL(2, 4) { throw NotImplementedException(); }
|
||||
|
||||
/** Called when the access list is cleared
|
||||
* @param ci The channel
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
/** Retrieves the size of the messages queue for the specified user.
|
||||
* @param nc The account to count queued messages for.
|
||||
*/
|
||||
inline size_t CountQueue(NickCore* nc) const
|
||||
inline size_t CountQueue(NickCore *nc) const
|
||||
{
|
||||
auto *q = GetQueue(nc);
|
||||
return q ? q->size() : 0;
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
/** Retrieves the messages queue for the specified user.
|
||||
* @param nc The account to retrieve queued messages for.
|
||||
*/
|
||||
virtual const std::vector<Anope::string> *GetQueue(NickCore* nc) const = 0;
|
||||
virtual const std::vector<Anope::string> *GetQueue(NickCore *nc) const = 0;
|
||||
|
||||
/** Queues a message to be sent later.
|
||||
* @param nc The account to queue the message for.
|
||||
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
size_t minparams;
|
||||
|
||||
protected:
|
||||
Event(Module *o, const Anope::string& e, size_t mp = 0)
|
||||
Event(Module *o, const Anope::string &e, size_t mp = 0)
|
||||
: Service(o, RPC_EVENT, e)
|
||||
, minparams(mp)
|
||||
{
|
||||
|
||||
+13
-26
@@ -23,46 +23,33 @@ namespace SQL
|
||||
: public Serialize::Data
|
||||
{
|
||||
public:
|
||||
typedef std::map<Anope::string, std::stringstream *> Map;
|
||||
Map data;
|
||||
|
||||
~Data()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
std::iostream &operator[](const Anope::string &key) override
|
||||
{
|
||||
std::stringstream *&ss = data[key];
|
||||
if (!ss)
|
||||
ss = new std::stringstream();
|
||||
return *ss;
|
||||
}
|
||||
Anope::unordered_map<Anope::string> data;
|
||||
|
||||
size_t Hash() const override
|
||||
{
|
||||
size_t hash = 0;
|
||||
for (const auto &[_, value] : this->data)
|
||||
{
|
||||
if (!value->str().empty())
|
||||
hash ^= Anope::hash_cs()(value->str());
|
||||
if (!value.empty())
|
||||
hash ^= Anope::hash_cs()(value);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
std::map<Anope::string, std::iostream *> GetData() const
|
||||
bool LoadInternal(const Anope::string &key, Anope::string &value) override
|
||||
{
|
||||
std::map<Anope::string, std::iostream *> d;
|
||||
for (const auto &[key, value] : this->data)
|
||||
d[key] = value;
|
||||
return d;
|
||||
auto it = this->data.find(key);
|
||||
if (it == this->data.end())
|
||||
return false;
|
||||
|
||||
value = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
bool StoreInternal(const Anope::string &key, const Anope::string &value) override
|
||||
{
|
||||
for (const auto &[_, value] : this->data)
|
||||
delete value;
|
||||
this->data.clear();
|
||||
this->data[key] = value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -307,7 +307,7 @@ public:
|
||||
*/
|
||||
virtual void SendOper(User *u);
|
||||
|
||||
virtual void SendClearModes(const MessageSource &user, Channel *c, User* u, const Anope::string &mode) { }
|
||||
virtual void SendClearModes(const MessageSource &user, Channel *c, User *u, const Anope::string &mode) { }
|
||||
|
||||
virtual bool IsNickValid(const Anope::string &);
|
||||
virtual bool IsChannelValid(const Anope::string &);
|
||||
|
||||
+93
-33
@@ -40,43 +40,11 @@ namespace Serialize
|
||||
UINT,
|
||||
};
|
||||
|
||||
class CoreExport Data
|
||||
{
|
||||
protected:
|
||||
std::map<Anope::string, Serialize::DataType> types;
|
||||
|
||||
public:
|
||||
virtual ~Data() = default;
|
||||
|
||||
virtual std::iostream &operator[](const Anope::string &key) = 0;
|
||||
|
||||
template <typename T>
|
||||
void Store(const Anope::string &key, const T &value)
|
||||
{
|
||||
using Type = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
|
||||
if constexpr (std::is_same_v<Type, bool>)
|
||||
SetType(key, DataType::BOOL);
|
||||
else if constexpr (std::is_floating_point_v<Type>)
|
||||
SetType(key, DataType::FLOAT);
|
||||
else if constexpr (std::is_integral_v<Type> && std::is_signed_v<Type>)
|
||||
SetType(key, DataType::INT);
|
||||
else if constexpr (std::is_integral_v<Type> && std::is_unsigned_v<Type>)
|
||||
SetType(key, DataType::UINT);
|
||||
|
||||
this->operator[](key) << value;
|
||||
}
|
||||
|
||||
virtual size_t Hash() const { throw CoreException("Not supported"); }
|
||||
|
||||
Serialize::DataType GetType(const Anope::string &key) const;
|
||||
void SetType(const Anope::string &key, Serialize::DataType dt);
|
||||
};
|
||||
|
||||
extern void RegisterTypes();
|
||||
extern void CheckTypes();
|
||||
extern void CreateTypes();
|
||||
|
||||
class Data;
|
||||
class Type;
|
||||
template<typename T> class Checker;
|
||||
template<typename T> class Reference;
|
||||
@@ -141,6 +109,98 @@ public:
|
||||
static const std::list<Serializable *> &GetItems();
|
||||
};
|
||||
|
||||
class CoreExport Serialize::Data
|
||||
{
|
||||
protected:
|
||||
/** The specified data types of known fields. */
|
||||
std::map<Anope::string, Serialize::DataType> types;
|
||||
|
||||
Data() = default;
|
||||
|
||||
/** Internal method for loading data from the database.
|
||||
* @param key The field to get the value of.
|
||||
* @param value The location to store the retrieved value.
|
||||
*/
|
||||
virtual bool LoadInternal(const Anope::string &key, Anope::string &value) = 0;
|
||||
|
||||
/** Internal method for storing data in the database.
|
||||
* @param key The field to set the value of.
|
||||
* @param value The value of the field.
|
||||
*/
|
||||
virtual bool StoreInternal(const Anope::string &key, const Anope::string &value) = 0;
|
||||
|
||||
/** Sets the data type of the specified field. This is called automatically from \ref Store.
|
||||
* @param key The field to specify the data type for.
|
||||
* @param dt The data type of the field.
|
||||
*/
|
||||
void SetType(const Anope::string &key, Serialize::DataType dt);
|
||||
|
||||
public:
|
||||
virtual ~Data() = default;
|
||||
|
||||
/** Retrieves the data type for the specified field. If the field does not have a data type
|
||||
* specified then it will default to TEXT.
|
||||
* @param key The field to retrieve the data type for.
|
||||
*/
|
||||
Serialize::DataType GetType(const Anope::string &key) const;
|
||||
|
||||
/** Retrieves a unique hash for the data set. */
|
||||
virtual size_t Hash() const { throw CoreException("Not supported"); }
|
||||
|
||||
/** Loads the value of a specific field.
|
||||
* @param key The field to get the value of.
|
||||
* @param def The default value if none is set.
|
||||
*/
|
||||
template <typename T = Anope::string>
|
||||
T Load(const Anope::string &key, T def = T())
|
||||
{
|
||||
T out;
|
||||
if (!TryLoad(key, out))
|
||||
out = def;
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Stores the value of a specific field, automatically setting its type.
|
||||
* @param key The field to set the value of.
|
||||
* @param value The value of the field.
|
||||
*/
|
||||
template <typename T>
|
||||
void Store(const Anope::string &key, const T &value)
|
||||
{
|
||||
using Type = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
|
||||
if constexpr (std::is_same_v<Type, bool>)
|
||||
SetType(key, DataType::BOOL);
|
||||
else if constexpr (std::is_floating_point_v<Type>)
|
||||
SetType(key, DataType::FLOAT);
|
||||
else if constexpr (std::is_integral_v<Type> && std::is_signed_v<Type>)
|
||||
SetType(key, DataType::INT);
|
||||
else if constexpr (std::is_integral_v<Type> && std::is_unsigned_v<Type>)
|
||||
SetType(key, DataType::UINT);
|
||||
|
||||
StoreInternal(key, Anope::ToString(value));
|
||||
}
|
||||
|
||||
/** Tries to load the value of a specific field.
|
||||
* @param key The field to get the value of.
|
||||
* @param out The location to store the retrieved value.
|
||||
*/
|
||||
template <typename T = Anope::string>
|
||||
bool TryLoad(const Anope::string &key, T &out)
|
||||
{
|
||||
Anope::string out_str;
|
||||
if (!LoadInternal(key, out_str))
|
||||
return false;
|
||||
|
||||
auto out_opt = Anope::TryConvert<T>(out_str);
|
||||
if (!out_opt)
|
||||
return false;
|
||||
|
||||
out = out_opt.value();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/* A serializable type. There should be a single instance of a subclass of this
|
||||
* for each subclass of Serializable as this is what is used to serialize and
|
||||
* deserialize data from the database.
|
||||
|
||||
+4
-4
@@ -57,11 +57,11 @@ private:
|
||||
/* Uplink for this server */
|
||||
Server *uplink;
|
||||
/* Server is syncing */
|
||||
bool syncing;
|
||||
bool syncing = true;
|
||||
/* The server is juped */
|
||||
bool juped;
|
||||
/* The server is about to quit */
|
||||
bool quitting;
|
||||
bool quitting = false;
|
||||
/* Reason this server was quit */
|
||||
Anope::string quit_reason;
|
||||
|
||||
@@ -69,12 +69,12 @@ public:
|
||||
/** Constructor
|
||||
* @param uplink The uplink this server is from, is only NULL when creating Me
|
||||
* @param name The server name
|
||||
* @param hops Hops from services server
|
||||
* @param description Server rdescription
|
||||
* @param sid Server sid/numeric
|
||||
* @param hops Hops from services server
|
||||
* @param jupe If the server is juped
|
||||
*/
|
||||
Server(Server *uplink, const Anope::string &name, unsigned hops, const Anope::string &description, const Anope::string &sid = "", bool jupe = false);
|
||||
Server(Server *uplink, const Anope::string &name, const Anope::string &description, const Anope::string &sid = "", unsigned hops = 0, bool jupe = false);
|
||||
|
||||
private:
|
||||
/** Destructor
|
||||
|
||||
+2
-2
@@ -151,14 +151,14 @@ public:
|
||||
const auto &GetServiceType() const { return type; }
|
||||
|
||||
/** Invalidates the reference and changes the name of the referenced service. */
|
||||
void SetServiceName(const Anope::string& newname)
|
||||
void SetServiceName(const Anope::string &newname)
|
||||
{
|
||||
this->invalid = true;
|
||||
this->name = newname;
|
||||
}
|
||||
|
||||
/** Invalidates the reference and changes the type of the referenced service. */
|
||||
void SetServiceType(const Anope::string& newtype)
|
||||
void SetServiceType(const Anope::string &newtype)
|
||||
{
|
||||
this->invalid = true;
|
||||
this->type = newtype;
|
||||
|
||||
+1
-3
@@ -27,7 +27,7 @@
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -41,8 +41,6 @@
|
||||
#include "defs.h"
|
||||
#include "sysconf.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
#define _(x) x
|
||||
#define N_(x, y) x, y
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
# include <afunix.h>
|
||||
#endif
|
||||
|
||||
#define NET_BUFSIZE 65535
|
||||
|
||||
/** A sockaddr union used to combine IPv4 and IPv6 sockaddrs
|
||||
*/
|
||||
union CoreExport sockaddrs
|
||||
|
||||
+3
-1
@@ -54,7 +54,9 @@ class UplinkSocket final
|
||||
, public BufferedSocket
|
||||
{
|
||||
public:
|
||||
bool error;
|
||||
bool error = false;
|
||||
size_t recv_msgs = 0;
|
||||
size_t sent_msgs = 0;
|
||||
UplinkSocket();
|
||||
~UplinkSocket();
|
||||
bool ProcessRead() override;
|
||||
|
||||
+2100
-100
File diff suppressed because it is too large
Load Diff
+3534
-4098
File diff suppressed because it is too large
Load Diff
+793
-571
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -15,6 +15,8 @@ fi
|
||||
find ../ \
|
||||
! -path '../docs/*' \
|
||||
-a ! -path '../modules/third/*' \
|
||||
-a ! -path '../run/*' \
|
||||
-a ! -path '../vendor/*' \
|
||||
-a \( -name '*.cpp' \
|
||||
-o -name '*.h' \
|
||||
-o -name '*.conf' \
|
||||
@@ -36,7 +38,7 @@ for f in *.po
|
||||
do
|
||||
echo "Merging $f"
|
||||
msgmerge \
|
||||
--no-location \
|
||||
--add-location=file \
|
||||
--no-wrap \
|
||||
--sort-output \
|
||||
--update \
|
||||
|
||||
@@ -84,6 +84,13 @@ public:
|
||||
"can then configure the bot for the channel so it fits "
|
||||
"your needs."
|
||||
));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry("#opers OperServ", _(
|
||||
"Assigns the \037OperServ\037 bot to \037#opers\037."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -150,6 +157,13 @@ public:
|
||||
"be able to reassign a bot later without having to reconfigure "
|
||||
"it entirely."
|
||||
));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry("#opers", _(
|
||||
"Unassigns a previously assigned bot from \037#opers\037."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ struct BadWordsImpl final
|
||||
|
||||
BadWordsImpl::~BadWordsImpl()
|
||||
{
|
||||
for (list::iterator it = badwords->begin(); it != badwords->end();)
|
||||
for (auto it = badwords->begin(); it != badwords->end();)
|
||||
{
|
||||
auto *bw = *it;
|
||||
++it;
|
||||
@@ -160,10 +160,10 @@ BadWordImpl::~BadWordImpl()
|
||||
ChannelInfo *ci = ChannelInfo::Find(chan);
|
||||
if (ci)
|
||||
{
|
||||
BadWordsImpl *badwords = ci->GetExt<BadWordsImpl>(BOTSERV_BAD_WORDS_EXT);
|
||||
auto *badwords = ci->GetExt<BadWordsImpl>(BOTSERV_BAD_WORDS_EXT);
|
||||
if (badwords)
|
||||
{
|
||||
BadWordsImpl::list::iterator it = std::find(badwords->badwords->begin(), badwords->badwords->end(), this);
|
||||
auto it = std::find(badwords->badwords->begin(), badwords->badwords->end(), this);
|
||||
if (it != badwords->badwords->end())
|
||||
badwords->badwords->erase(it);
|
||||
}
|
||||
@@ -172,28 +172,20 @@ BadWordImpl::~BadWordImpl()
|
||||
|
||||
Serializable *BadWordTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci, sword;
|
||||
|
||||
data["ci"] >> sci;
|
||||
data["word"] >> sword;
|
||||
|
||||
ChannelInfo *ci = ChannelInfo::Find(sci);
|
||||
auto *ci = ChannelInfo::Find(data.Load("ci"));
|
||||
if (!ci)
|
||||
return NULL;
|
||||
|
||||
Anope::string n;
|
||||
data["type"] >> n;
|
||||
|
||||
BadWordImpl *bw;
|
||||
if (obj)
|
||||
bw = anope_dynamic_static_cast<BadWordImpl *>(obj);
|
||||
else
|
||||
bw = new BadWordImpl();
|
||||
bw->chan = sci;
|
||||
bw->word = sword;
|
||||
bw->type = StringToType(n);
|
||||
bw->chan = ci->name;
|
||||
bw->word = data.Load("word");
|
||||
bw->type = StringToType(data.Load("type"));
|
||||
|
||||
BadWordsImpl *bws = ci->Require<BadWordsImpl>(BOTSERV_BAD_WORDS_EXT);
|
||||
auto *bws = ci->Require<BadWordsImpl>(BOTSERV_BAD_WORDS_EXT);
|
||||
if (!obj)
|
||||
bws->badwords->push_back(bw);
|
||||
|
||||
@@ -337,7 +329,7 @@ private:
|
||||
realword = word.substr(0, pos);
|
||||
}
|
||||
|
||||
unsigned badwordsmax = Config->GetModule(this->module).Get<unsigned>("badwordsmax");
|
||||
auto badwordsmax = Config->GetModule(this->module).Get<unsigned>("badwordsmax");
|
||||
if (badwords->GetBadWordCount() >= badwordsmax)
|
||||
{
|
||||
source.Reply(_("You can only have %d bad words entries on a channel."), badwordsmax);
|
||||
@@ -496,7 +488,7 @@ public:
|
||||
"\n\n"
|
||||
"The \002DEL\002 command removes the given word from the "
|
||||
"bad words list. If a list of entry numbers is given, those "
|
||||
"entries are deleted. (See the example for LIST below.)"
|
||||
"entries are deleted."
|
||||
"\n\n"
|
||||
"The \002LIST\002 command displays the bad words list. If "
|
||||
"a wildcard mask is given, only those entries matching the "
|
||||
@@ -509,14 +501,44 @@ public:
|
||||
source.service->GetQueryCommand("generic/help").c_str(),
|
||||
source.command.nobreak().c_str());
|
||||
|
||||
ExampleWrapper examples;
|
||||
examples.AddEntry("#channel LIST 2-5,7-9", _(
|
||||
"Lists bad word entries on \037#channel\037 numbered 2 through 5 and 7 through 9."
|
||||
));
|
||||
examples.AddEntry("#channel LIST *UwU*", _(
|
||||
"Lists bad word entries on \037#channel\037 that match \037*UwU*\037."
|
||||
));
|
||||
examples.SendTo(source);
|
||||
ExampleWrapper()
|
||||
.AddEntry("#channel ADD smeg", _(
|
||||
"Add \035smeg\035 to the bad word list of \035#channel\035. If a user says this "
|
||||
"word anywhere in a message they will be kicked."
|
||||
))
|
||||
.AddEntry("#channel ADD smeg SINGLE", _(
|
||||
"Add \035smeg\035 to the bad word list of \035#channel\035. If a user says only "
|
||||
"this word in a message they will be kicked."
|
||||
))
|
||||
.AddEntry("#channel ADD smeg START", _(
|
||||
"Add \035smeg\035 to the bad word list of \035#channel\035. If a user says this "
|
||||
"word at the start of a message they will be kicked."
|
||||
))
|
||||
.AddEntry("#channel ADD smeg END", _(
|
||||
"Add \035smeg\035 to the bad word list of \035#channel\035. If a user says this "
|
||||
"word at the start of a message they will be kicked."
|
||||
))
|
||||
.AddEntry("#channel CLEAR", _(
|
||||
"Clears all bad word entries set on \035#channel\035."
|
||||
))
|
||||
.AddEntry("#channel DEL 2-5,7-9", _(
|
||||
"Deletes bad word entries set on \035#channel\035 numbered 2 through 5 and 7 "
|
||||
"through 9."
|
||||
))
|
||||
.AddEntry("#channel DEL heck", _(
|
||||
"Deletes \035heck\035 from the bad word list of \035#channel\035."
|
||||
))
|
||||
.AddEntry("#channel LIST", _(
|
||||
"Lists all bad word entries set on \035#channel\035."
|
||||
))
|
||||
.AddEntry("#channel LIST 2-5,7-9", _(
|
||||
"Lists bad word entries set on \035#channel\035 numbered 2 through 5 and 7 through "
|
||||
"9."
|
||||
))
|
||||
.AddEntry("#channel LIST *frack*", _(
|
||||
"Lists bad word entries set on \035#channel\035 that match \035*frack*\035."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -351,8 +351,7 @@ public:
|
||||
"channels."
|
||||
"\n\n"
|
||||
"\002%s\033ADD\002 adds a bot with the given nickname, username, "
|
||||
"hostname and realname. Since no integrity checks are done "
|
||||
"for these settings, be really careful."
|
||||
"hostname and realname."
|
||||
"\n\n"
|
||||
"\002%s\033CHANGE\002 allows you to change the nickname, username, hostname "
|
||||
"or realname of a bot without deleting it (and "
|
||||
@@ -367,6 +366,25 @@ public:
|
||||
source.command.nobreak().c_str(),
|
||||
source.command.nobreak().c_str(),
|
||||
source.command.nobreak().c_str());
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry("ADD Chii chobit persocom.test Chii Motosuwa", _(
|
||||
"Adds a new bot with the nickname \035Chii\035, username \035chobit\035, hostname "
|
||||
"\035persocom.test\035, and realname \035Chii Motosuwa\035."
|
||||
))
|
||||
.AddEntry("CHANGE Elda Chii", _(
|
||||
"Renames an existing bot called \035Elda\035 to \035Chii\035."
|
||||
))
|
||||
.AddEntry("CHANGE Chii Mahoro saint vesper.test Mahoro Andou", _(
|
||||
"Changes all of the information of the bot called \035Chii\035. The new nickname "
|
||||
"will be \035Mahoro\035, the new username will be \035saint\035, the new hostname "
|
||||
"will be \035vesper.test\035, and the new realname will be \035Mahoro Andou\035."
|
||||
))
|
||||
.AddEntry("DEL Mahoro", _(
|
||||
"Deletes a bot called \035Mahoro\035."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -71,6 +71,13 @@ public:
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Makes the bot say the specified text on the specified channel."));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry(_("#chat hello all"), _(
|
||||
"Sends a message to \035#chat\035 saying \035hello all\035."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -126,9 +133,16 @@ public:
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Makes the bot do the equivalent of a \"/me\" command "
|
||||
"on the specified channel using the specified text."
|
||||
"Makes the bot do the equivalent of a \"/me\" command on the specified channel using "
|
||||
"the specified text."
|
||||
));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry(_("#chat is eating pizza"), _(
|
||||
"Sends an action message to \035#chat\035 saying \035is eating pizza\035."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -104,6 +104,17 @@ public:
|
||||
"you'll get information about a bot, such as creation "
|
||||
"time or number of channels it is on."
|
||||
), source.service->nick.c_str());
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry("#example", _(
|
||||
"Shows information about the bot assigned to \035#example\035 and its kickers and "
|
||||
"options."
|
||||
))
|
||||
.AddEntry("ChanServ", _(
|
||||
"Shows information about the \035ChanServ\035 bot."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+28
-26
@@ -51,7 +51,7 @@ struct KickerDataImpl final
|
||||
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
|
||||
return;
|
||||
|
||||
const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(e);
|
||||
const auto *ci = anope_dynamic_static_cast<const ChannelInfo *>(e);
|
||||
auto *kd = this->Get(ci);
|
||||
if (kd == NULL)
|
||||
return;
|
||||
@@ -85,33 +85,35 @@ struct KickerDataImpl final
|
||||
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
|
||||
return;
|
||||
|
||||
ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(e);
|
||||
auto *ci = anope_dynamic_static_cast<ChannelInfo *>(e);
|
||||
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
|
||||
|
||||
data["kickerdata:amsgs"] >> kd->amsgs;
|
||||
data["kickerdata:badwords"] >> kd->badwords;
|
||||
data["kickerdata:bolds"] >> kd->bolds;
|
||||
data["kickerdata:caps"] >> kd->caps;
|
||||
data["kickerdata:colors"] >> kd->colors;
|
||||
data["kickerdata:flood"] >> kd->flood;
|
||||
data["kickerdata:italics"] >> kd->italics;
|
||||
data["kickerdata:repeat"] >> kd->repeat;
|
||||
data["kickerdata:reverses"] >> kd->reverses;
|
||||
data["kickerdata:underlines"] >> kd->underlines;
|
||||
kd->amsgs = data.Load<bool>("kickerdata:amsgs");
|
||||
kd->badwords = data.Load<bool>("kickerdata:badwords");
|
||||
kd->bolds = data.Load<bool>("kickerdata:bolds");
|
||||
kd->caps = data.Load<bool>("kickerdata:caps");
|
||||
kd->colors = data.Load<bool>("kickerdata:colors");
|
||||
kd->flood = data.Load<bool>("kickerdata:flood");
|
||||
kd->italics = data.Load<bool>("kickerdata:italics");
|
||||
kd->repeat = data.Load<bool>("kickerdata:repeat");
|
||||
kd->reverses = data.Load<bool>("kickerdata:reverses");
|
||||
kd->underlines = data.Load<bool>("kickerdata:underlines");
|
||||
|
||||
data["capsmin"] >> kd->capsmin;
|
||||
data["capspercent"] >> kd->capspercent;
|
||||
data["floodlines"] >> kd->floodlines;
|
||||
data["floodsecs"] >> kd->floodsecs;
|
||||
data["repeattimes"] >> kd->repeattimes;
|
||||
data["dontkickops"] >> kd->dontkickops;
|
||||
data["dontkickvoices"] >> kd->dontkickvoices;
|
||||
kd->capsmin = data.Load<int16_t>("capsmin");
|
||||
kd->capspercent = data.Load<int16_t>("capspercent");
|
||||
kd->floodlines = data.Load<int16_t>("floodlines");
|
||||
kd->floodsecs = data.Load<int16_t>("floodsecs");
|
||||
kd->repeattimes = data.Load<int16_t>("repeattimes");
|
||||
kd->dontkickops = data.Load<bool>("dontkickops");
|
||||
kd->dontkickvoices = data.Load<bool>("dontkickvoices");
|
||||
|
||||
Anope::string ttb, tok;
|
||||
data["ttb"] >> ttb;
|
||||
spacesepstream sep(ttb);
|
||||
for (int i = 0; sep.GetToken(tok) && i < BotServ::TTB_SIZE; ++i)
|
||||
spacesepstream sep(data.Load("ttb"));
|
||||
for (size_t i = 0; i < BotServ::TTB_SIZE; ++i)
|
||||
{
|
||||
Anope::string tok;
|
||||
if (!sep.GetToken(tok))
|
||||
break;
|
||||
|
||||
if (auto n = Anope::TryConvert<int16_t>(tok))
|
||||
kd->ttb[i] = n.value();
|
||||
}
|
||||
@@ -988,7 +990,7 @@ public:
|
||||
void purge()
|
||||
{
|
||||
time_t keepdata = Config->GetModule(me).Get<time_t>("keepdata");
|
||||
for (data_type::iterator it = data_map.begin(), it_end = data_map.end(); it != it_end;)
|
||||
for (auto it = data_map.begin(), it_end = data_map.end(); it != it_end;)
|
||||
{
|
||||
const Anope::string &user = it->first;
|
||||
Data &bd = it->second;
|
||||
@@ -1038,7 +1040,7 @@ public:
|
||||
|
||||
for (auto &[_, c] : ChannelList)
|
||||
{
|
||||
BanData *bd = c->GetExt<BanData>("bandata");
|
||||
auto *bd = c->GetExt<BanData>("bandata");
|
||||
if (bd != NULL)
|
||||
{
|
||||
bd->purge();
|
||||
@@ -1488,7 +1490,7 @@ public:
|
||||
|
||||
if (ud->lastline.equals_ci(realbuf) && !ud->lasttarget.empty() && !ud->lasttarget.equals_ci(ci->name))
|
||||
{
|
||||
for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end();)
|
||||
for (auto it = u->chans.begin(); it != u->chans.end();)
|
||||
{
|
||||
Channel *chan = it->second->chan;
|
||||
++it;
|
||||
|
||||
@@ -166,6 +166,13 @@ public:
|
||||
"be removed after the given time. Set to 0 to disable bans from "
|
||||
"automatically expiring."
|
||||
));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry("#wibble 15m", _(
|
||||
"Sets bot bans on \035#wibble\035 to expire after \03515 minutes\035."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,7 +357,7 @@ public:
|
||||
if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly)
|
||||
return;
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; )
|
||||
for (auto it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; )
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
++it;
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
if (ci->c)
|
||||
{
|
||||
time_t last_used = ci->last_used;
|
||||
for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->last_used; ++cit)
|
||||
for (auto cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->last_used; ++cit)
|
||||
ci->AccessFor(cit->second->user);
|
||||
expire = last_used == ci->last_used;
|
||||
}
|
||||
@@ -397,11 +397,10 @@ public:
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
void OnUplinkSync(Server* s) override
|
||||
void OnUplinkSync(Server *s) override
|
||||
{
|
||||
// We need to do this when the uplink is synced as we may not know if
|
||||
// the mode exists before then on some IRCds (e.g. InspIRCd).
|
||||
|
||||
if (!persist)
|
||||
return;
|
||||
|
||||
|
||||
@@ -23,6 +23,17 @@ static inline void reset_levels(ChannelInfo *ci)
|
||||
ci->SetLevel(priv, level);
|
||||
}
|
||||
|
||||
static Anope::string LevelToString(CommandSource &source, int16_t level)
|
||||
{
|
||||
if (level == ACCESS_INVALID)
|
||||
return Language::Translate(source.GetAccount(), _("(disabled)"));
|
||||
|
||||
if (level == ACCESS_FOUNDER)
|
||||
return Language::Translate(source.GetAccount(), _("(founder only)"));
|
||||
|
||||
return Anope::ToString(level);
|
||||
}
|
||||
|
||||
class AccessChanAccess final
|
||||
: public ChanAccess
|
||||
{
|
||||
@@ -276,7 +287,7 @@ private:
|
||||
ServiceReference<AccessProvider> provider("AccessProvider", "access/access");
|
||||
if (!provider)
|
||||
return;
|
||||
AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create());
|
||||
auto *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create());
|
||||
access->SetMask(mask, ci);
|
||||
access->creator = source.GetNick();
|
||||
access->level = level;
|
||||
@@ -285,7 +296,7 @@ private:
|
||||
access->description = description;
|
||||
ci->AddAccess(access);
|
||||
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, access));
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, access, false));
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level;
|
||||
if (p != NULL)
|
||||
@@ -376,7 +387,7 @@ private:
|
||||
|
||||
ci->EraseAccess(Number - 1);
|
||||
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, access));
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, access, false));
|
||||
delete access;
|
||||
}
|
||||
}
|
||||
@@ -402,7 +413,7 @@ private:
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->Mask();
|
||||
|
||||
ci->EraseAccess(i - 1);
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, access));
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, access, false));
|
||||
delete access;
|
||||
}
|
||||
return;
|
||||
@@ -416,6 +427,8 @@ private:
|
||||
void ProcessList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms, ListFormatter &list)
|
||||
{
|
||||
const Anope::string &nick = params.size() > 2 ? params[2] : "";
|
||||
const auto show_all = params.size() > 3 && params[3].equals_ci("ALL");
|
||||
unsigned foreign = 0;
|
||||
|
||||
if (!ci->GetAccessCount())
|
||||
source.Reply(_("%s access list is empty."), ci->name.c_str());
|
||||
@@ -426,9 +439,16 @@ private:
|
||||
{
|
||||
ListFormatter &list;
|
||||
ChannelInfo *ci;
|
||||
bool show_all;
|
||||
unsigned &foreign;
|
||||
|
||||
public:
|
||||
AccessListCallback(ListFormatter &_list, ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), list(_list), ci(_ci)
|
||||
AccessListCallback(ListFormatter &_list, ChannelInfo *_ci, const Anope::string &numlist, bool _show_all, unsigned &_foreign)
|
||||
: NumberList(numlist, false)
|
||||
, list(_list)
|
||||
, ci(_ci)
|
||||
, show_all(_show_all)
|
||||
, foreign(_foreign)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -438,11 +458,16 @@ private:
|
||||
return;
|
||||
|
||||
const ChanAccess *access = ci->GetAccess(number - 1);
|
||||
if (!show_all && access->provider->name != "access/access")
|
||||
{
|
||||
foreign++;
|
||||
return;
|
||||
}
|
||||
|
||||
AddEntry(this->list, ci, access, number);
|
||||
}
|
||||
}
|
||||
nl_list(list, ci, nick);
|
||||
nl_list(list, ci, nick, show_all, foreign);
|
||||
nl_list.Process();
|
||||
}
|
||||
else
|
||||
@@ -454,6 +479,12 @@ private:
|
||||
if (!nick.empty() && !Anope::Match(access->Mask(), nick))
|
||||
continue;
|
||||
|
||||
if (!show_all && access->provider->name != "access/access")
|
||||
{
|
||||
foreign++;
|
||||
continue;
|
||||
}
|
||||
|
||||
AddEntry(list, ci, access, i + 1);
|
||||
}
|
||||
}
|
||||
@@ -466,6 +497,14 @@ private:
|
||||
list.SendTo(source);
|
||||
source.Reply(_("End of access list"));
|
||||
}
|
||||
|
||||
if (foreign)
|
||||
{
|
||||
const auto full_command = Anope::Format("%s %s %s %s", source.command.c_str(),
|
||||
ci->name.c_str(), params[1].upper().c_str(), nick.empty() ? "*" : nick.c_str()).nobreak();
|
||||
|
||||
source.Reply(foreign, CHAN_ACCESS_FOREIGN, foreign, full_command.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
@@ -531,8 +570,8 @@ public:
|
||||
this->SetDesc(_("Modify the list of privileged users"));
|
||||
this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037 [\037description\037]"));
|
||||
this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
|
||||
this->SetSyntax(_("\037channel\037 VIEW [\037mask\037 | \037list\037]"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037] [ALL]"));
|
||||
this->SetSyntax(_("\037channel\037 VIEW [\037mask\037 | \037list\037] [ALL]"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
@@ -635,7 +674,8 @@ public:
|
||||
"The \002%s\033LIST\002 command displays the access list. If "
|
||||
"a wildcard mask is given, only those entries matching the "
|
||||
"mask are displayed. If a list of entry numbers is given, "
|
||||
"only those entries are shown."
|
||||
"only those entries are shown. The \002ALL\002 option allows "
|
||||
"listing entries from other access systems as well as levels."
|
||||
"\n\n"
|
||||
"The \002%s\033VIEW\002 command displays the access list similar "
|
||||
"to \002%s\033LIST\002 but shows the creator and last used time."
|
||||
@@ -660,7 +700,7 @@ public:
|
||||
|
||||
BotInfo *bi;
|
||||
Anope::string cmd;
|
||||
if (Command::FindCommandFromService("chanserv/levels", bi, cmd))
|
||||
if (Command::FindFromService("chanserv/levels", bi, cmd))
|
||||
{
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
@@ -768,14 +808,7 @@ class CommandCSLevels final
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Name"] = p.name;
|
||||
|
||||
if (j == ACCESS_INVALID)
|
||||
entry["Level"] = Language::Translate(source.GetAccount(), _("(disabled)"));
|
||||
else if (j == ACCESS_FOUNDER)
|
||||
entry["Level"] = Language::Translate(source.GetAccount(), _("(founder only)"));
|
||||
else
|
||||
entry["Level"] = Anope::ToString(j);
|
||||
|
||||
entry["Level"] = LevelToString(source, j);
|
||||
list.AddEntry(entry);
|
||||
}
|
||||
|
||||
@@ -852,13 +885,14 @@ public:
|
||||
source.Reply(_("The following feature/function names are available:"));
|
||||
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn(_("Name")).AddColumn(_("Description"));
|
||||
list.SetFlexible(_("\002{name}\002: {description}"));
|
||||
list.AddColumn(_("Name")).AddColumn(_("Default")).AddColumn(_("Description"));
|
||||
list.SetFlexible(_("\002{name}\002: defaults to {default} ({description})"));
|
||||
|
||||
for (const auto &p : PrivilegeManager::GetPrivileges())
|
||||
{
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Name"] = p.name;
|
||||
entry["Default"] = LevelToString(source, defaultLevels[p.name]);
|
||||
entry["Description"] = Language::Translate(source.nc, p.desc.c_str());
|
||||
list.AddEntry(entry);
|
||||
}
|
||||
@@ -960,7 +994,7 @@ public:
|
||||
/* Access accessprovider is the only accessprovider with the concept of negative access,
|
||||
* so check they don't have negative access
|
||||
*/
|
||||
const AccessChanAccess *aca = anope_dynamic_static_cast<const AccessChanAccess *>(highest);
|
||||
const auto *aca = anope_dynamic_static_cast<const AccessChanAccess *>(highest);
|
||||
|
||||
if (aca->level < 0)
|
||||
return EVENT_CONTINUE;
|
||||
|
||||
@@ -143,46 +143,34 @@ struct AutoKickType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string sci, snc;
|
||||
uint64_t sncid = 0;
|
||||
|
||||
data["ci"] >> sci;
|
||||
data["nc"] >> snc; // Deprecated 2.0 field
|
||||
data["ncid"] >> sncid;
|
||||
|
||||
ChannelInfo *ci = ChannelInfo::Find(sci);
|
||||
auto *ci = ChannelInfo::Find(data.Load("ci"));
|
||||
if (!ci)
|
||||
return NULL;
|
||||
|
||||
const auto sncid = data.Load<uint64_t>("ncid");
|
||||
auto *nc = sncid ? NickCore::FindId(sncid) : NickCore::Find(data.Load("nc"));
|
||||
|
||||
const auto screator = data.Load("creator");
|
||||
const auto smask = data.Load("mask");
|
||||
const auto sreason = data.Load("reason");
|
||||
const auto saddtime = data.Load<time_t>("addtime");
|
||||
const auto slastused = data.Load<time_t>("last_used");
|
||||
|
||||
ChanServ::AutoKick *ak;
|
||||
auto *nc = sncid ? NickCore::FindId(sncid) : NickCore::Find(snc);
|
||||
if (obj)
|
||||
{
|
||||
ak = anope_dynamic_static_cast<ChanServ::AutoKick *>(obj);
|
||||
data["creator"] >> ak->creator;
|
||||
data["reason"] >> ak->reason;
|
||||
ak->creator = screator;
|
||||
ak->reason = sreason;
|
||||
ak->nc = nc;
|
||||
data["mask"] >> ak->mask;
|
||||
data["addtime"] >> ak->addtime;
|
||||
data["last_used"] >> ak->last_used;
|
||||
ak->mask = smask;
|
||||
ak->addtime = saddtime;
|
||||
ak->last_used = slastused;
|
||||
}
|
||||
else if (nc)
|
||||
ak = ChanServ::akick_service->AddAKick(ci, screator, nc, sreason, saddtime, slastused);
|
||||
else
|
||||
{
|
||||
time_t addtime, lastused;
|
||||
data["addtime"] >> addtime;
|
||||
data["last_used"] >> lastused;
|
||||
|
||||
Anope::string screator, sreason, smask;
|
||||
|
||||
data["creator"] >> screator;
|
||||
data["reason"] >> sreason;
|
||||
data["mask"] >> smask;
|
||||
|
||||
if (nc)
|
||||
ak = ChanServ::akick_service->AddAKick(ci, screator, nc, sreason, addtime, lastused);
|
||||
else
|
||||
ak = ChanServ::akick_service->AddAKick(ci, screator, smask, sreason, addtime, lastused);
|
||||
}
|
||||
ak = ChanServ::akick_service->AddAKick(ci, screator, smask, sreason, saddtime, slastused);
|
||||
|
||||
return ak;
|
||||
}
|
||||
@@ -201,7 +189,7 @@ class CommandCSAKick final
|
||||
return;
|
||||
}
|
||||
|
||||
for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
for (auto it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
{
|
||||
auto *memb = it->second;
|
||||
++it;
|
||||
@@ -223,7 +211,7 @@ class CommandCSAKick final
|
||||
const NickAlias *na = NickAlias::Find(mask);
|
||||
NickCore *nc = NULL;
|
||||
const ChanServ::AutoKick *akick;
|
||||
unsigned reasonmax = Config->GetModule("chanserv").Get<unsigned>("reasonmax", "200");
|
||||
auto reasonmax = Config->GetModule("chanserv").Get<unsigned>("reasonmax", "200");
|
||||
|
||||
if (reason.length() > reasonmax)
|
||||
reason = reason.substr(0, reasonmax);
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
reason += " " + params[3];
|
||||
}
|
||||
|
||||
unsigned reasonmax = Config->GetModule("chanserv").Get<unsigned>("reasonmax", "200");
|
||||
auto reasonmax = Config->GetModule("chanserv").Get<unsigned>("reasonmax", "200");
|
||||
if (reason.length() > reasonmax)
|
||||
reason = reason.substr(0, reasonmax);
|
||||
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
}
|
||||
|
||||
int matched = 0, kicked = 0;
|
||||
for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;)
|
||||
for (auto it = c->users.begin(), it_end = c->users.end(); it != it_end;)
|
||||
{
|
||||
auto *memb = it->second;
|
||||
++it;
|
||||
|
||||
@@ -28,7 +28,7 @@ class CommandCSClone final
|
||||
static void CopyAccess(CommandSource &source, ChannelInfo *ci, ChannelInfo *target_ci)
|
||||
{
|
||||
std::set<Anope::string> masks;
|
||||
unsigned access_max = Config->GetModule("chanserv").Get<unsigned>("accessmax", "1000");
|
||||
auto access_max = Config->GetModule("chanserv").Get<unsigned>("accessmax", "1000");
|
||||
unsigned count = 0;
|
||||
|
||||
for (unsigned i = 0; i < target_ci->GetAccessCount(); ++i)
|
||||
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
|
||||
std::vector<User *> users;
|
||||
/* The newer users are at the end of the list, so kick users starting from the end */
|
||||
for (Channel::ChanUserList::reverse_iterator it = ci->c->users.rbegin(), it_end = ci->c->users.rend(); it != it_end; ++it)
|
||||
for (auto it = ci->c->users.rbegin(), it_end = ci->c->users.rend(); it != it_end; ++it)
|
||||
{
|
||||
auto *memb = it->second;
|
||||
User *user = memb->user;
|
||||
|
||||
@@ -85,31 +85,24 @@ EntryMsgImpl::~EntryMsgImpl()
|
||||
|
||||
Serializable *EntryMsgTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci, screator, smessage;
|
||||
time_t swhen;
|
||||
|
||||
data["ci"] >> sci;
|
||||
data["creator"] >> screator;
|
||||
data["message"] >> smessage;
|
||||
|
||||
ChannelInfo *ci = ChannelInfo::Find(sci);
|
||||
auto *ci = ChannelInfo::Find(data.Load("ci"));
|
||||
if (!ci)
|
||||
return NULL;
|
||||
|
||||
const auto screator = data.Load("creator");
|
||||
const auto smessage = data.Load("message");
|
||||
const auto swhen = data.Load<time_t>("when");
|
||||
if (obj)
|
||||
{
|
||||
EntryMsgImpl *msg = anope_dynamic_static_cast<EntryMsgImpl *>(obj);
|
||||
auto *msg = anope_dynamic_static_cast<EntryMsgImpl *>(obj);
|
||||
msg->chan = ci->name;
|
||||
data["creator"] >> msg->creator;
|
||||
data["message"] >> msg->message;
|
||||
data["when"] >> msg->when;
|
||||
msg->creator = screator;
|
||||
msg->message = smessage;
|
||||
msg->when = swhen;
|
||||
return msg;
|
||||
}
|
||||
|
||||
auto *messages = ci->Require<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
|
||||
|
||||
data["when"] >> swhen;
|
||||
|
||||
auto *m = new EntryMsgImpl(ci, screator, smessage, swhen);
|
||||
(*messages)->push_back(m);
|
||||
return m;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
bool HasPriv(const Anope::string &priv) const override
|
||||
{
|
||||
std::map<Anope::string, char>::iterator it = defaultFlags.find(priv);
|
||||
auto it = defaultFlags.find(priv);
|
||||
return it != defaultFlags.end() && this->flags.count(it->second) > 0;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ class CommandCSFlags final
|
||||
if (current != NULL)
|
||||
{
|
||||
ci->EraseAccess(current_idx - 1);
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, current));
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, current, false));
|
||||
delete current;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask;
|
||||
source.Reply(_("\002%s\002 removed from the %s access list."), mask.c_str(), ci->name.c_str());
|
||||
@@ -301,7 +301,7 @@ class CommandCSFlags final
|
||||
ServiceReference<AccessProvider> provider("AccessProvider", "access/flags");
|
||||
if (!provider)
|
||||
return;
|
||||
FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
|
||||
auto *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
|
||||
access->SetMask(mask, ci);
|
||||
access->creator = source.GetNick();
|
||||
access->description = current ? current->description : description;
|
||||
@@ -314,7 +314,7 @@ class CommandCSFlags final
|
||||
|
||||
ci->AddAccess(access);
|
||||
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, access));
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, access, false));
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize();
|
||||
if (p != NULL)
|
||||
@@ -331,6 +331,7 @@ class CommandCSFlags final
|
||||
static void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
const Anope::string &arg = params.size() > 2 ? params[2] : "";
|
||||
const auto show_all = params.size() > 3 && params[3].equals_ci("ALL");
|
||||
|
||||
if (!ci->GetAccessCount())
|
||||
{
|
||||
@@ -348,6 +349,7 @@ class CommandCSFlags final
|
||||
});
|
||||
|
||||
unsigned count = 0;
|
||||
unsigned foreign = 0;
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
{
|
||||
const ChanAccess *access = ci->GetAccess(i);
|
||||
@@ -368,6 +370,12 @@ class CommandCSFlags final
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!show_all && access->provider->name != "access/flags")
|
||||
{
|
||||
foreign++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
++count;
|
||||
entry["Number"] = Anope::ToString(i + 1);
|
||||
@@ -390,6 +398,88 @@ class CommandCSFlags final
|
||||
else
|
||||
source.Reply(_("End of access list - %d/%d entries shown."), count, ci->GetAccessCount());
|
||||
}
|
||||
|
||||
if (foreign)
|
||||
{
|
||||
const auto full_command = Anope::Format("%s %s LIST %s", source.command.c_str(),
|
||||
ci->name.c_str(), arg.empty() ? "*" : arg.c_str()).nobreak();
|
||||
|
||||
source.Reply(foreign, CHAN_ACCESS_FOREIGN, foreign, full_command.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void DoMigrate(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
auto override = false;
|
||||
const auto source_access = source.AccessFor(ci);
|
||||
|
||||
unsigned migrated = 0, notmigrated = 0;
|
||||
Anope::string migratedmask, notmigratedmask;
|
||||
const auto &entry = params.size() > 2 ? params[2] : "*";
|
||||
for (auto idx = ci->GetAccessCount(); idx > 0; --idx)
|
||||
{
|
||||
auto *access = ci->GetAccess(idx - 1);
|
||||
if (access->provider->name == "access/flags")
|
||||
continue; // Already using flags.
|
||||
|
||||
if (!Anope::Match(access->Mask(), entry))
|
||||
continue; // Not this entry.
|
||||
|
||||
std::set<char> newflags;
|
||||
for (auto &[priv, flag] : defaultFlags)
|
||||
{
|
||||
if (access->HasPriv(priv))
|
||||
continue; // Source doesn't have this flag.
|
||||
|
||||
// Check that the source has access to set this entry.
|
||||
if (!override && !source_access.HasPriv(priv) && !source_access.founder)
|
||||
{
|
||||
if (!source.HasPriv("chanserv/access/modify"))
|
||||
{
|
||||
notmigrated++;
|
||||
notmigratedmask = access->Mask();
|
||||
continue; // No privs
|
||||
}
|
||||
|
||||
override = true;
|
||||
}
|
||||
|
||||
newflags.insert(flag);
|
||||
}
|
||||
|
||||
migrated++;
|
||||
migratedmask = access->Mask();
|
||||
|
||||
auto *newaccess = anope_dynamic_static_cast<FlagsChanAccess *>(FlagsAccessProvider::ap->Create());
|
||||
newaccess->SetMask(access->Mask(), ci);
|
||||
newaccess->creator = access->creator;
|
||||
newaccess->description = access->description;
|
||||
newaccess->created = access->created;
|
||||
newaccess->flags = newflags;
|
||||
|
||||
ci->EraseAccess(idx - 1);
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, access, true));
|
||||
delete access;
|
||||
|
||||
ci->AddAccess(newaccess);
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, newaccess, true));
|
||||
}
|
||||
|
||||
if (migrated == 1)
|
||||
{
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to migrate " << migratedmask;
|
||||
source.Reply(CHAN_ACCESS_MIGRATED_1, migratedmask.c_str(), source.command.nobreak().c_str());
|
||||
}
|
||||
else if (migrated > 1)
|
||||
{
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to migrate " << migrated << " access entries";
|
||||
source.Reply(migrated, CHAN_ACCESS_MIGRATED_N, migrated, source.command.nobreak().c_str());
|
||||
}
|
||||
|
||||
if (notmigrated == 1)
|
||||
source.Reply(CHAN_ACCESS_NOT_MIGRATED_1, notmigratedmask.c_str(), source.command.nobreak().c_str());
|
||||
else if (notmigrated > 1)
|
||||
source.Reply(migrated, CHAN_ACCESS_NOT_MIGRATED_N, notmigrated, source.command.nobreak().c_str());
|
||||
}
|
||||
|
||||
void DoClear(CommandSource &source, ChannelInfo *ci)
|
||||
@@ -414,7 +504,8 @@ public:
|
||||
{
|
||||
this->SetDesc(_("Modify the list of privileged users"));
|
||||
this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037 [\037description\037]"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | +\037flags\037]"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | +\037flags\037] [ALL]"));
|
||||
this->SetSyntax(_("\037channel\037 MIGRATE [\037mask\037]"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
@@ -447,6 +538,8 @@ public:
|
||||
source.Reply(READ_ONLY_MODE);
|
||||
else if (is_list)
|
||||
this->DoList(source, ci, params);
|
||||
else if (cmd.equals_ci("MIGRATE"))
|
||||
this->DoMigrate(source, ci, params);
|
||||
else if (cmd.equals_ci("CLEAR"))
|
||||
this->DoClear(source, ci);
|
||||
else
|
||||
@@ -487,7 +580,8 @@ public:
|
||||
"The \002LIST\002 command allows you to list existing entries on the channel access list. "
|
||||
"If a mask is given, the mask is wildcard matched against all existing entries on the "
|
||||
"access list, and only those entries are returned. If a set of flags is given, only those "
|
||||
"on the access list with the specified flags are returned."
|
||||
"on the access list with the specified flags are returned. The \002ALL\002 option allows "
|
||||
"listing entries from other access systems as well as flags."
|
||||
"\n\n"
|
||||
"The \002CLEAR\002 command clears the channel access list. This requires channel founder access."
|
||||
"\n\n"
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned reasonmax = Config->GetModule("chanserv").Get<unsigned>("reasonmax", "200");
|
||||
auto reasonmax = Config->GetModule("chanserv").Get<unsigned>("reasonmax", "200");
|
||||
if (reason.length() > reasonmax)
|
||||
reason = reason.substr(0, reasonmax);
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
Log(LOG_COMMAND, source, this, ci) << "for " << mask;
|
||||
|
||||
int matched = 0, kicked = 0;
|
||||
for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;)
|
||||
for (auto it = c->users.begin(), it_end = c->users.end(); it != it_end;)
|
||||
{
|
||||
auto *memb = it->second;
|
||||
++it;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
}
|
||||
|
||||
Anope::string spattern = "#" + pattern;
|
||||
unsigned listmax = Config->GetModule(this->owner).Get<unsigned>("listmax", "50");
|
||||
auto listmax = Config->GetModule(this->owner).Get<unsigned>("listmax", "50");
|
||||
|
||||
source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str());
|
||||
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
|
||||
BotInfo *bi;
|
||||
Anope::string cmd;
|
||||
if (Command::FindCommandFromService("chanserv/list", bi, cmd))
|
||||
if (Command::FindFromService("chanserv/list", bi, cmd))
|
||||
{
|
||||
source.Reply(_("When \002private\002 is set, the channel will not appear in %s's %s command."),
|
||||
bi->nick.c_str(), cmd.c_str());
|
||||
|
||||
@@ -64,10 +64,7 @@ struct LogSettingTypeImpl final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string sci;
|
||||
data["ci"] >> sci;
|
||||
|
||||
ChannelInfo *ci = ChannelInfo::Find(sci);
|
||||
auto *ci = ChannelInfo::Find(data.Load("ci"));
|
||||
if (ci == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -82,13 +79,13 @@ struct LogSettingTypeImpl final
|
||||
}
|
||||
|
||||
ls->chan = ci->name;
|
||||
data["service_name"] >> ls->service_name;
|
||||
data["command_service"] >> ls->command_service;
|
||||
data["command_name"] >> ls->command_name;
|
||||
data["method"] >> ls->method;
|
||||
data["extra"] >> ls->extra;
|
||||
data["creator"] >> ls->creator;
|
||||
data["created"] >> ls->created;
|
||||
ls->service_name = data.Load("service_name");
|
||||
ls->command_service = data.Load("command_service");
|
||||
ls->command_name = data.Load("command_name");
|
||||
ls->method = data.Load("method");
|
||||
ls->extra = data.Load("extra");
|
||||
ls->creator = data.Load("creator");
|
||||
ls->created = data.Load<time_t>("created");
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
@@ -270,11 +270,7 @@ void ModeLockTypeImpl::Serialize(Serializable *obj, Serialize::Data &data) const
|
||||
|
||||
Serializable *ModeLockTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci;
|
||||
|
||||
data["ci"] >> sci;
|
||||
|
||||
ChannelInfo *ci = ChannelInfo::Find(sci);
|
||||
auto *ci = ChannelInfo::Find(data.Load("ci"));
|
||||
if (!ci)
|
||||
return NULL;
|
||||
|
||||
@@ -287,11 +283,11 @@ Serializable *ModeLockTypeImpl::Unserialize(Serializable *obj, Serialize::Data &
|
||||
ml->ci = ci->name;
|
||||
}
|
||||
|
||||
data["set"] >> ml->set;
|
||||
data["created"] >> ml->created;
|
||||
data["setter"] >> ml->setter;
|
||||
data["name"] >> ml->name;
|
||||
data["param"] >> ml->param;
|
||||
ml->set = data.Load<bool>("set");
|
||||
ml->created = data.Load<time_t>("created");
|
||||
ml->setter = data.Load("setter");
|
||||
ml->name = data.Load("name");
|
||||
ml->param = data.Load("param");
|
||||
|
||||
if (!obj)
|
||||
ci->Require<ModeLocksImpl>(CHANSERV_MODE_LOCK_EXT)->mlocks->push_back(ml);
|
||||
@@ -601,7 +597,7 @@ class CommandCSMode final
|
||||
}
|
||||
}
|
||||
|
||||
for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end;)
|
||||
for (auto it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end;)
|
||||
{
|
||||
auto *memb = it->second;
|
||||
++it;
|
||||
@@ -1102,7 +1098,7 @@ public:
|
||||
Anope::string param;
|
||||
if (cm->type == MODE_PARAM)
|
||||
{
|
||||
ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
|
||||
auto *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
|
||||
if (add || !cmp->minus_no_arg)
|
||||
{
|
||||
sep.GetToken(param);
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &chdesc = params.size() > 1 ? params[1] : "";
|
||||
unsigned maxregistered = Config->GetModule("chanserv").Get<unsigned>("maxregistered");
|
||||
auto maxregistered = Config->GetModule("chanserv").Get<unsigned>("maxregistered");
|
||||
|
||||
User *u = source.GetUser();
|
||||
NickCore *nc = source.nc;
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
|
||||
BotInfo *bi;
|
||||
Anope::string cmd;
|
||||
if (Command::FindCommandFromService("chanserv/access", bi, cmd))
|
||||
if (Command::FindFromService("chanserv/access", bi, cmd))
|
||||
{
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
|
||||
@@ -41,7 +41,7 @@ struct SeenInfo final
|
||||
|
||||
~SeenInfo() override
|
||||
{
|
||||
database_map::iterator iter = database.find(nick);
|
||||
auto iter = database.find(nick);
|
||||
if (iter != database.end() && iter->second == this)
|
||||
database.erase(iter);
|
||||
}
|
||||
@@ -111,9 +111,7 @@ struct SeenInfoType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snick;
|
||||
|
||||
data["nick"] >> snick;
|
||||
const auto snick = data.Load("nick");
|
||||
|
||||
SeenInfo *s;
|
||||
if (obj)
|
||||
@@ -127,14 +125,12 @@ struct SeenInfoType final
|
||||
}
|
||||
|
||||
s->nick = snick;
|
||||
data["vhost"] >> s->vhost;
|
||||
Anope::string n;
|
||||
data["type"] >> n;
|
||||
s->type = StringToType(n);
|
||||
data["nick2"] >> s->nick2;
|
||||
data["channel"] >> s->channel;
|
||||
data["message"] >> s->message;
|
||||
data["last"] >> s->last;
|
||||
s->vhost = data.Load("vhost");
|
||||
s->type = StringToType(data.Load("type"));
|
||||
s->nick2 = data.Load("nick2");
|
||||
s->channel = data.Load("channel");
|
||||
s->message = data.Load("message");
|
||||
s->last = data.Load<time_t>("last");
|
||||
|
||||
if (!obj)
|
||||
database[s->nick] = s;
|
||||
@@ -144,7 +140,7 @@ struct SeenInfoType final
|
||||
|
||||
static SeenInfo *FindInfo(const Anope::string &nick)
|
||||
{
|
||||
database_map::iterator iter = database.find(nick);
|
||||
auto iter = database.find(nick);
|
||||
if (iter != database.end())
|
||||
return iter->second;
|
||||
return NULL;
|
||||
@@ -203,7 +199,7 @@ public:
|
||||
time = Anope::CurTime - time;
|
||||
database_map::iterator buf;
|
||||
size_t counter = 0;
|
||||
for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;)
|
||||
for (auto it = database.begin(), it_end = database.end(); it != it_end;)
|
||||
{
|
||||
buf = it;
|
||||
++it;
|
||||
@@ -379,9 +375,9 @@ public:
|
||||
return;
|
||||
|
||||
auto previous_size = database.size();
|
||||
for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;)
|
||||
for (auto it = database.begin(), it_end = database.end(); it != it_end;)
|
||||
{
|
||||
database_map::iterator cur = it;
|
||||
auto cur = it;
|
||||
++it;
|
||||
|
||||
if ((Anope::CurTime - cur->second->last) > purgetime)
|
||||
|
||||
@@ -320,7 +320,7 @@ public:
|
||||
}
|
||||
|
||||
NickCore *nc = na->nc;
|
||||
unsigned max_reg = Config->GetModule("chanserv").Get<unsigned>("maxregistered");
|
||||
auto max_reg = Config->GetModule("chanserv").Get<unsigned>("maxregistered");
|
||||
if (max_reg && nc->channelcount >= max_reg && !source.HasPriv("chanserv/no-register-limit"))
|
||||
{
|
||||
source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str());
|
||||
@@ -1018,7 +1018,7 @@ public:
|
||||
"channel will be dropped."
|
||||
));
|
||||
|
||||
unsigned max_reg = Config->GetModule("chanserv").Get<unsigned>("maxregistered");
|
||||
auto max_reg = Config->GetModule("chanserv").Get<unsigned>("maxregistered");
|
||||
if (max_reg)
|
||||
{
|
||||
source.Reply(" ");
|
||||
@@ -1112,7 +1112,7 @@ class CSSet final
|
||||
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
|
||||
return;
|
||||
|
||||
const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(s);
|
||||
const auto *ci = anope_dynamic_static_cast<const ChannelInfo *>(s);
|
||||
Anope::string modes;
|
||||
for (const auto &[last_mode, last_data] : ci->last_modes)
|
||||
{
|
||||
@@ -1138,11 +1138,11 @@ class CSSet final
|
||||
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
|
||||
return;
|
||||
|
||||
ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(s);
|
||||
Anope::string modes;
|
||||
data["last_modes"] >> modes;
|
||||
auto *ci = anope_dynamic_static_cast<ChannelInfo *>(s);
|
||||
ci->last_modes.clear();
|
||||
for (spacesepstream sep(modes); sep.GetToken(modes);)
|
||||
|
||||
spacesepstream sep(data.Load("last_modes"));
|
||||
for (Anope::string modes; sep.GetToken(modes);)
|
||||
{
|
||||
if (modes[0] == '+')
|
||||
{
|
||||
|
||||
@@ -77,23 +77,20 @@ struct CSMiscDataType
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string sci, sname, sdata;
|
||||
|
||||
data["ci"] >> sci;
|
||||
data["name"] >> sname;
|
||||
data["data"] >> sdata;
|
||||
|
||||
ChannelInfo *ci = ChannelInfo::Find(sci);
|
||||
auto *ci = ChannelInfo::Find(data.Load("ci"));
|
||||
if (ci == NULL)
|
||||
return NULL;
|
||||
|
||||
const auto sname = data.Load("name");
|
||||
const auto sdata = data.Load("data");
|
||||
|
||||
CSMiscData *d = NULL;
|
||||
if (obj)
|
||||
{
|
||||
d = anope_dynamic_static_cast<CSMiscData *>(obj);
|
||||
d->object = ci->name;
|
||||
data["name"] >> d->name;
|
||||
data["data"] >> d->data;
|
||||
d->name = sname;
|
||||
d->data = sdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -18,9 +18,9 @@ class StatusUpdate final
|
||||
: public Module
|
||||
{
|
||||
private:
|
||||
void OnAccessChange(ChannelInfo *ci, ChanAccess *access, bool adding)
|
||||
void OnAccessChange(ChannelInfo *ci, ChanAccess *access, bool migrated, bool adding)
|
||||
{
|
||||
if (!ci->c)
|
||||
if (!ci->c || migrated)
|
||||
return;
|
||||
|
||||
for (const auto &[_, uc] : ci->c->users)
|
||||
@@ -50,14 +50,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
|
||||
void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access, bool migrated) override
|
||||
{
|
||||
OnAccessChange(ci, access, true);
|
||||
OnAccessChange(ci, access, migrated, true);
|
||||
}
|
||||
|
||||
void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
|
||||
void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access, bool migrated) override
|
||||
{
|
||||
OnAccessChange(ci, access, false);
|
||||
OnAccessChange(ci, access, migrated, false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -42,25 +42,22 @@ struct CSSuspendInfoType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string schan;
|
||||
data["chan"] >> schan;
|
||||
|
||||
CSSuspendInfo *si;
|
||||
if (obj)
|
||||
si = anope_dynamic_static_cast<CSSuspendInfo *>(obj);
|
||||
else
|
||||
{
|
||||
ChannelInfo *ci = ChannelInfo::Find(schan);
|
||||
auto *ci = ChannelInfo::Find(data.Load("chan"));
|
||||
if (!ci)
|
||||
return NULL;
|
||||
si = ci->Extend<CSSuspendInfo>("CS_SUSPENDED");
|
||||
data["chan"] >> si->what;
|
||||
si->what = ci->name;
|
||||
}
|
||||
|
||||
data["by"] >> si->by;
|
||||
data["reason"] >> si->reason;
|
||||
data["time"] >> si->when;
|
||||
data["expires"] >> si->expires;
|
||||
si->by = data.Load("by");
|
||||
si->reason = data.Load("reason");
|
||||
si->when = data.Load<time_t>("time");
|
||||
si->expires = data.Load<time_t>("expires");
|
||||
return si;
|
||||
}
|
||||
};
|
||||
@@ -116,7 +113,7 @@ public:
|
||||
for (auto idx = reason_idx; idx < params.size(); ++idx)
|
||||
reason.append(reason.empty() ? "" : " ").append(params[idx]);
|
||||
|
||||
CSSuspendInfo *si = ci->Extend<CSSuspendInfo>("CS_SUSPENDED");
|
||||
auto *si = ci->Extend<CSSuspendInfo>("CS_SUSPENDED");
|
||||
si->what = ci->name;
|
||||
si->by = source.GetNick();
|
||||
si->reason = reason;
|
||||
@@ -186,7 +183,7 @@ public:
|
||||
}
|
||||
|
||||
/* Only UNSUSPEND already suspended channels */
|
||||
CSSuspendInfo *si = ci->GetExt<CSSuspendInfo>("CS_SUSPENDED");
|
||||
auto *si = ci->GetExt<CSSuspendInfo>("CS_SUSPENDED");
|
||||
if (!si)
|
||||
{
|
||||
source.Reply(_("Channel \002%s\002 isn't suspended."), ci->name.c_str());
|
||||
@@ -254,7 +251,7 @@ public:
|
||||
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
Anope::string s = conf.GetModule(this).Get<Anope::string>("show");
|
||||
auto s = conf.GetModule(this).Get<Anope::string>("show");
|
||||
commasepstream(s).GetTokens(show);
|
||||
std::transform(show.begin(), show.end(), show.begin(), trim());
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
{
|
||||
if (!source.GetUser())
|
||||
return;
|
||||
for (User::ChanUserList::iterator it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it)
|
||||
for (auto it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it)
|
||||
{
|
||||
Channel *c = it->second->chan;
|
||||
SetModes(source.GetUser(), c);
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
{
|
||||
if (!source.GetUser())
|
||||
return;
|
||||
for (User::ChanUserList::iterator it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it)
|
||||
for (auto it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it)
|
||||
{
|
||||
Channel *c = it->second->chan;
|
||||
RemoveAll(source.GetUser(), c);
|
||||
|
||||
+10
-10
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
bool HasPriv(const Anope::string &priv) const override
|
||||
{
|
||||
for (std::vector<Anope::string>::iterator it = std::find(order.begin(), order.end(), this->type); it != order.end(); ++it)
|
||||
for (auto it = std::find(order.begin(), order.end(), this->type); it != order.end(); ++it)
|
||||
{
|
||||
const std::vector<Anope::string> &privs = permissions[*it];
|
||||
if (std::find(privs.begin(), privs.end(), priv) != privs.end())
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
{
|
||||
if (access->provider->name == "access/xop")
|
||||
{
|
||||
const XOPChanAccess *xaccess = anope_dynamic_static_cast<const XOPChanAccess *>(access);
|
||||
const auto *xaccess = anope_dynamic_static_cast<const XOPChanAccess *>(access);
|
||||
return xaccess->type;
|
||||
}
|
||||
else
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
bool override = false;
|
||||
const NickAlias *na = NULL;
|
||||
|
||||
std::vector<Anope::string>::iterator cmd_it = std::find(order.begin(), order.end(), source.command.upper()),
|
||||
auto cmd_it = std::find(order.begin(), order.end(), source.command.upper()),
|
||||
access_it = highest ? std::find(order.begin(), order.end(), XOPChanAccess::DetermineLevel(highest)) : order.end();
|
||||
|
||||
if (!access.founder && (!access.HasPriv("ACCESS_CHANGE") || cmd_it <= access_it))
|
||||
@@ -252,7 +252,7 @@ private:
|
||||
ServiceReference<AccessProvider> provider("AccessProvider", "access/xop");
|
||||
if (!provider)
|
||||
return;
|
||||
XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create());
|
||||
auto *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create());
|
||||
acc->SetMask(mask, ci);
|
||||
acc->creator = source.GetNick();
|
||||
acc->description = description;
|
||||
@@ -263,7 +263,7 @@ private:
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask;
|
||||
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, acc));
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, acc, false));
|
||||
source.Reply(_("\002%s\002 added to %s %s list."), acc->Mask().c_str(), ci->name.c_str(), source.command.nobreak().c_str());
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Anope::string>::iterator cmd_it = std::find(order.begin(), order.end(), source.command.upper()),
|
||||
auto cmd_it = std::find(order.begin(), order.end(), source.command.upper()),
|
||||
access_it = highest ? std::find(order.begin(), order.end(), XOPChanAccess::DetermineLevel(highest)) : order.end();
|
||||
|
||||
if (!mask.equals_ci(nc->display) && !access.founder && (!access.HasPriv("ACCESS_CHANGE") || cmd_it <= access_it))
|
||||
@@ -372,7 +372,7 @@ private:
|
||||
nicks += caccess->Mask();
|
||||
|
||||
ci->EraseAccess(number - 1);
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, caccess));
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, caccess, false));
|
||||
delete caccess;
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ private:
|
||||
source.Reply(_("\002%s\002 deleted from %s %s list."), a->Mask().c_str(), ci->name.c_str(), source.command.nobreak().c_str());
|
||||
|
||||
ci->EraseAccess(i);
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, a));
|
||||
FOREACH_MOD(OnAccessDel, (ci, source, a, false));
|
||||
delete a;
|
||||
|
||||
return;
|
||||
@@ -636,8 +636,8 @@ public:
|
||||
|
||||
BotInfo *access_bi, *flags_bi;
|
||||
Anope::string access_cmd, flags_cmd;
|
||||
Command::FindCommandFromService("chanserv/access", access_bi, access_cmd);
|
||||
Command::FindCommandFromService("chanserv/flags", flags_bi, flags_cmd);
|
||||
Command::FindFromService("chanserv/access", access_bi, access_cmd);
|
||||
Command::FindFromService("chanserv/flags", flags_bi, flags_cmd);
|
||||
if (!access_cmd.empty() || !flags_cmd.empty())
|
||||
{
|
||||
source.Reply(_("Alternative methods of modifying channel access lists are available."));
|
||||
|
||||
@@ -235,7 +235,7 @@ class MChanstats final
|
||||
for (int i = 0; i < r.Rows(); ++i)
|
||||
{
|
||||
const std::map<Anope::string, Anope::string> &map = r.Row(i);
|
||||
for (std::map<Anope::string, Anope::string>::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
TableList.push_back(it->second);
|
||||
}
|
||||
query = "SHOW PROCEDURE STATUS WHERE `Db` = Database();";
|
||||
@@ -254,7 +254,7 @@ class MChanstats final
|
||||
|
||||
bool HasTable(const Anope::string &table)
|
||||
{
|
||||
for (std::vector<Anope::string>::const_iterator it = TableList.begin(); it != TableList.end(); ++it)
|
||||
for (auto it = TableList.begin(); it != TableList.end(); ++it)
|
||||
if (*it == table)
|
||||
return true;
|
||||
return false;
|
||||
@@ -262,7 +262,7 @@ class MChanstats final
|
||||
|
||||
bool HasProcedure(const Anope::string &table)
|
||||
{
|
||||
for (std::vector<Anope::string>::const_iterator it = ProcedureList.begin(); it != ProcedureList.end(); ++it)
|
||||
for (auto it = ProcedureList.begin(); it != ProcedureList.end(); ++it)
|
||||
if (*it == table)
|
||||
return true;
|
||||
return false;
|
||||
@@ -270,7 +270,7 @@ class MChanstats final
|
||||
|
||||
bool HasEvent(const Anope::string &table)
|
||||
{
|
||||
for (std::vector<Anope::string>::const_iterator it = EventList.begin(); it != EventList.end(); ++it)
|
||||
for (auto it = EventList.begin(); it != EventList.end(); ++it)
|
||||
if (*it == table)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
@@ -253,7 +253,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyFlags(Extensible *ext, Anope::string &flags, char flag, const char* extname, bool extend = true)
|
||||
void ApplyFlags(Extensible *ext, Anope::string &flags, char flag, const char *extname, bool extend = true)
|
||||
{
|
||||
auto pos = flags.find(flag);
|
||||
auto has_flag = (pos != Anope::string::npos);
|
||||
|
||||
@@ -21,7 +21,6 @@ public:
|
||||
std::fstream *fs;
|
||||
Serializable::Id id = 0;
|
||||
std::map<Anope::string, Anope::string> data;
|
||||
std::stringstream ss;
|
||||
bool read = false;
|
||||
|
||||
LoadData(std::fstream &fsref)
|
||||
@@ -29,7 +28,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
std::iostream &operator[](const Anope::string &key) override
|
||||
bool LoadInternal(const Anope::string &key, Anope::string &value) override
|
||||
{
|
||||
if (!read)
|
||||
{
|
||||
@@ -51,9 +50,13 @@ public:
|
||||
read = true;
|
||||
}
|
||||
|
||||
ss.clear();
|
||||
this->ss << this->data[key];
|
||||
return this->ss;
|
||||
value = this->data[key];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StoreInternal(const Anope::string &key, const Anope::string &value) override
|
||||
{
|
||||
return false; // This module can only load data.
|
||||
}
|
||||
|
||||
size_t Hash() const override
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
Serializable::Id id = 0;
|
||||
|
||||
// Data in this database entry.
|
||||
Anope::map<std::stringstream> data;
|
||||
Anope::unordered_map<Anope::string> data;
|
||||
|
||||
// Used when writing data.
|
||||
Data(Serialize::Type *s_type, Serializable *obj)
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
if (yyjson_get_type(key) != YYJSON_TYPE_STR)
|
||||
continue;
|
||||
|
||||
auto akey = yyjson_get_astr(key);
|
||||
const auto akey = yyjson_get_astr(key);
|
||||
if (akey.equals_ci("@id"))
|
||||
{
|
||||
this->id = yyjson_get_uint(value);
|
||||
@@ -66,23 +66,28 @@ public:
|
||||
}
|
||||
|
||||
if (yyjson_is_bool(value))
|
||||
data[akey] << yyjson_get_bool(value);
|
||||
data[akey] = Anope::ToString(yyjson_get_bool(value));
|
||||
else if (yyjson_is_int(value))
|
||||
data[akey] << yyjson_get_int(value);
|
||||
data[akey] = Anope::ToString(yyjson_get_int(value));
|
||||
else if (yyjson_is_null(value))
|
||||
data[akey];
|
||||
else if (yyjson_is_real(value))
|
||||
data[akey] << yyjson_get_real(value);
|
||||
data[akey] = Anope::ToString(yyjson_get_real(value));
|
||||
else if (yyjson_is_str(value))
|
||||
data[akey] << yyjson_get_astr(value);
|
||||
data[akey] = Anope::ToString(yyjson_get_astr(value));
|
||||
else if (yyjson_is_uint(value))
|
||||
data[akey] << yyjson_get_uint(value);
|
||||
data[akey] = Anope::ToString(yyjson_get_uint(value));
|
||||
}
|
||||
}
|
||||
|
||||
std::iostream &operator[](const Anope::string &key) override
|
||||
bool LoadInternal(const Anope::string &key, Anope::string &value) override
|
||||
{
|
||||
return data[key];
|
||||
auto it = this->data.find(key);
|
||||
if (it == this->data.end())
|
||||
return false;
|
||||
|
||||
value = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Hash() const override
|
||||
@@ -96,6 +101,12 @@ public:
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
bool StoreInternal(const Anope::string &key, const Anope::string &value) override
|
||||
{
|
||||
this->data[key] = value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class DBJSON final
|
||||
@@ -318,22 +329,23 @@ private:
|
||||
switch (data.GetType(key))
|
||||
{
|
||||
case Serialize::DataType::BOOL:
|
||||
v = yyjson_mut_bool(doc, Anope::Convert<bool>(value.str(), false));
|
||||
v = yyjson_mut_bool(doc, Anope::Convert<bool>(value, false));
|
||||
break;
|
||||
case Serialize::DataType::FLOAT:
|
||||
v = yyjson_mut_real(doc, Anope::Convert<double>(value.str(), 0.0));
|
||||
v = yyjson_mut_real(doc, Anope::Convert<double>(value, 0.0));
|
||||
break;
|
||||
case Serialize::DataType::INT:
|
||||
v = yyjson_mut_int(doc, Anope::Convert<int64_t>(value.str(), 0));
|
||||
v = yyjson_mut_int(doc, Anope::Convert<int64_t>(value, 0));
|
||||
break;
|
||||
case Serialize::DataType::TEXT:
|
||||
{
|
||||
auto str = value.str();
|
||||
v = str.empty() ? yyjson_mut_null(doc) : yyjson_mut_strncpy(doc, str.c_str(), str.length());
|
||||
v = value.empty()
|
||||
? yyjson_mut_null(doc)
|
||||
: yyjson_mut_strncpy(doc, value.c_str(), value.length());
|
||||
break;
|
||||
}
|
||||
case Serialize::DataType::UINT:
|
||||
v = yyjson_mut_uint(doc, Anope::Convert<uint64_t>(value.str(), 0));
|
||||
v = yyjson_mut_uint(doc, Anope::Convert<uint64_t>(value, 0));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,28 +24,30 @@ class Data final
|
||||
: public Serialize::Data
|
||||
{
|
||||
public:
|
||||
std::map<Anope::string, std::stringstream *> data;
|
||||
Anope::unordered_map<Anope::string> data;
|
||||
|
||||
~Data() override
|
||||
bool LoadInternal(const Anope::string &key, Anope::string &value) override
|
||||
{
|
||||
for (auto &[_, stream] : data)
|
||||
delete stream;
|
||||
auto it = this->data.find(key);
|
||||
if (it == this->data.end())
|
||||
return false;
|
||||
|
||||
value = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::iostream &operator[](const Anope::string &key) override
|
||||
bool StoreInternal(const Anope::string &key, const Anope::string &value) override
|
||||
{
|
||||
std::stringstream *&stream = data[key];
|
||||
if (!stream)
|
||||
stream = new std::stringstream();
|
||||
return *stream;
|
||||
this->data[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Hash() const override
|
||||
{
|
||||
size_t hash = 0;
|
||||
for (const auto &[_, value] : this->data)
|
||||
if (!value->str().empty())
|
||||
hash ^= Anope::hash_cs()(value->str());
|
||||
if (!value.empty())
|
||||
hash ^= Anope::hash_cs()(value);
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
@@ -311,7 +313,7 @@ void ObjectLoader::OnResult(const Reply &r)
|
||||
const Reply *key = r.multi_bulk[i],
|
||||
*value = r.multi_bulk[i + 1];
|
||||
|
||||
data[key->bulk] << value->bulk;
|
||||
data.StoreInternal(key->bulk, value->bulk);
|
||||
}
|
||||
|
||||
Serializable *&obj = st->objects[this->id];
|
||||
@@ -444,12 +446,12 @@ void Updater::OnResult(const Reply &r)
|
||||
for (const auto &[key, value] : data.data)
|
||||
{
|
||||
args.push_back(key);
|
||||
args.emplace_back(value->str());
|
||||
args.emplace_back(value);
|
||||
|
||||
std::vector<Anope::string> args2;
|
||||
|
||||
args2.emplace_back("SADD");
|
||||
args2.push_back("value:" + this->type + ":" + key + ":" + value->str());
|
||||
args2.push_back("value:" + this->type + ":" + key + ":" + value);
|
||||
args2.push_back(Anope::ToString(obj->object_id));
|
||||
|
||||
/* Add to value -> object id set */
|
||||
@@ -544,7 +546,7 @@ void SubscriptionListener::OnResult(const Reply &r)
|
||||
{
|
||||
std::vector<Anope::string> args;
|
||||
args.emplace_back("SREM");
|
||||
args.push_back("value:" + type + ":" + k + ":" + value->str());
|
||||
args.push_back("value:" + type + ":" + k + ":" + value);
|
||||
args.push_back(id);
|
||||
|
||||
/* Delete value -> object id */
|
||||
@@ -592,7 +594,7 @@ void ModifiedObject::OnResult(const Reply &r)
|
||||
{
|
||||
std::vector<Anope::string> args;
|
||||
args.emplace_back("SREM");
|
||||
args.push_back("value:" + st->GetName() + ":" + key + ":" + value->str());
|
||||
args.push_back("value:" + st->GetName() + ":" + key + ":" + value);
|
||||
args.push_back(Anope::ToString(this->id));
|
||||
|
||||
/* Delete value -> object id */
|
||||
@@ -607,7 +609,7 @@ void ModifiedObject::OnResult(const Reply &r)
|
||||
const Reply *key = r.multi_bulk[i],
|
||||
*value = r.multi_bulk[i + 1];
|
||||
|
||||
data[key->bulk] << value->bulk;
|
||||
data.StoreInternal(key->bulk, value->bulk);
|
||||
}
|
||||
|
||||
obj = st->Unserialize(obj, data);
|
||||
@@ -621,7 +623,7 @@ void ModifiedObject::OnResult(const Reply &r)
|
||||
{
|
||||
std::vector<Anope::string> args;
|
||||
args.emplace_back("SADD");
|
||||
args.push_back("value:" + st->GetName() + ":" + key + ":" + value->str());
|
||||
args.push_back("value:" + st->GetName() + ":" + key + ":" + value);
|
||||
args.push_back(Anope::ToString(obj->object_id));
|
||||
|
||||
/* Add to value -> object id set */
|
||||
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
Data data;
|
||||
|
||||
for (const auto &[key, value] : res.Row(j))
|
||||
data[key] << value;
|
||||
data.StoreInternal(key, value);
|
||||
|
||||
Serializable *obj = sb->Unserialize(NULL, data);
|
||||
if (obj)
|
||||
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
Data data;
|
||||
|
||||
for (const auto &[key, value] : row)
|
||||
data[key] << value;
|
||||
data.StoreInternal(key, value);
|
||||
|
||||
Serializable *s = NULL;
|
||||
auto it = obj->objects.find(id);
|
||||
|
||||
+7
-7
@@ -729,7 +729,7 @@ public:
|
||||
delete udpsock;
|
||||
delete tcpsock;
|
||||
|
||||
for (std::map<unsigned short, Request *>::iterator it = this->requests.begin(), it_end = this->requests.end(); it != it_end;)
|
||||
for (auto it = this->requests.begin(), it_end = this->requests.end(); it != it_end;)
|
||||
{
|
||||
Request *request = it->second;
|
||||
++it;
|
||||
@@ -909,7 +909,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<unsigned short, Request *>::iterator it = this->requests.find(recv_packet.id);
|
||||
auto it = this->requests.find(recv_packet.id);
|
||||
if (it == this->requests.end())
|
||||
{
|
||||
Log(LOG_DEBUG_2) << "Resolver: Received an answer for something we didn't request";
|
||||
@@ -1043,7 +1043,7 @@ private:
|
||||
*/
|
||||
bool CheckCache(Request *request)
|
||||
{
|
||||
cache_map::iterator it = this->cache.find(*request);
|
||||
auto it = this->cache.find(*request);
|
||||
if (it != this->cache.end())
|
||||
{
|
||||
Query &record = it->second;
|
||||
@@ -1070,7 +1070,7 @@ public:
|
||||
|
||||
~ModuleDNS() override
|
||||
{
|
||||
for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
|
||||
for (auto it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
|
||||
{
|
||||
Socket *s = it->second;
|
||||
++it;
|
||||
@@ -1096,8 +1096,8 @@ public:
|
||||
for (int i = 0; i < block.CountBlock("notify"); ++i)
|
||||
{
|
||||
const auto &n = block.GetBlock("notify", i);
|
||||
Anope::string nip = n.Get<Anope::string>("ip");
|
||||
short nport = n.Get<short>("port");
|
||||
auto nip = n.Get<Anope::string>("ip");
|
||||
auto nport = n.Get<short>("port");
|
||||
|
||||
notify.emplace_back(nip, nport);
|
||||
}
|
||||
@@ -1149,7 +1149,7 @@ public:
|
||||
|
||||
void OnModuleUnload(User *u, Module *m) override
|
||||
{
|
||||
for (std::map<unsigned short, Request *>::iterator it = this->manager.requests.begin(), it_end = this->manager.requests.end(); it != it_end;)
|
||||
for (auto it = this->manager.requests.begin(), it_end = this->manager.requests.end(); it != it_end;)
|
||||
{
|
||||
unsigned short id = it->first;
|
||||
Request *req = it->second;
|
||||
|
||||
@@ -575,7 +575,7 @@ Query MySQLService::BuildInsert(const Anope::string &table, Serializable::Id id,
|
||||
for (const auto &known_col : this->active_schema[table])
|
||||
{
|
||||
if (data.data.count(known_col) == 0)
|
||||
data[known_col] << "";
|
||||
data.data[known_col];
|
||||
}
|
||||
|
||||
Anope::string query_text = "INSERT INTO `" + table + "` (`id`";
|
||||
@@ -593,9 +593,7 @@ Query MySQLService::BuildInsert(const Anope::string &table, Serializable::Id id,
|
||||
Query query(query_text);
|
||||
for (auto &[field, value] : data.data)
|
||||
{
|
||||
Anope::string buf;
|
||||
*value >> buf;
|
||||
|
||||
auto buf = value;
|
||||
auto escape = true;
|
||||
switch (data.GetType(field))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
int err = regcomp(&this->regbuf, expr.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE);
|
||||
if (err)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
char buf[256];
|
||||
regerror(err, &this->regbuf, buf, sizeof(buf));
|
||||
regfree(&this->regbuf);
|
||||
throw RegexException("Error in regex " + expr + ": " + buf);
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
int err = regcomp(&this->regbuf, expr.c_str(), REG_EXTENDED | REG_NOSUB);
|
||||
if (err)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
char buf[256];
|
||||
regerror(err, &this->regbuf, buf, sizeof(buf));
|
||||
regfree(&this->regbuf);
|
||||
throw RegexException("Error in regex " + expr + ": " + buf);
|
||||
|
||||
@@ -311,7 +311,7 @@ Query SQLiteService::BuildInsert(const Anope::string &table, Serializable::Id id
|
||||
for (const auto &known_col : this->active_schema[table])
|
||||
{
|
||||
if (known_col != "id" && known_col != "timestamp" && data.data.count(known_col) == 0)
|
||||
data[known_col] << "";
|
||||
data.data[known_col];
|
||||
}
|
||||
|
||||
Anope::string query_text = "REPLACE INTO `" + table + "` (";
|
||||
@@ -331,9 +331,7 @@ Query SQLiteService::BuildInsert(const Anope::string &table, Serializable::Id id
|
||||
Query query(query_text);
|
||||
for (auto &[field, value] : data.data)
|
||||
{
|
||||
Anope::string buf;
|
||||
*value >> buf;
|
||||
|
||||
auto buf = value;
|
||||
auto escape = true;
|
||||
switch (data.GetType(field))
|
||||
{
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ public:
|
||||
if (params.empty())
|
||||
return;
|
||||
|
||||
CommandInfo::map::const_iterator it = Config->Fantasy.end();
|
||||
auto it = Config->Fantasy.end();
|
||||
unsigned count = 0;
|
||||
for (unsigned max = params.size(); it == Config->Fantasy.end() && max > 0; --max)
|
||||
{
|
||||
|
||||
+27
-10
@@ -88,7 +88,7 @@ public:
|
||||
CommandNSSetGreet(Module *creator, const Anope::string &sname = "nickserv/set/greet", size_t min = 0) : Command(creator, sname, min, min + 1)
|
||||
{
|
||||
this->SetDesc(_("Associate a greet message with your nickname"));
|
||||
this->SetSyntax(_("\037message\037"));
|
||||
this->SetSyntax(_("[\037message\037]"));
|
||||
}
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
@@ -136,11 +136,19 @@ public:
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Makes the given message the greet of your nickname, that "
|
||||
"will be displayed when joining a channel that has GREET "
|
||||
"option enabled, provided that you have the necessary "
|
||||
"access on it."
|
||||
"Changes your greet message. This message will be displayed when joining a channel "
|
||||
"that has GREET option enabled, provided that you have the necessary access on it."
|
||||
));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry(_("I come in peace"), _(
|
||||
"Changes your greet message to \035I come in peace\035."
|
||||
))
|
||||
.AddEntry("", _(
|
||||
"Removes your greet message."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -152,7 +160,7 @@ public:
|
||||
CommandNSSASetGreet(Module *creator) : CommandNSSetGreet(creator, "nickserv/saset/greet", 1)
|
||||
{
|
||||
this->ClearSyntax();
|
||||
this->SetSyntax(_("\037nickname\037 \037message\037"));
|
||||
this->SetSyntax(_("\037nickname\037 [\037message\037]"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
|
||||
@@ -165,11 +173,20 @@ public:
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Makes the given message the greet of the nickname, that "
|
||||
"will be displayed when joining a channel that has GREET "
|
||||
"option enabled, provided that the user has the necessary "
|
||||
"access on it."
|
||||
"Changes the greet message of the specified nickname. This message will be displayed "
|
||||
"when joining a channel that has GREET option enabled, provided that the user has the "
|
||||
"necessary access on it."
|
||||
));
|
||||
|
||||
ExampleWrapper()
|
||||
.AddEntry(_("alien I come in peace"), _(
|
||||
"Changes the greet message of \035alien\035 to \035I come in peace\035."
|
||||
))
|
||||
.AddEntry("zebra", _(
|
||||
"Removes the greet message of \035zebra\035."
|
||||
))
|
||||
.SendTo(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ public:
|
||||
full_command += " " + params[i];
|
||||
full_command.erase(full_command.begin());
|
||||
|
||||
CommandInfo::map::const_iterator it = map.find(full_command);
|
||||
auto it = map.find(full_command);
|
||||
if (it == map.end())
|
||||
continue;
|
||||
|
||||
|
||||
@@ -223,12 +223,12 @@ public:
|
||||
else
|
||||
ho = new HostOffer();
|
||||
|
||||
data["ident"] >> ho->ident;
|
||||
data["host"] >> ho->host;
|
||||
data["reason"] >> ho->reason;
|
||||
data["creator"] >> ho->creator;
|
||||
data["created"] >> ho->created;
|
||||
data["expires"] >> ho->expires;
|
||||
ho->ident = data.Load("ident");
|
||||
ho->host = data.Load("host");
|
||||
ho->reason = data.Load("reason");
|
||||
ho->creator = data.Load("creator");
|
||||
ho->created = data.Load<time_t>("created");
|
||||
ho->expires = data.Load<time_t>("expires");
|
||||
|
||||
if (!obj)
|
||||
host_offers->Add(ho);
|
||||
|
||||
@@ -75,10 +75,7 @@ struct HostRequestTypeImpl final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snick;
|
||||
data["nick"] >> snick;
|
||||
|
||||
NickAlias *na = NickAlias::Find(snick);
|
||||
auto *na = NickAlias::Find(data.Load("nick"));
|
||||
if (na == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -90,11 +87,11 @@ struct HostRequestTypeImpl final
|
||||
if (req)
|
||||
{
|
||||
req->nick = na->nick;
|
||||
data["ident"] >> req->ident;
|
||||
data["host"] >> req->host;
|
||||
data["time"] >> req->time;
|
||||
data["validation_token"] >> req->validation_token;
|
||||
data["last_validation"] >> req->last_validation;
|
||||
req->ident = data.Load("ident");
|
||||
req->host = data.Load("host");
|
||||
req->time = data.Load<time_t>("time");
|
||||
req->validation_token = data.Load("validation_token");
|
||||
req->last_validation = data.Load<time_t>("last_validation");
|
||||
}
|
||||
|
||||
return req;
|
||||
@@ -285,7 +282,7 @@ public:
|
||||
|
||||
BotInfo *bi;
|
||||
Anope::string cmd;
|
||||
if (dnsmanager && Command::FindCommandFromService("hostserv/validate", bi, cmd))
|
||||
if (dnsmanager && Command::FindFromService("hostserv/validate", bi, cmd))
|
||||
{
|
||||
source.Reply(_(
|
||||
"Your vhost \002%s\002 has been requested. If the requested vhost is for a valid "
|
||||
|
||||
+2
-2
@@ -354,7 +354,7 @@ public:
|
||||
|
||||
~HTTPD() override
|
||||
{
|
||||
for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
|
||||
for (auto it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
|
||||
{
|
||||
Socket *s = it->second;
|
||||
++it;
|
||||
@@ -447,7 +447,7 @@ public:
|
||||
spacesepstream(ext_header).GetTokens(p->ext_headers);
|
||||
}
|
||||
|
||||
for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end;)
|
||||
for (auto it = this->providers.begin(), it_end = this->providers.end(); it != it_end;)
|
||||
{
|
||||
HTTP::Provider *p = it->second;
|
||||
++it;
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
BotInfo *bi;
|
||||
Anope::string cmd;
|
||||
if (Command::FindCommandFromService("memoserv/del", bi, cmd))
|
||||
if (Command::FindFromService("memoserv/del", bi, cmd))
|
||||
{
|
||||
if (ci)
|
||||
source.Reply(_("To delete, type: \002%s %s %d\002"), bi->GetQueryCommand({}, cmd).c_str(), ci->name.c_str(), index + 1);
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
, nick(na->nick)
|
||||
{
|
||||
/* Erase the current release timer and use the new one */
|
||||
Anope::map<NickServRelease *>::iterator nit = NickServReleases.find(this->nick);
|
||||
auto nit = NickServReleases.find(this->nick);
|
||||
if (nit != NickServReleases.end())
|
||||
{
|
||||
IRCD->SendQuit(nit->second);
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
Log(NickServ, "nick") << "Deleting account " << nc->display;
|
||||
|
||||
/* Clean up this nick core from any users online */
|
||||
for (std::list<User *>::iterator it = nc->users.begin(); it != nc->users.end();)
|
||||
for (auto it = nc->users.begin(); it != nc->users.end();)
|
||||
{
|
||||
User *user = *it++;
|
||||
IRCD->SendLogout(user);
|
||||
@@ -610,7 +610,7 @@ public:
|
||||
|
||||
time_t nickserv_expire = Config->GetModule(this).Get<time_t>("expire", "1y");
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; )
|
||||
for (auto it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; )
|
||||
{
|
||||
NickAlias *na = it->second;
|
||||
++it;
|
||||
|
||||
@@ -34,10 +34,10 @@ struct AJoinEntry final
|
||||
|
||||
~AJoinEntry() override
|
||||
{
|
||||
AJoinList *channels = owner->GetExt<AJoinList>("ajoinlist");
|
||||
auto *channels = owner->GetExt<AJoinList>("ajoinlist");
|
||||
if (channels)
|
||||
{
|
||||
std::vector<AJoinEntry *>::iterator it = std::find((*channels)->begin(), (*channels)->end(), this);
|
||||
auto it = std::find((*channels)->begin(), (*channels)->end(), this);
|
||||
if (it != (*channels)->end())
|
||||
(*channels)->erase(it);
|
||||
}
|
||||
@@ -65,13 +65,9 @@ struct AJoinEntryType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &sd) const override
|
||||
{
|
||||
Anope::string sowner;
|
||||
uint64_t sownerid = 0;
|
||||
const auto sownerid = sd.Load<uint64_t>("ownerid");
|
||||
|
||||
sd["owner"] >> sowner; // Deprecated 2.0 field
|
||||
sd["ownerid"] >> sownerid;
|
||||
|
||||
auto *nc = sownerid ? NickCore::FindId(sownerid) : NickCore::Find(sowner);
|
||||
auto *nc = sownerid ? NickCore::FindId(sownerid) : NickCore::Find(sd.Load("owner"));
|
||||
if (nc == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -84,12 +80,12 @@ struct AJoinEntryType final
|
||||
aj->owner = nc;
|
||||
}
|
||||
|
||||
sd["channel"] >> aj->channel;
|
||||
sd["key"] >> aj->key;
|
||||
aj->channel = sd.Load("channel");
|
||||
aj->key = sd.Load("key");
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
auto *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
(*channels)->push_back(aj);
|
||||
}
|
||||
|
||||
@@ -108,7 +104,7 @@ class CommandNSAJoin final
|
||||
{
|
||||
static void DoList(CommandSource &source, NickCore *nc)
|
||||
{
|
||||
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
auto *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
|
||||
if ((*channels)->empty())
|
||||
source.Reply(_("%s's auto join list is empty."), nc->display.c_str());
|
||||
@@ -141,7 +137,7 @@ class CommandNSAJoin final
|
||||
void DoAdd(CommandSource &source, NickCore *nc, const Anope::string &chans, const Anope::string &keys)
|
||||
{
|
||||
const auto ajoinmax = Config->GetModule(this->owner).Get<unsigned>("ajoinmax");
|
||||
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
auto *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
|
||||
Anope::string addedchans;
|
||||
Anope::string alreadyadded;
|
||||
@@ -208,7 +204,7 @@ class CommandNSAJoin final
|
||||
|
||||
void DoDel(CommandSource &source, NickCore *nc, const Anope::string &chans)
|
||||
{
|
||||
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
auto *channels = nc->Require<AJoinList>("ajoinlist");
|
||||
Anope::string delchans;
|
||||
Anope::string notfoundchans;
|
||||
commasepstream sep(chans);
|
||||
@@ -344,7 +340,7 @@ public:
|
||||
if (!NickServ)
|
||||
return;
|
||||
|
||||
AJoinList *channels = u->Account()->GetExt<AJoinList>("ajoinlist");
|
||||
auto *channels = u->Account()->GetExt<AJoinList>("ajoinlist");
|
||||
if (channels == NULL)
|
||||
return;
|
||||
|
||||
|
||||
@@ -219,9 +219,8 @@ public:
|
||||
cl->certs.clear();
|
||||
|
||||
// Add the new cert list
|
||||
Anope::string buf;
|
||||
data["cert"] >> buf;
|
||||
for (spacesepstream sep(buf); sep.GetToken(buf); )
|
||||
spacesepstream sep(data.Load("cert"));
|
||||
for (Anope::string buf; sep.GetToken(buf); )
|
||||
{
|
||||
auto *cert = new NSCertInfo(e);
|
||||
cert->fingerprint = buf;
|
||||
@@ -255,10 +254,7 @@ public:
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
uint64_t account = 0;
|
||||
data["account"] >> account;
|
||||
|
||||
auto *nc = NickCore::FindId(account);
|
||||
auto *nc = NickCore::FindId(data.Load<uint64_t>("account"));
|
||||
if (!nc)
|
||||
return nullptr; // Missing user.
|
||||
|
||||
@@ -268,10 +264,10 @@ public:
|
||||
else
|
||||
cert = new NSCertInfo(nc);
|
||||
|
||||
data["created"] >> cert->created;
|
||||
data["creator"] >> cert->creator;
|
||||
data["description"] >> cert->description;
|
||||
data["fingerprint"] >> cert->fingerprint;
|
||||
cert->created = data.Load<time_t>("created");
|
||||
cert->creator = data.Load("creator");
|
||||
cert->description = data.Load("description");
|
||||
cert->fingerprint = data.Load("fingerprint");
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
@@ -652,6 +648,7 @@ private:
|
||||
NSCertListImpl::ExtensibleItem certs;
|
||||
CertServiceImpl cs;
|
||||
NSCertInfoType cert_type;
|
||||
SerializableExtensibleItem<bool> autologin;
|
||||
|
||||
bool CanLogin(User *u, NickCore *nc)
|
||||
{
|
||||
@@ -681,6 +678,7 @@ public:
|
||||
, commandnssasetautologin(this)
|
||||
, certs(this, NICKSERV_CERT_EXT)
|
||||
, cs(this)
|
||||
, autologin(this, "AUTOLOGIN")
|
||||
{
|
||||
if (!IRCD || !IRCD->CanCertFP)
|
||||
throw ModuleException("Your IRCd does not support ssl client certificates");
|
||||
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
|
||||
NickAlias *target, *na = NickAlias::Find(source.GetNick());
|
||||
time_t reg_delay = Config->GetModule("nickserv").Get<time_t>("regdelay");
|
||||
unsigned maxaliases = Config->GetModule(this->owner).Get<unsigned>("maxaliases");
|
||||
auto maxaliases = Config->GetModule(this->owner).Get<unsigned>("maxaliases");
|
||||
if (!(target = NickAlias::Find(nick)))
|
||||
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
|
||||
else if (user && Anope::CurTime < user->lastnickreg + reg_delay)
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
{
|
||||
NickCore *oldcore = na->nc;
|
||||
|
||||
std::vector<NickAlias *>::iterator it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na);
|
||||
auto it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na);
|
||||
if (it != oldcore->aliases->end())
|
||||
oldcore->aliases->erase(it);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int maxlogins = Config->GetModule(this->owner).Get<unsigned int>("maxlogins");
|
||||
auto maxlogins = Config->GetModule(this->owner).Get<unsigned int>("maxlogins");
|
||||
if (na && maxlogins && na->nc->users.size() >= maxlogins)
|
||||
{
|
||||
source.Reply(_("Account \002%s\002 has already reached the maximum number of simultaneous logins (%u)."), na->nc->display.c_str(), maxlogins);
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
{
|
||||
if (!u->chans.empty())
|
||||
{
|
||||
NSRecoverInfo *ei = source.GetUser()->Extend<NSRecoverInfo>("recover");
|
||||
auto *ei = source.GetUser()->Extend<NSRecoverInfo>("recover");
|
||||
for (auto &[chan, cuc] : u->chans)
|
||||
(*ei)[chan->name] = cuc->status;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
|
||||
if (IRCD->CanSVSNick)
|
||||
{
|
||||
NSRecoverSvsnick *svs = u->Extend<NSRecoverSvsnick>("svsnick");
|
||||
auto *svs = u->Extend<NSRecoverSvsnick>("svsnick");
|
||||
svs->from = source.GetUser();
|
||||
svs->to = u->nick;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
BotInfo *NickServ = Config->GetClient("NickServ");
|
||||
|
||||
if (ei != NULL && NickServ != NULL)
|
||||
for (NSRecoverInfo::iterator it = ei->begin(), it_end = ei->end(); it != it_end;)
|
||||
for (auto it = ei->begin(), it_end = ei->end(); it != it_end;)
|
||||
{
|
||||
Channel *c = Channel::Find(it->first);
|
||||
const Anope::string &cname = it->first;
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
|
||||
if (ei != NULL)
|
||||
{
|
||||
NSRecoverInfo::iterator it = ei->find(c->name);
|
||||
auto it = ei->find(c->name);
|
||||
if (it != ei->end())
|
||||
{
|
||||
for (auto mode : it->second.Modes())
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
|
||||
{
|
||||
unsigned int minpasslen = Config->GetModule("nickserv").Get<unsigned>("minpasslen", "10");
|
||||
auto minpasslen = Config->GetModule("nickserv").Get<unsigned>("minpasslen", "10");
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
Anope::string GetAgent()
|
||||
{
|
||||
Anope::string agent = Config->GetModule(Service::owner).Get<Anope::string>("agent", "NickServ");
|
||||
auto agent = Config->GetModule(Service::owner).Get<Anope::string>("agent", "NickServ");
|
||||
BotInfo *bi = Config->GetClient(agent);
|
||||
if (bi)
|
||||
agent = bi->GetUID();
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
bool ProcessMessage(SASL::Session *sess, const SASL::Message &m) override
|
||||
{
|
||||
Session *mysess = anope_dynamic_static_cast<Session *>(sess);
|
||||
auto *mysess = anope_dynamic_static_cast<Session *>(sess);
|
||||
|
||||
if (m.type == "S")
|
||||
{
|
||||
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
if (s->GetSerializableType()->GetName() != NICKCORE_TYPE)
|
||||
return;
|
||||
|
||||
const NickCore *nc = anope_dynamic_static_cast<const NickCore *>(s);
|
||||
const auto *nc = anope_dynamic_static_cast<const NickCore *>(s);
|
||||
Anope::string modes;
|
||||
for (const auto &[last_mode, last_data] : nc->last_modes)
|
||||
{
|
||||
@@ -155,11 +155,11 @@ private:
|
||||
if (s->GetSerializableType()->GetName() != NICKCORE_TYPE)
|
||||
return;
|
||||
|
||||
NickCore *nc = anope_dynamic_static_cast<NickCore *>(s);
|
||||
Anope::string modes;
|
||||
data["last_modes"] >> modes;
|
||||
auto *nc = anope_dynamic_static_cast<NickCore *>(s);
|
||||
nc->last_modes.clear();
|
||||
for (spacesepstream sep(modes); sep.GetToken(modes);)
|
||||
|
||||
spacesepstream sep(data.Load("last_modes"));
|
||||
for (Anope::string modes; sep.GetToken(modes);)
|
||||
{
|
||||
if (modes[0] == '+')
|
||||
{
|
||||
|
||||
@@ -79,23 +79,20 @@ struct NSMiscDataType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snc, sname, sdata;
|
||||
|
||||
data["nc"] >> snc;
|
||||
data["name"] >> sname;
|
||||
data["data"] >> sdata;
|
||||
|
||||
NickCore *nc = NickCore::Find(snc);
|
||||
auto *nc = NickCore::Find(data.Load("nc"));
|
||||
if (nc == NULL)
|
||||
return NULL;
|
||||
|
||||
const auto sname = data.Load("name");
|
||||
const auto sdata = data.Load("data");
|
||||
|
||||
NSMiscData *d = NULL;
|
||||
if (obj)
|
||||
{
|
||||
d = anope_dynamic_static_cast<NSMiscData *>(obj);
|
||||
d->object = nc->display;
|
||||
data["name"] >> d->name;
|
||||
data["data"] >> d->data;
|
||||
d->name = sname;
|
||||
d->data = sdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
throw ModuleException("A compiler with C++20 support is required by this module");
|
||||
#else
|
||||
// Build the zone list.
|
||||
const auto& tzdb = std::chrono::get_tzdb();
|
||||
const auto &tzdb = std::chrono::get_tzdb();
|
||||
for (const auto &tz : tzdb.zones)
|
||||
timezones.emplace_back(tz.name());
|
||||
for (const auto &tz : tzdb.links)
|
||||
|
||||
@@ -43,25 +43,23 @@ struct NSSuspendInfoType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snick;
|
||||
data["nick"] >> snick;
|
||||
|
||||
NSSuspendInfo *si;
|
||||
if (obj)
|
||||
si = anope_dynamic_static_cast<NSSuspendInfo *>(obj);
|
||||
else
|
||||
{
|
||||
NickAlias *na = NickAlias::Find(snick);
|
||||
auto *na = NickAlias::Find(data.Load("nick"));
|
||||
if (!na)
|
||||
return NULL;
|
||||
|
||||
si = na->nc->Extend<NSSuspendInfo>("NS_SUSPENDED");
|
||||
data["nick"] >> si->what;
|
||||
si->what = na->nick;
|
||||
}
|
||||
|
||||
data["by"] >> si->by;
|
||||
data["reason"] >> si->reason;
|
||||
data["time"] >> si->when;
|
||||
data["expires"] >> si->expires;
|
||||
si->by = data.Load("by");
|
||||
si->reason = data.Load("reason");
|
||||
si->when = data.Load<time_t>("time");
|
||||
si->expires = data.Load<time_t>("expires");
|
||||
return si;
|
||||
}
|
||||
};
|
||||
@@ -124,7 +122,7 @@ public:
|
||||
for (auto idx = reason_idx; idx < params.size(); ++idx)
|
||||
reason.append(reason.empty() ? "" : " ").append(params[idx]);
|
||||
|
||||
NSSuspendInfo *si = nc->Extend<NSSuspendInfo>("NS_SUSPENDED");
|
||||
auto *si = nc->Extend<NSSuspendInfo>("NS_SUSPENDED");
|
||||
si->what = nc->display;
|
||||
si->by = source.GetNick();
|
||||
si->reason = reason;
|
||||
@@ -199,7 +197,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
NSSuspendInfo *si = na->nc->GetExt<NSSuspendInfo>("NS_SUSPENDED");
|
||||
auto *si = na->nc->GetExt<NSSuspendInfo>("NS_SUSPENDED");
|
||||
|
||||
Log(LOG_ADMIN, source, this) << "for " << na->nick << " which was suspended by " << (!si->by.empty() ? si->by : "(none)") << " for: " << (!si->reason.empty() ? si->reason : "No reason");
|
||||
|
||||
@@ -258,7 +256,7 @@ public:
|
||||
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
Anope::string s = conf.GetModule(this).Get<Anope::string>("show");
|
||||
auto s = conf.GetModule(this).Get<Anope::string>("show");
|
||||
commasepstream(s).GetTokens(show);
|
||||
std::transform(show.begin(), show.end(), show.begin(), trim());
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ struct DefconConfig final
|
||||
|
||||
bool GetDefConParam(const Anope::string &name, Anope::string &buf)
|
||||
{
|
||||
std::map<Anope::string, Anope::string>::iterator it = DefConModesOnParams.find(name);
|
||||
auto it = DefConModesOnParams.find(name);
|
||||
|
||||
buf.clear();
|
||||
|
||||
|
||||
+14
-16
@@ -38,7 +38,7 @@ struct DNSZone final
|
||||
|
||||
~DNSZone() override
|
||||
{
|
||||
std::vector<DNSZone *>::iterator it = std::find(zones->begin(), zones->end(), this);
|
||||
auto it = std::find(zones->begin(), zones->end(), this);
|
||||
if (it != zones->end())
|
||||
zones->erase(it);
|
||||
}
|
||||
@@ -79,12 +79,12 @@ struct DNSZoneType final
|
||||
DNSZone *zone;
|
||||
Anope::string zone_name;
|
||||
|
||||
data["name"] >> zone_name;
|
||||
zone_name = data.Load("name");
|
||||
|
||||
if (obj)
|
||||
{
|
||||
zone = anope_dynamic_static_cast<DNSZone *>(obj);
|
||||
data["name"] >> zone->name;
|
||||
zone->name = data.Load("name");
|
||||
}
|
||||
else
|
||||
zone = new DNSZone(zone_name);
|
||||
@@ -92,10 +92,10 @@ struct DNSZoneType final
|
||||
zone->servers.clear();
|
||||
for (unsigned count = 0; true; ++count)
|
||||
{
|
||||
Anope::string server_str;
|
||||
data["server" + Anope::ToString(count)] >> server_str;
|
||||
const auto server_str = data.Load(Anope::Format("server%u", count));
|
||||
if (server_str.empty())
|
||||
break;
|
||||
|
||||
zone->servers.insert(server_str);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
|
||||
~DNSServer() override
|
||||
{
|
||||
std::vector<DNSServer *>::iterator it = std::find(dns_servers->begin(), dns_servers->end(), this);
|
||||
auto it = std::find(dns_servers->begin(), dns_servers->end(), this);
|
||||
if (it != dns_servers->end())
|
||||
dns_servers->erase(it);
|
||||
}
|
||||
@@ -195,11 +195,9 @@ struct DNSServerType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto server_name = data.Load("server_name");
|
||||
|
||||
DNSServer *req;
|
||||
Anope::string server_name;
|
||||
|
||||
data["server_name"] >> server_name;
|
||||
|
||||
if (obj)
|
||||
{
|
||||
req = anope_dynamic_static_cast<DNSServer *>(obj);
|
||||
@@ -210,23 +208,23 @@ struct DNSServerType final
|
||||
|
||||
for (unsigned i = 0; true; ++i)
|
||||
{
|
||||
Anope::string ip_str;
|
||||
data["ip" + Anope::ToString(i)] >> ip_str;
|
||||
const auto ip_str = data.Load(Anope::Format("ip%u", i));
|
||||
if (ip_str.empty())
|
||||
break;
|
||||
|
||||
req->ips.push_back(ip_str);
|
||||
}
|
||||
|
||||
data["limit"] >> req->limit;
|
||||
data["pooled"] >> req->pooled;
|
||||
req->limit = data.Load<unsigned>("limit");
|
||||
req->pooled = data.Load<bool>("pooled");
|
||||
|
||||
req->zones.clear();
|
||||
for (unsigned i = 0; true; ++i)
|
||||
{
|
||||
Anope::string zone_str;
|
||||
data["zone" + Anope::ToString(i)] >> zone_str;
|
||||
const auto zone_str = data.Load(Anope::Format("zone%u", i));
|
||||
if (zone_str.empty())
|
||||
break;
|
||||
|
||||
req->zones.insert(zone_str);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,14 +113,12 @@ Serializable *ForbidDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data
|
||||
else
|
||||
fb = new ForbidDataImpl();
|
||||
|
||||
data["mask"] >> fb->mask;
|
||||
data["creator"] >> fb->creator;
|
||||
data["reason"] >> fb->reason;
|
||||
data["created"] >> fb->created;
|
||||
data["expires"] >> fb->expires;
|
||||
Anope::string t;
|
||||
data["type"] >> t;
|
||||
fb->type = StringToType(t);
|
||||
fb->mask = data.Load("mask");
|
||||
fb->creator = data.Load("creator");
|
||||
fb->reason = data.Load("reason");
|
||||
fb->created = data.Load<time_t>("created");
|
||||
fb->expires = data.Load<time_t>("expires");
|
||||
fb->type = StringToType(data.Load("type"));
|
||||
|
||||
if (fb->type == OperServ::FT_SIZE)
|
||||
return NULL;
|
||||
@@ -325,7 +323,7 @@ public:
|
||||
for (const auto &[_, user] : UserListByNick)
|
||||
module->OnUserNickChange(user, "");
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end;)
|
||||
for (auto it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end;)
|
||||
{
|
||||
NickAlias *na = it->second;
|
||||
++it;
|
||||
@@ -346,7 +344,7 @@ public:
|
||||
{
|
||||
int chan_matches = 0, ci_matches = 0;
|
||||
|
||||
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end;)
|
||||
for (auto it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end;)
|
||||
{
|
||||
Channel *c = it->second;
|
||||
++it;
|
||||
@@ -369,7 +367,7 @@ public:
|
||||
|
||||
++chan_matches;
|
||||
|
||||
for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end;)
|
||||
for (auto cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end;)
|
||||
{
|
||||
User *u = cit->first;
|
||||
++cit;
|
||||
@@ -383,7 +381,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(); it != RegisteredChannelList->end();)
|
||||
for (auto it = RegisteredChannelList->begin(); it != RegisteredChannelList->end();)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
++it;
|
||||
|
||||
@@ -66,10 +66,10 @@ Serializable *IgnoreDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data
|
||||
OperServ::ignore_service->AddIgnore(ign);
|
||||
}
|
||||
|
||||
data["mask"] >> ign->mask;
|
||||
data["creator"] >> ign->creator;
|
||||
data["reason"] >> ign->reason;
|
||||
data["time"] >> ign->time;
|
||||
ign->mask = data.Load("mask");
|
||||
ign->creator = data.Load("creator");
|
||||
ign->reason = data.Load("reason");
|
||||
ign->time = data.Load<time_t>("time");
|
||||
|
||||
return ign;
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ OperInfoImpl::~OperInfoImpl()
|
||||
Extensible *e = OperInfos::Find(target);
|
||||
if (e)
|
||||
{
|
||||
OperInfos *op = e->GetExt<OperInfos>("operinfo");
|
||||
auto *op = e->GetExt<OperInfos>("operinfo");
|
||||
if (op)
|
||||
{
|
||||
std::vector<OperInfo *>::iterator it = std::find((*op)->begin(), (*op)->end(), this);
|
||||
auto it = std::find((*op)->begin(), (*op)->end(), this);
|
||||
if (it != (*op)->end())
|
||||
(*op)->erase(it);
|
||||
}
|
||||
@@ -89,14 +89,13 @@ OperInfoImpl::~OperInfoImpl()
|
||||
|
||||
Serializable *OperInfoTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string starget;
|
||||
data["target"] >> starget;
|
||||
const auto starget = data.Load("target");
|
||||
|
||||
Extensible *e = OperInfos::Find(starget);
|
||||
if (!e)
|
||||
return NULL;
|
||||
|
||||
OperInfos *oi = e->Require<OperInfos>("operinfo");
|
||||
auto *oi = e->Require<OperInfos>("operinfo");
|
||||
OperInfoImpl *o;
|
||||
if (obj)
|
||||
o = anope_dynamic_static_cast<OperInfoImpl *>(obj);
|
||||
@@ -105,9 +104,9 @@ Serializable *OperInfoTypeImpl::Unserialize(Serializable *obj, Serialize::Data &
|
||||
o = new OperInfoImpl();
|
||||
o->target = starget;
|
||||
}
|
||||
data["info"] >> o->info;
|
||||
data["adder"] >> o->adder;
|
||||
data["created"] >> o->created;
|
||||
o->info = data.Load("info");
|
||||
o->adder = data.Load("adder");
|
||||
o->created = data.Load<time_t>("created");
|
||||
|
||||
if (!obj)
|
||||
(*oi)->push_back(o);
|
||||
@@ -162,7 +161,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
OperInfos *oi = e->Require<OperInfos>("operinfo");
|
||||
auto *oi = e->Require<OperInfos>("operinfo");
|
||||
|
||||
if ((*oi)->size() >= Config->GetModule(this->module).Get<unsigned>("max", "10"))
|
||||
{
|
||||
@@ -195,7 +194,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
OperInfos *oi = e->GetExt<OperInfos>("operinfo");
|
||||
auto *oi = e->GetExt<OperInfos>("operinfo");
|
||||
|
||||
if (!oi)
|
||||
{
|
||||
@@ -234,7 +233,7 @@ public:
|
||||
}
|
||||
else if (cmd.equals_ci("CLEAR"))
|
||||
{
|
||||
OperInfos *oi = e->GetExt<OperInfos>("operinfo");
|
||||
auto *oi = e->GetExt<OperInfos>("operinfo");
|
||||
|
||||
if (!oi)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
IRCD->SendSquit(server, rbuf);
|
||||
server->Delete(rbuf);
|
||||
}
|
||||
auto *juped_server = new Server(Me, jserver, 1, rbuf, sid, true);
|
||||
auto *juped_server = new Server(Me, jserver, rbuf, sid, 1, true);
|
||||
IRCD->SendServer(juped_server);
|
||||
|
||||
Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")";
|
||||
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
|
||||
source.Reply(_("Users list:"));
|
||||
|
||||
for (Anope::map<User *>::const_iterator it = ordered_map.begin(); it != ordered_map.end(); ++it)
|
||||
for (auto it = ordered_map.begin(); it != ordered_map.end(); ++it)
|
||||
{
|
||||
User *u2 = it->second;
|
||||
|
||||
|
||||
@@ -130,12 +130,10 @@ struct NewsItemType final
|
||||
else
|
||||
ni = new OperServ::NewsItem();
|
||||
|
||||
Anope::string t;
|
||||
data["type"] >> t;
|
||||
ni->type = StringToType(t);
|
||||
data["text"] >> ni->text;
|
||||
data["who"] >> ni->who;
|
||||
data["time"] >> ni->time;
|
||||
ni->type = StringToType(data.Load("type"));
|
||||
ni->text = data.Load("text");
|
||||
ni->who = data.Load("who");
|
||||
ni->time = data.Load<time_t>("time");
|
||||
|
||||
if (!obj)
|
||||
OperServ::news_service->AddNewsItem(ni);
|
||||
@@ -265,7 +263,7 @@ protected:
|
||||
source.Reply(READ_ONLY_MODE);
|
||||
if (!text.equals_ci("ALL"))
|
||||
{
|
||||
unsigned num = Anope::Convert<unsigned>(text, 0);
|
||||
auto num = Anope::Convert<unsigned>(text, 0);
|
||||
if (num > 0 && num <= list.size())
|
||||
{
|
||||
OperServ::news_service->DelNewsItem(list[num - 1]);
|
||||
|
||||
@@ -32,15 +32,11 @@ struct OSOperType
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string stype, sname;
|
||||
|
||||
data["type"] >> stype;
|
||||
data["name"] >> sname;
|
||||
|
||||
OperType *ot = OperType::Find(stype);
|
||||
auto *ot = OperType::Find(data.Load("type"));
|
||||
if (ot == NULL)
|
||||
return NULL;
|
||||
NickCore *nc = NickCore::Find(sname);
|
||||
|
||||
auto *nc = NickCore::Find(data.Load("name"));
|
||||
if (nc == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -49,6 +45,7 @@ struct OSOperType
|
||||
myo = anope_dynamic_static_cast<OperServ::Oper *>(obj);
|
||||
else
|
||||
myo = new OperServ::Oper(nc->display, ot);
|
||||
|
||||
nc->o = myo;
|
||||
Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName();
|
||||
return myo;
|
||||
@@ -169,7 +166,7 @@ public:
|
||||
if (!nc->o)
|
||||
continue;
|
||||
|
||||
source.Reply(_("%-8s %s"), nc->o->name.c_str(), nc->o->ot->GetName().c_str());
|
||||
source.Reply("%-8s %s", nc->o->name.c_str(), nc->o->ot->GetName().c_str());
|
||||
if (std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end())
|
||||
source.Reply(_(" This oper is configured in the configuration file."));
|
||||
for (auto *u : nc->users)
|
||||
|
||||
@@ -66,12 +66,13 @@ struct ExceptionType final
|
||||
ex = anope_dynamic_static_cast<OperServ::Exception *>(obj);
|
||||
else
|
||||
ex = new OperServ::Exception();
|
||||
data["mask"] >> ex->mask;
|
||||
data["limit"] >> ex->limit;
|
||||
data["who"] >> ex->who;
|
||||
data["reason"] >> ex->reason;
|
||||
data["time"] >> ex->time;
|
||||
data["expires"] >> ex->expires;
|
||||
|
||||
ex->mask = data.Load("mask");
|
||||
ex->limit = data.Load<unsigned>("limit");
|
||||
ex->who = data.Load("who");
|
||||
ex->reason = data.Load("reason");
|
||||
ex->time = data.Load<time_t>("time");
|
||||
ex->expires = data.Load<time_t>("expires");
|
||||
|
||||
if (!obj)
|
||||
OperServ::session_service->AddException(ex);
|
||||
|
||||
@@ -43,8 +43,8 @@ struct StatsType final
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
data["maxusercnt"] >> MaxUserCount;
|
||||
data["maxusertime"] >> MaxUserTime;
|
||||
MaxUserCount = data.Load<size_t>("maxusercnt");
|
||||
MaxUserTime = data.Load<time_t>("maxusertime");
|
||||
return Stats::me;
|
||||
}
|
||||
};
|
||||
@@ -54,71 +54,30 @@ Stats *Stats::me = nullptr;
|
||||
class CommandOSStats final
|
||||
: public Command
|
||||
{
|
||||
private:
|
||||
ServiceReference<XLineManager> akills, snlines, sqlines;
|
||||
|
||||
static void ReportXLineStats(CommandSource &source, XLineManager *xlm, const char *type, const char *config)
|
||||
{
|
||||
source.Reply(_("Current number of %ss: \002%zu\002"), type, xlm->GetCount());
|
||||
|
||||
const auto timeout = Config->GetModule("operserv").Get<time_t>(config, "30d");
|
||||
if (timeout)
|
||||
source.Reply(_("Default %s expiry time: \002%s\002"), type, Anope::Duration(timeout, source.nc, true).c_str());
|
||||
else
|
||||
source.Reply(_("Default %s expiry time: \002No expiration\002"), type);
|
||||
}
|
||||
private:
|
||||
void DoStatsAkill(CommandSource &source)
|
||||
{
|
||||
int timeout;
|
||||
if (akills)
|
||||
{
|
||||
/* AKILLs */
|
||||
source.Reply(_("Current number of AKILLs: \002%zu\002"), akills->GetCount());
|
||||
timeout = Config->GetModule("operserv").Get<time_t>("autokillexpiry", "30d") + 59;
|
||||
if (timeout >= 172800)
|
||||
source.Reply(_("Default AKILL expiry time: \002%d days\002"), timeout / 86400);
|
||||
else if (timeout >= 86400)
|
||||
source.Reply(_("Default AKILL expiry time: \0021 day\002"));
|
||||
else if (timeout >= 7200)
|
||||
source.Reply(_("Default AKILL expiry time: \002%d hours\002"), timeout / 3600);
|
||||
else if (timeout >= 3600)
|
||||
source.Reply(_("Default AKILL expiry time: \0021 hour\002"));
|
||||
else if (timeout >= 120)
|
||||
source.Reply(_("Default AKILL expiry time: \002%d minutes\002"), timeout / 60);
|
||||
else if (timeout >= 60)
|
||||
source.Reply(_("Default AKILL expiry time: \0021 minute\002"));
|
||||
else
|
||||
source.Reply(_("Default AKILL expiry time: \002No expiration\002"));
|
||||
}
|
||||
ReportXLineStats(source, *akills, "AKILL", "autokillexpiry");
|
||||
|
||||
if (snlines)
|
||||
{
|
||||
/* SNLINEs */
|
||||
source.Reply(_("Current number of SNLINEs: \002%zu\002"), snlines->GetCount());
|
||||
timeout = Config->GetModule("operserv").Get<time_t>("snlineexpiry", "30d") + 59;
|
||||
if (timeout >= 172800)
|
||||
source.Reply(_("Default SNLINE expiry time: \002%d days\002"), timeout / 86400);
|
||||
else if (timeout >= 86400)
|
||||
source.Reply(_("Default SNLINE expiry time: \0021 day\002"));
|
||||
else if (timeout >= 7200)
|
||||
source.Reply(_("Default SNLINE expiry time: \002%d hours\002"), timeout / 3600);
|
||||
else if (timeout >= 3600)
|
||||
source.Reply(_("Default SNLINE expiry time: \0021 hour\002"));
|
||||
else if (timeout >= 120)
|
||||
source.Reply(_("Default SNLINE expiry time: \002%d minutes\002"), timeout / 60);
|
||||
else if (timeout >= 60)
|
||||
source.Reply(_("Default SNLINE expiry time: \0021 minute\002"));
|
||||
else
|
||||
source.Reply(_("Default SNLINE expiry time: \002No expiration\002"));
|
||||
}
|
||||
ReportXLineStats(source, *snlines, "SNLINE", "snlineexpiry");
|
||||
|
||||
if (sqlines)
|
||||
{
|
||||
/* SQLINEs */
|
||||
source.Reply(_("Current number of SQLINEs: \002%zu\002"), sqlines->GetCount());
|
||||
timeout = Config->GetModule("operserv").Get<time_t>("sglineexpiry", "30d") + 59;
|
||||
if (timeout >= 172800)
|
||||
source.Reply(_("Default SQLINE expiry time: \002%d days\002"), timeout / 86400);
|
||||
else if (timeout >= 86400)
|
||||
source.Reply(_("Default SQLINE expiry time: \0021 day\002"));
|
||||
else if (timeout >= 7200)
|
||||
source.Reply(_("Default SQLINE expiry time: \002%d hours\002"), timeout / 3600);
|
||||
else if (timeout >= 3600)
|
||||
source.Reply(_("Default SQLINE expiry time: \0021 hour\002"));
|
||||
else if (timeout >= 120)
|
||||
source.Reply(_("Default SQLINE expiry time: \002%d minutes\002"), timeout / 60);
|
||||
else if (timeout >= 60)
|
||||
source.Reply(_("Default SQLINE expiry time: \0021 minute\002"));
|
||||
else
|
||||
source.Reply(_("Default SQLINE expiry time: \002No expiration\002"));
|
||||
}
|
||||
ReportXLineStats(source, *sqlines, "SQLINE", "sqlineexpiry");
|
||||
}
|
||||
|
||||
static void DoStatsReset(CommandSource &source)
|
||||
|
||||
@@ -510,7 +510,7 @@ struct IRCDMessageServer final
|
||||
if (params.size() == 5)
|
||||
UplinkSID = params[2];
|
||||
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params.back(), UplinkSID);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params.back(), UplinkSID, 1);
|
||||
|
||||
IRCD->SendPing(Me->GetName(), params[0]);
|
||||
}
|
||||
@@ -526,7 +526,7 @@ struct IRCDMessageSID final
|
||||
void Run(MessageSource &source, const std::vector<Anope::string> ¶ms, const Anope::map<Anope::string> &tags) override
|
||||
{
|
||||
auto hops = Anope::Convert(params[1], 0);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params.back(), params[2]);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params.back(), params[2], hops);
|
||||
|
||||
IRCD->SendPing(Me->GetName(), params[0]);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
ListLimits *limits = maxlist.Get(c);
|
||||
if (limits)
|
||||
{
|
||||
ListLimits::const_iterator limit = limits->find(cm->mchar);
|
||||
auto limit = limits->find(cm->mchar);
|
||||
if (limit != limits->end())
|
||||
return limit->second;
|
||||
}
|
||||
@@ -1768,11 +1768,7 @@ struct IRCDMessageSave final
|
||||
if (targ->server == Me && (bi = dynamic_cast<BotInfo *>(targ)))
|
||||
{
|
||||
if (last_collide == Anope::CurTime)
|
||||
{
|
||||
Anope::QuitReason = "Nick collision fight on " + targ->nick;
|
||||
Anope::Quitting = true;
|
||||
return;
|
||||
}
|
||||
throw ProtocolException("Nick collision fight on " + targ->nick);
|
||||
|
||||
IRCD->SendKill(Me, targ->nick, "Nick collision");
|
||||
IRCD->SendNickChange(targ, targ->nick);
|
||||
@@ -2352,7 +2348,7 @@ struct IRCDMessageServer final
|
||||
* 2: numeric
|
||||
* 3: desc
|
||||
*/
|
||||
new Server(Me, params[0], 0, params.back(), params[2]);
|
||||
new Server(Me, params[0], params.back(), params[2]);
|
||||
}
|
||||
else if (source.GetServer())
|
||||
{
|
||||
@@ -2363,7 +2359,7 @@ struct IRCDMessageServer final
|
||||
* 2 to N-1: various key=value pairs.
|
||||
* N: desc
|
||||
*/
|
||||
new Server(source.GetServer(), params[0], 1, params.back(), params[1]);
|
||||
new Server(source.GetServer(), params[0], params.back(), params[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2416,7 +2412,7 @@ struct IRCDMessageUID final
|
||||
|
||||
NickAlias *na = NULL;
|
||||
if (SASL::service)
|
||||
for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();)
|
||||
for (auto it = saslusers.begin(); it != saslusers.end();)
|
||||
{
|
||||
SASLUser &u = *it;
|
||||
|
||||
|
||||
@@ -542,13 +542,13 @@ struct IRCDMessageServer final
|
||||
if (params.size() == 3)
|
||||
{
|
||||
// our uplink is introducing itself
|
||||
new Server(Me, params[0], 1, params[2], "1");
|
||||
new Server(Me, params[0], params[2], "1", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// our uplink is introducing a new server
|
||||
auto hops = Anope::Convert<unsigned>(params[1], 0);
|
||||
new Server(source.GetServer(), params[0], hops, params[3], params[2]);
|
||||
new Server(source.GetServer(), params[0], params[3], params[2], hops);
|
||||
}
|
||||
/*
|
||||
* ngIRCd does not send an EOB, so we send a PING immediately
|
||||
|
||||
@@ -287,7 +287,7 @@ struct IRCDMessageServer final
|
||||
if (params[1] != "1")
|
||||
return;
|
||||
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params[2], UplinkSID, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ struct IRCDMessageServer final
|
||||
// Servers other then our immediate uplink are introduced via SID
|
||||
if (params[1] != "1")
|
||||
return;
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params[2], UplinkSID, 1);
|
||||
IRCD->SendPing(Me->GetName(), params[0]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -400,7 +400,7 @@ struct IRCDMessageServer final
|
||||
// Servers other then our immediate uplink are introduced via SID
|
||||
if (params[1] != "1")
|
||||
return;
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params[2], UplinkSID, 1);
|
||||
IRCD->SendPing(Me->GetName(), params[0]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace UnrealExtBan
|
||||
Anope::string xbname;
|
||||
|
||||
public:
|
||||
Base(const Anope::string &mname, const Anope::string& uname, char uchar)
|
||||
Base(const Anope::string &mname, const Anope::string &uname, char uchar)
|
||||
: ChannelModeVirtual<ChannelModeList>(mname, "BAN")
|
||||
, xbchar(uchar)
|
||||
, xbname(uname)
|
||||
@@ -640,7 +640,7 @@ namespace UnrealExtBan
|
||||
|
||||
bool Matches(User *u, const Entry *e) override
|
||||
{
|
||||
ModData *moddata = u->GetExt<ModData>("ClientModData");
|
||||
auto *moddata = u->GetExt<ModData>("ClientModData");
|
||||
return moddata != NULL && moddata->find("operclass") != moddata->end() && Anope::Match((*moddata)["operclass"], e->GetMask());
|
||||
}
|
||||
};
|
||||
@@ -674,7 +674,7 @@ namespace UnrealExtBan
|
||||
|
||||
bool Matches(User *u, const Entry *e) override
|
||||
{
|
||||
ModData *moddata = u->GetExt<ModData>("ClientModData");
|
||||
auto *moddata = u->GetExt<ModData>("ClientModData");
|
||||
if (moddata == NULL || moddata->find("geoip") == moddata->end())
|
||||
return false;
|
||||
|
||||
@@ -1455,10 +1455,10 @@ struct IRCDMessageServer final
|
||||
Anope::string desc;
|
||||
spacesepstream(params[2]).GetTokenRemainder(desc, 1);
|
||||
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, desc, UplinkSID);
|
||||
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], desc, UplinkSID, hops);
|
||||
}
|
||||
else
|
||||
new Server(source.GetServer(), params[0], hops, params[2]);
|
||||
new Server(source.GetServer(), params[0], params[2], hops);
|
||||
|
||||
IRCD->SendPing(Me->GetName(), params[0]);
|
||||
}
|
||||
@@ -1473,7 +1473,7 @@ struct IRCDMessageSID final
|
||||
{
|
||||
auto hops = Anope::Convert<unsigned>(params[1], 0);
|
||||
|
||||
new Server(source.GetServer(), params[0], hops, params[3], params[2]);
|
||||
new Server(source.GetServer(), params[0], params[3], params[2], hops);
|
||||
|
||||
IRCD->SendPing(Me->GetName(), params[0]);
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ class ModuleProxyScan final
|
||||
|
||||
void Tick() override
|
||||
{
|
||||
for (std::set<ProxyConnect *>::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;)
|
||||
for (auto it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;)
|
||||
{
|
||||
ProxyConnect *p = *it;
|
||||
++it;
|
||||
@@ -246,19 +246,19 @@ public:
|
||||
|
||||
~ModuleProxyScan() override
|
||||
{
|
||||
for (std::set<ProxyConnect *>::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;)
|
||||
for (auto it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;)
|
||||
{
|
||||
ProxyConnect *p = *it;
|
||||
++it;
|
||||
delete p;
|
||||
}
|
||||
|
||||
for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
|
||||
for (auto it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
|
||||
{
|
||||
Socket *s = it->second;
|
||||
++it;
|
||||
|
||||
ClientSocket *cs = dynamic_cast<ClientSocket *>(s);
|
||||
auto *cs = dynamic_cast<ClientSocket *>(s);
|
||||
if (cs != NULL && cs->ls == this->listener)
|
||||
delete s;
|
||||
}
|
||||
|
||||
+3
-3
@@ -473,7 +473,7 @@ bool RedisSocket::Read(const char *buffer, size_t l)
|
||||
* __keyevent@0__:set
|
||||
* key
|
||||
*/
|
||||
std::map<Anope::string, Interface *>::iterator it = this->subinterfaces.find(r.multi_bulk[1]->bulk);
|
||||
auto it = this->subinterfaces.find(r.multi_bulk[1]->bulk);
|
||||
if (it != this->subinterfaces.end())
|
||||
it->second->OnResult(r);
|
||||
}
|
||||
@@ -553,14 +553,14 @@ public:
|
||||
const Anope::string &n = redis.Get<const Anope::string>("name"),
|
||||
&ip = redis.Get<const Anope::string>("ip");
|
||||
int port = redis.Get<int>("port");
|
||||
unsigned db = redis.Get<unsigned>("db");
|
||||
auto db = redis.Get<unsigned>("db");
|
||||
|
||||
delete services[n];
|
||||
services[n] = new MyRedisService(this, n, ip, port, db);
|
||||
new_services.push_back(n);
|
||||
}
|
||||
|
||||
for (std::map<Anope::string, MyRedisService *>::iterator it = services.begin(); it != services.end();)
|
||||
for (auto it = services.begin(); it != services.end();)
|
||||
{
|
||||
Provider *p = it->second;
|
||||
++it;
|
||||
|
||||
+15
-10
@@ -28,11 +28,11 @@ class SaveData final
|
||||
: public Serialize::Data
|
||||
{
|
||||
public:
|
||||
Anope::map<std::stringstream> data;
|
||||
Anope::unordered_map<Anope::string> data;
|
||||
|
||||
std::iostream &operator[](const Anope::string &key) override
|
||||
bool LoadInternal(const Anope::string &key, Anope::string &value) override
|
||||
{
|
||||
return data[key];
|
||||
return false; // This module can only store data.
|
||||
}
|
||||
|
||||
static void Serialize(const Extensible *e, const Serializable *s, RPC::Map &map)
|
||||
@@ -41,32 +41,37 @@ public:
|
||||
Extensible::ExtensibleSerialize(e, s, data);
|
||||
for (const auto &[k, v] : data.data)
|
||||
{
|
||||
auto vs = v.str();
|
||||
switch (data.GetType(k))
|
||||
{
|
||||
case Serialize::DataType::BOOL:
|
||||
map.Reply(k, Anope::Convert<bool>(vs, false));
|
||||
map.Reply(k, Anope::Convert<bool>(v, false));
|
||||
break;
|
||||
case Serialize::DataType::FLOAT:
|
||||
map.Reply(k, Anope::Convert<double>(vs, 0.0));
|
||||
map.Reply(k, Anope::Convert<double>(v, 0.0));
|
||||
break;
|
||||
case Serialize::DataType::INT:
|
||||
map.Reply(k, Anope::Convert<int64_t>(vs, 0));
|
||||
map.Reply(k, Anope::Convert<int64_t>(v, 0));
|
||||
break;
|
||||
case Serialize::DataType::TEXT:
|
||||
{
|
||||
if (vs.empty())
|
||||
if (v.empty())
|
||||
map.Reply(k, nullptr);
|
||||
else
|
||||
map.Reply(k, vs);
|
||||
map.Reply(k, v);
|
||||
break;
|
||||
}
|
||||
case Serialize::DataType::UINT:
|
||||
map.Reply(k, Anope::Convert<uint64_t>(vs, 0));
|
||||
map.Reply(k, Anope::Convert<uint64_t>(v, 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool StoreInternal(const Anope::string &key, const Anope::string &value) override
|
||||
{
|
||||
data[key] = value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class AnopeListAccountsRPCEvent final
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user