This repository was archived by the owner on Aug 18, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/main/scala/org/codeoverflow/chatoverflow/requirement/service/twitch/chat Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,27 @@ class TwitchChatConnector(override val sourceIdentifier: String) extends Connect
30
30
}
31
31
32
32
def joinChannel (channel : String ): Unit = {
33
- bot.send().joinChannel(channel)
34
- channels += channel
33
+ val formattedChan = formatChannel(channel)
34
+ bot.send().joinChannel(formattedChan)
35
+ channels += formattedChan
35
36
}
36
37
37
38
def sendChatMessage (channel : String , chatMessage : String ): Unit = {
38
- if (! isJoined(channel)) throw new IllegalArgumentException (s " you must join the ' $channel' channel, before you can send messages to it " )
39
- bot.send().message(channel, chatMessage)
39
+ val formattedChan = formatChannel(channel)
40
+ if (! isJoined(formattedChan)) throw new IllegalArgumentException (s " you must join the ' $channel' channel, before you can send messages to it " )
41
+ bot.send().message(formattedChan, chatMessage)
40
42
}
41
43
42
44
override def getUniqueTypeString : String = this .getClass.getName
43
45
44
- def isJoined (channel : String ): Boolean = channels.contains(channel)
46
+ def isJoined (channel : String ): Boolean = channels.contains(formatChannel(channel))
47
+
48
+ /**
49
+ * Ensures that the channel is in following format: "#lowercasename"
50
+ * @param chan the unmodified channel
51
+ * @return the channel in the correct format, changes nothing if already correct
52
+ */
53
+ private def formatChannel (chan : String ): String = s " # ${chan.stripPrefix(" #" ).toLowerCase}"
45
54
46
55
private def getConfig : Configuration = {
47
56
You can’t perform that action at this time.
0 commit comments