(new): rich message support
(fix): runtime reliability (tests): regression coverage (doc): v1.1 release notes
This commit is contained in:
@@ -19,6 +19,12 @@ func (bot *Bot[T]) AddPlugins(plugin ...*Plugin[T]) *Bot[T] {
|
||||
return bot
|
||||
}
|
||||
level := bot.GetLoggerLevel()
|
||||
sceneOwners := make(map[string]string)
|
||||
for _, registered := range bot.plugins {
|
||||
for name := range registered.scenes {
|
||||
sceneOwners[name] = registered.name
|
||||
}
|
||||
}
|
||||
for _, p := range plugin {
|
||||
if p == nil {
|
||||
if bot.logger != nil {
|
||||
@@ -27,6 +33,16 @@ func (bot *Bot[T]) AddPlugins(plugin ...*Plugin[T]) *Bot[T] {
|
||||
continue
|
||||
}
|
||||
cloned := clonePlugin(p)
|
||||
for name := range cloned.scenes {
|
||||
if owner, duplicate := sceneOwners[name]; duplicate {
|
||||
if bot.logger != nil {
|
||||
bot.logger.Warnf("scene %q from plugin %q duplicates plugin %q; skipping", name, cloned.name, owner)
|
||||
}
|
||||
delete(cloned.scenes, name)
|
||||
continue
|
||||
}
|
||||
sceneOwners[name] = cloned.name
|
||||
}
|
||||
if cloned.logger == nil {
|
||||
cloned.logger = utils.CreateLogger(cloned.name, level, bot.logFormat, bot.logFormatter)
|
||||
cloned.loggerOwned = true
|
||||
|
||||
Reference in New Issue
Block a user