Plugin manager plugin listing
This commit is contained in:
parent
41e83b5445
commit
e1af52377c
1 changed files with 23 additions and 8 deletions
|
@ -19,7 +19,7 @@ package org.congressodeiradicali.karlmarx.coreplugins
|
|||
|
||||
import com.bot4s.telegram.api.declarative.{CommandFilterMagnet, CommandImplicits}
|
||||
import com.bot4s.telegram.models.Message
|
||||
import org.congressodeiradicali.karlmarx.{Bot, LocalizableString}
|
||||
import org.congressodeiradicali.karlmarx.{Bot, LocalizableString, Plugin}
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
||||
|
@ -28,6 +28,8 @@ class PluginManagerPlugin(bot: Bot) extends CorePlugin with CommandImplicits {
|
|||
// Todo: disable it when reasonable
|
||||
enabled = true
|
||||
|
||||
private implicit val ec: ExecutionContext = ExecutionContext.global
|
||||
|
||||
override val name = "Plugin Manager"
|
||||
override val description = "Manages other plugins"
|
||||
|
||||
|
@ -53,7 +55,7 @@ class PluginManagerPlugin(bot: Bot) extends CorePlugin with CommandImplicits {
|
|||
else
|
||||
LocalizableString.NO_SUCH_PLUGIN
|
||||
|
||||
Future { Some(bot.localize(response)) }(ExecutionContext.global)
|
||||
Future { Some(bot.localize(response)) }
|
||||
},
|
||||
|
||||
stringToCommandFilter("disable") -> { (_: Message, argv: Array[String]) =>
|
||||
|
@ -63,13 +65,26 @@ class PluginManagerPlugin(bot: Bot) extends CorePlugin with CommandImplicits {
|
|||
else
|
||||
LocalizableString.NO_SUCH_PLUGIN
|
||||
|
||||
Future { Some(bot.localize(response)) }(ExecutionContext.global)
|
||||
Future { Some(bot.localize(response)) }
|
||||
},
|
||||
|
||||
stringToCommandFilter("listplugins") -> { (_, _) =>
|
||||
Future {
|
||||
Some(
|
||||
bot.plugins.values.map { plugin =>
|
||||
s"${plugin.identifier}: ${plugin.name}. ${plugin.description}. License: ${plugin.license}. Author: ${plugin.author}"
|
||||
}.mkString("\n")
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
stringToCommandFilter("listenabled") -> { (_, _) =>
|
||||
Future {
|
||||
Some(
|
||||
bot.plugins.values.filter(_.enabled).map(_.identifier).mkString("\n")
|
||||
)
|
||||
}
|
||||
},
|
||||
/*
|
||||
stringToCommandFilter("plugins") -> { (_: Message, _: Array[String]) =>
|
||||
Future { Some(bot.plugins.values.map("- " + _.name).mkString("\n")) }(ExecutionContext.global)
|
||||
}
|
||||
*/
|
||||
)
|
||||
override var messageHandlers: List[MessageHandler] = List()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue