mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 10:13:42 +00:00
Fix wrong source when creating new task or event
This commit is contained in:
parent
893fcc11e3
commit
ab2200ecc1
3 changed files with 18 additions and 1 deletions
12
external/mirai-core/src/Mirai.cpp
vendored
12
external/mirai-core/src/Mirai.cpp
vendored
|
@ -149,6 +149,18 @@ Source *Mirai::getSourceById(int id)
|
|||
return source->get();
|
||||
}
|
||||
|
||||
Source *Mirai::getSourceByName(const std::string &name)
|
||||
{
|
||||
auto source = std::ranges::find_if(sources_, [&](const std::unique_ptr<Source> &source) {
|
||||
return source->name() == name;
|
||||
});
|
||||
assert(source != sources_.end()); // This should not happen
|
||||
if (source == sources_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return source->get();
|
||||
}
|
||||
|
||||
void Mirai::onSourceAdded(std::function<void(Source *)> f)
|
||||
{
|
||||
sourceAdded.registerCallback(f);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue