mirror of
https://github.com/Syping/dtranslatebot.git
synced 2025-09-11 11:16:38 +02:00
/translate supports multiple targets now
This commit is contained in:
parent
9f995a129c
commit
9202f7ce00
3 changed files with 90 additions and 9 deletions
|
@ -265,12 +265,6 @@ uint16_t settings::avatar_size()
|
|||
|
||||
const channel* settings::get_channel(const guild *guild, dpp::snowflake channel_id) const
|
||||
{
|
||||
if (!m_externallyLockedCount) {
|
||||
#ifndef NDEBUG
|
||||
std::cerr << "[Debug] settings::get_channel(const guild*, dpp::snowflake) have being called without settings being locked." << std::endl;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
for (auto channel = guild->channel.begin(); channel != guild->channel.end(); channel++) {
|
||||
if (channel->id == channel_id)
|
||||
return &*channel;
|
||||
|
@ -313,6 +307,40 @@ const guild* settings::get_guild(dpp::snowflake guild_id) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const target* settings::get_target(dpp::snowflake guild_id, dpp::snowflake channel_id, const std::string &target) const
|
||||
{
|
||||
if (!m_externallyLockedCount) {
|
||||
#ifndef NDEBUG
|
||||
std::cerr << "[Debug] settings::get_target(dpp::snowflake, dpp::snowflake, const std::string&) have being called without settings being locked." << std::endl;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
for (auto guild = m_guilds.begin(); guild != m_guilds.end(); guild++) {
|
||||
if (guild->id == guild_id) {
|
||||
for (auto channel = guild->channel.begin(); channel != guild->channel.end(); channel++) {
|
||||
if (channel->id == channel_id) {
|
||||
for (auto _target = channel->targets.begin(); _target != channel->targets.end(); _target++) {
|
||||
if (_target->target == target)
|
||||
return &*_target;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const target* settings::get_target(const channel *channel, const std::string &target) const
|
||||
{
|
||||
for (auto _target = channel->targets.begin(); _target != channel->targets.end(); _target++) {
|
||||
if (_target->target == target)
|
||||
return &*_target;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector<std::string> settings::preferred_languages() const
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
|
@ -434,7 +462,7 @@ bool settings::parse_file(const std::string &filename)
|
|||
std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
|
||||
ifs.close();
|
||||
|
||||
return parse(std::move(sdata));
|
||||
return parse(sdata);
|
||||
}
|
||||
|
||||
void settings::unlock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue