/
MockChat.kt
61 lines (55 loc) · 1.36 KB
/
MockChat.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.github.twitch4j.kotlin.mock
import com.github.philippheuer.credentialmanager.CredentialManagerBuilder
import com.github.philippheuer.events4j.core.EventManager
import com.github.twitch4j.chat.TwitchChat
import com.github.twitch4j.chat.util.TwitchChatLimitHelper
import com.github.twitch4j.common.util.ThreadUtils
/**
* The bare minimum we need to test the TwitchChat extensions
*/
class MockChat : TwitchChat(
null,
EventManager().apply { autoDiscovery() },
CredentialManagerBuilder.builder().build(),
null,
FDGT_TEST_SOCKET_SERVER,
false,
emptyList(),
1,
null,
null,
null,
null,
ThreadUtils.getDefaultScheduledThreadPoolExecutor("MOCK", 1),
1,
null,
false,
false,
null,
false,
100,
1,
0,
null,
TwitchChatLimitHelper.MOD_MESSAGE_LIMIT,
false,
0
) {
@Volatile
var isConnected = false
override fun connect() {
isConnected = true
}
override fun disconnect() {
isConnected = false
}
override fun joinChannel(channelName: String) {
val lowerChannelName = channelName.lowercase()
currentChannels.add(lowerChannelName)
}
override fun leaveChannel(channelName: String): Boolean {
val lowerChannelName = channelName.lowercase()
currentChannels.remove(lowerChannelName)
return true
}
}