1
- import org .codeoverflow .chatoverflow .api .io .input .chat .TwitchChatInput
2
- import org .codeoverflow .chatoverflow .api .plugin .configuration .{ParameterRequirement , Requirements , SourceRequirement }
1
+ import org .codeoverflow .chatoverflow .api .plugin .configuration .Requirements
3
2
import org .codeoverflow .chatoverflow .api .plugin .{Plugin , PluginManager }
4
3
5
4
class simpletestPlugin (manager : PluginManager ) extends Plugin {
6
5
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" ))
6
+ private val require = new Requirements
7
+ private val twitchChatInput = require.input.requireTwitchChatInput(" reqTwitch" , " A twitch channel" , false )
8
+ private val nameToSayHelloTo = require.parameter.requireString(" reqHello" , " Your name" , true )
23
9
24
10
override def start (): Unit = {
25
11
println(" Started successfully!" )
26
12
println(s " Dummy message is: ${manager.getDummyMessage}" )
27
13
28
- val chatInput = config.getInputRequirement(" Twitch Channel" ).getSource.asInstanceOf [TwitchChatInput ]
29
- chatInput.registerMessageHandler(msg => println(msg))
14
+ twitchChatInput.getValue.registerMessageHandler(msg => println(msg))
30
15
31
- println(s " Param: ${config.getParameterRequirement( " Some name " ).getParameter} " )
16
+ println(s " Hello ${nameToSayHelloTo.getValue} ! " )
32
17
33
18
while (true ) {
34
19
Thread .sleep(10 )
35
20
}
36
21
}
37
22
38
- override def getRequirements : Requirements = config
23
+ override def getRequirements : Requirements = require
39
24
}
0 commit comments