1
1
import org .codeoverflow .chatoverflow .api .io .input .chat .TwitchChatInput
2
- import org .codeoverflow .chatoverflow .api .io .input .event .EventInput
3
- import org .codeoverflow .chatoverflow .api .plugin .configuration .{Configuration , ParameterRequirement , SourceRequirement }
2
+ import org .codeoverflow .chatoverflow .api .plugin .configuration .{ParameterRequirement , Requirements , SourceRequirement }
4
3
import org .codeoverflow .chatoverflow .api .plugin .{Plugin , PluginManager }
5
4
6
5
class simpletestPlugin (manager : PluginManager ) extends Plugin {
7
6
8
- val config = new Configuration
9
- config.addInputRequirement(" Twitch Channel" , new SourceRequirement [TwitchChatInput ])
10
- config.addInputRequirement(" Some other stuff" , new SourceRequirement [EventInput ])
11
- // config.addOutputRequirement("Any Channel", new SourceRequirement[ChatOutput])
12
- config.addParameterRequirement(" Some name" , new ParameterRequirement [String ])
7
+ // TODO: Better?
8
+ // val x: Requirement[TwitchChatInput] = config.requireTwitchChatInput("inputReq", "Twitch Channel")
9
+
10
+ val config = new Requirements
11
+
12
+ // VERSION A (Objektorientiert. Vorteil: Typsicher. Nachteil: Für jeden Input/Output eigene Methode in API)
13
+ private val twitchChat = config.requireTwitchChatInput(" inputReq" , " A Twitch channel" )
14
+ twitchChat.getSource.getLastMessages(1000 )
15
+
16
+ // VERSION B (Durch Reflection aufgelöst, Vorteil: Leicht erweiterbar, Nachteil: Nicht typsicher)
17
+ // private val twitchChat2 = config.require(Class[TwitchChatInput], "inputReq2", "A twitch channel")
18
+ // twitchChat2.getSource.asInstanceOf[TwitchChatInput].getLastMessages(1000)
19
+
20
+
21
+ config.addInputRequirement(" Twitch Channel" , new SourceRequirement [TwitchChatInput ](" input" ))
22
+ config.addParameterRequirement(" Some name" , new ParameterRequirement [String ](" helloReq" ))
13
23
14
24
override def start (): Unit = {
15
25
println(" Started successfully!" )
16
26
println(s " Dummy message is: ${manager.getDummyMessage}" )
17
27
18
- val chatInput = config.getInputs.get (" Twitch Channel" ).getSource.asInstanceOf [TwitchChatInput ]
28
+ val chatInput = config.getInputRequirement (" Twitch Channel" ).getSource.asInstanceOf [TwitchChatInput ]
19
29
chatInput.registerMessageHandler(msg => println(msg))
20
30
21
- println(s " Param: ${config.getParameters.get (" Some name" ).getParameter}" )
31
+ println(s " Param: ${config.getParameterRequirement (" Some name" ).getParameter}" )
22
32
23
33
while (true ) {
24
34
Thread .sleep(10 )
25
35
}
26
36
}
27
37
28
- override def getRequirements : Configuration = config
38
+ override def getRequirements : Requirements = config
29
39
}
0 commit comments