|
@@ -0,0 +1,20 @@
|
|
|
+package org.congressodeiradicali.karlmarx
|
|
|
+
|
|
|
+import com.bot4s.telegram.api.declarative.{CommandFilterMagnet, CommandImplicits}
|
|
|
+
|
|
|
+import scala.concurrent.{ExecutionContext, Future}
|
|
|
+
|
|
|
+class PluginManagerPlugin(localizer: Localizer, bot: Bot) extends Plugin with CommandImplicits {
|
|
|
+ override var handlers: Map[CommandFilterMagnet, Handler] = Map {
|
|
|
+ stringToCommandFilter("enable") -> { msg =>
|
|
|
+ val response = msg.text.map {
|
|
|
+ case "echo" => Some(new EchoPlugin(localizer, bot))
|
|
|
+ case "ban" => Some(new BanPlugin(localizer, bot))
|
|
|
+ case _ => None
|
|
|
+ }.map {
|
|
|
+ case Some(plugin) => bot.plugins :+= plugin; "Added."
|
|
|
+ }
|
|
|
+ Future { response }(ExecutionContext.global)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|