mirror of
https://github.com/anope/anope.git
synced 2026-06-12 17:04:47 +02:00
Allow importing custom Atheme metadata to {cs,ns}_set_misc.
This commit is contained in:
@@ -1084,6 +1084,34 @@ mail
|
||||
* The file that db_atheme will import your main database from.
|
||||
*/
|
||||
database = "atheme.db"
|
||||
|
||||
/*
|
||||
* If you have custom data in your Atheme database that you want converted
|
||||
* to Anope misc data to be shown with cs_set_misc you can configure that
|
||||
* using one or more cs_set_misc blocks.
|
||||
*/
|
||||
#cs_set_misc
|
||||
{
|
||||
/* The key name used by Atheme. */
|
||||
atheme = "private:misc:data"
|
||||
|
||||
/* The cs_set_misc entry to import into. */
|
||||
anope = "MISC_DATA"
|
||||
}
|
||||
|
||||
/*
|
||||
* If you have custom data in your Atheme database that you want converted
|
||||
* to Anope misc data to be shown with ns_set_misc you can configure that
|
||||
* using one or more ns_set_misc blocks.
|
||||
*/
|
||||
#ns_set_misc
|
||||
{
|
||||
/* The key name used by Atheme. */
|
||||
atheme = "private:misc:data"
|
||||
|
||||
/* The ns_set_misc entry to import into. */
|
||||
anope = "MISC_DATA"
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
## Changes
|
||||
|
||||
* The db_atheme module can now import arbitrary metadata to fields from the ns_set_misc module.
|
||||
|
||||
* The regex_posix module is now available on Windows (using the PCRE2 POSIX compatibility layer).
|
||||
|
||||
* The regex_tre module is now available on Windows.
|
||||
|
||||
@@ -170,6 +170,8 @@ private:
|
||||
ServiceReference<XLineManager> sglinemgr;
|
||||
ServiceReference<XLineManager> snlinemgr;
|
||||
ServiceReference<XLineManager> sqlinemgr;
|
||||
Anope::map<Anope::string> csmiscdata;
|
||||
Anope::map<Anope::string> nsmiscdata;
|
||||
|
||||
Anope::map<std::function<bool(DBAtheme*,AthemeRow&)>> rowhandlers = {
|
||||
{ "AC", &DBAtheme::HandleIgnore },
|
||||
@@ -1080,7 +1082,26 @@ private:
|
||||
data->data = value;
|
||||
}
|
||||
else
|
||||
Log(this) << "Unknown channel metadata for " << ci->name << ": " << key << " = " << value;
|
||||
{
|
||||
auto it = csmiscdata.find(key);
|
||||
if (it == csmiscdata.end())
|
||||
{
|
||||
Log(this) << "Unknown channel metadata for " << ci->name << ": " << key << " = " << value;
|
||||
return true;
|
||||
}
|
||||
|
||||
ExtensibleRef<MiscData> extref("cs_set_misc:" + it->second);
|
||||
if (!extref)
|
||||
{
|
||||
Log(this) << "Unknown imported channel metadata for " << ci->name << ": " << it->second << " = " << value;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto *data = extref->Set(ci);
|
||||
data->object = ci->name;
|
||||
data->name = it->second;
|
||||
data->data = value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1193,7 +1214,26 @@ private:
|
||||
data->data = value;
|
||||
}
|
||||
else
|
||||
Log(this) << "Unknown account metadata for " << nc->display << ": " << key << " = " << value;
|
||||
{
|
||||
auto it = nsmiscdata.find(key);
|
||||
if (it == nsmiscdata.end())
|
||||
{
|
||||
Log(this) << "Unknown public account metadata for " << nc->display << ": " << key << " = " << value;
|
||||
return true;
|
||||
}
|
||||
|
||||
ExtensibleRef<MiscData> extref("ns_set_misc:" + it->second);
|
||||
if (!extref)
|
||||
{
|
||||
Log(this) << "Unknown imported account metadata for " << nc->display << ": " << key << " = " << value;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto *data = extref->Set(nc);
|
||||
data->object = nc->display;
|
||||
data->name = it->second;
|
||||
data->data = value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1541,6 +1581,28 @@ public:
|
||||
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
const auto &modconf = conf.GetModule(this);
|
||||
|
||||
csmiscdata.clear();
|
||||
for (auto idx = 0; idx < modconf.CountBlock("cs_set_misc"); ++idx)
|
||||
{
|
||||
const auto &data = modconf.GetBlock("cs_set_misc", idx);
|
||||
const auto &anope = data.Get<const Anope::string>("anope");
|
||||
const auto &atheme = data.Get<const Anope::string>("atheme");
|
||||
if (!anope.empty() && !atheme.empty())
|
||||
csmiscdata[atheme] = anope.upper();
|
||||
}
|
||||
|
||||
nsmiscdata.clear();
|
||||
for (auto idx = 0; idx < modconf.CountBlock("ns_set_misc"); ++idx)
|
||||
{
|
||||
const auto &data = modconf.GetBlock("ns_set_misc", idx);
|
||||
const auto &anope = data.Get<const Anope::string>("anope");
|
||||
const auto &atheme = data.Get<const Anope::string>("atheme");
|
||||
if (!anope.empty() && !atheme.empty())
|
||||
nsmiscdata[atheme] = anope.upper();
|
||||
}
|
||||
|
||||
flags.clear();
|
||||
for (int i = 0; i < Config->CountBlock("privilege"); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user