1
0
Fork 0
mirror of https://gitlab.com/niansa/asbots.git synced 2025-03-06 20:48:25 +01:00

Fixed some desyncs in ChanServ

This commit is contained in:
Nils 2021-06-28 13:26:56 +02:00
parent 2433f56852
commit 58753858b4
2 changed files with 10 additions and 2 deletions

View file

@ -78,6 +78,11 @@ struct ModeSet {
}
return o.str();
}
bool listModeExists(char character, std::string_view value) {
return std::find_if(params.begin(), params.end(), [&] (const auto o) {
return std::get<0>(o) == character && std::get<1>(o) == value;
}) != params.end();
}
template<bool channelModes>
void parse(std::string_view str, NetworkInfo& netInfo);
};

View file

@ -64,7 +64,10 @@ async::result<void> ChanServ::intitialize() {
channel = res->get();
}
// Check if user is operator in the channel
// TODO
if (!channel->mode.listModeExists('o', sender->uid.str())) {
co_await i->send_event(user.get_notice("Error: You need to be an operator in {} to be able to perform a registeration!"_format(args[0]), sender->uid));
co_return;
}
// Check that account does not exist already
{
auto channelregs_found = storage->get_all<ChannelReg>(where(c(&ChannelReg::name) == std::string(args[0])));
@ -94,7 +97,7 @@ async::result<void> ChanServ::initializeChannel(Channel *channel, const ChannelR
// Get all owners nicks mode +o
ModeSet initialModes;
for (const auto& member : channel->members) {
if (member->loginName.has_value() && member->loginName.value() == channelReg.owner) {
if (member->loginName.has_value() && member->loginName.value() == channelReg.owner && !channel->mode.listModeExists('o', member->uid.str())) {
initialModes.parse<true>("+o {}"_format(member->uid.str()), i->netInfo);
}
}