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
3030 }
3131
3232 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
3536 }
3637
3738 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)
4042 }
4143
4244 override def getUniqueTypeString : String = this .getClass.getName
4345
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}"
4554
4655 private def getConfig : Configuration = {
4756
You can’t perform that action at this time.
0 commit comments