- std::vector<std::string> setban;
- setban.push_back(chan);
- setban.push_back("-b");
- setban.push_back(mask);
-
- CUList empty;
- std::string expiry = "*** Timed ban on " + chan + " expired.";
- cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
- ServerInstance->PI->SendChannelNotice(cr, '@', expiry);
-
- ServerInstance->SendGlobalMode(setban, ServerInstance->FakeClient);
+ const std::string expiry = "*** Timed ban on " + cr->name + " expired.";
+ // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
+ PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
+ char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
+
+ ClientProtocol::Messages::Privmsg notice(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, cr, expiry, MSG_NOTICE);
+ cr->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
+ ServerInstance->PI->SendChannelNotice(cr, pfxchar, expiry);
+
+ Modes::ChangeList setban;
+ setban.push_remove(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), mask);
+ ServerInstance->Modes->Process(ServerInstance->FakeClient, cr, NULL, setban);