@@ -62,7 +62,9 @@ function __construct(array $options = [])
6262 $ this ->loop = $ options ['loop ' ];
6363 $ this ->secret = $ options ['secret ' ];
6464 $ this ->nick = $ options ['nick ' ];
65- $ this ->channel = strtolower ($ options ['channel ' ]) ?? strtolower ($ options ['nick ' ]);
65+ foreach ($ options ['channel ' ] as $ channel )
66+ $ this ->channel [] = strtolower ($ channel );
67+ if (is_null ($ this ->channel )) $ this ->channel = $ options ['nick ' ];
6668 $ this ->commandsymbol = $ options ['commandsymbol ' ] ?? array ('! ' );
6769
6870 foreach ($ options ['whitelist ' ] as $ whitelist ){
@@ -112,13 +114,13 @@ public function close(bool $closeLoop = true): void
112114
113115 public function sendMessage (string $ data , string $ channel = null ): void
114116 {
115- $ this ->connection ->write ("PRIVMSG # " . ($ channel ?? $ this ->channel ) . " : " . $ data . "\n" );
116- $ this ->emit (" [REPLY] $ data" );
117+ $ this ->connection ->write ("PRIVMSG # " . ($ channel ?? $ this ->reallastchannel ) . " : " . $ data . "\n" );
118+ $ this ->emit (' [REPLY] # ' . ( $ channel ?? $ this -> reallastchannel ) . ' - ' . $ data );
117119 }
118120
119121 public function joinChannel (string $ string ): void
120122 {
121- $ connection ->write ("JOIN # " . strtolower ($ string ) . "\n" );
123+ $ this -> connection ->write ("JOIN # " . strtolower ($ string ) . "\n" );
122124 if ($ this ->verbose ) $ this ->emit ('[VERBOSE] [JOINCHANNEL] ` ' . strtolower ($ string ) . '` ' );
123125 }
124126
@@ -166,7 +168,8 @@ protected function initIRC(ConnectionInterface $connection): void
166168 $ connection ->write ("PASS " . $ this ->secret . "\n" );
167169 $ connection ->write ("NICK " . $ this ->nick . "\n" );
168170 $ connection ->write ("CAP REQ :twitch.tv/membership \n" );
169- $ connection ->write ("JOIN # " . $ this ->channel . "\n" );
171+ foreach ($ this ->channel as $ channel )
172+ $ connection ->write ("JOIN # " . $ channel . "\n" );
170173 if ($ this ->verbose ) $ this ->emit ('[INIT IRC] ' );
171174 }
172175
@@ -189,7 +192,7 @@ protected function process(string $data, ConnectionInterface $connection): void
189192 if ($ response ) {
190193 $ payload = '@ ' . $ this ->lastuser . ', ' . $ response . "\n" ;
191194 $ this ->sendMessage ($ payload );
192- $ this ->discordRelay ('[REPLY] ' . $ payload );
195+ $ this ->discordRelay ('[REPLY] # ' . $ this -> reallastchannel . ' - ' . $ payload );
193196 }
194197 }
195198 }
@@ -204,7 +207,7 @@ protected function parseMessage(string $data): ?string
204207 $ this ->lastmessage = $ messageContents ;
205208 $ this ->reallastuser = $ this ->parseUser ($ data );
206209 $ this ->reallastchannel = $ this ->parseChannel ($ data );
207- $ this ->discordRelay ('[MSG] ' . $ this ->reallastuser . ': ' . $ messageContents );
210+ $ this ->discordRelay ('[MSG] # ' . $ this -> reallastchannel . ' - ' . $ this ->reallastuser . ': ' . $ messageContents );
208211
209212 $ commandsymbol = '' ;
210213 foreach ($ this ->commandsymbol as $ symbol ) {
@@ -224,22 +227,22 @@ protected function parseMessage(string $data): ?string
224227 //Public commands
225228 if (in_array ($ command , $ this ->functions )) {
226229 if ($ this ->verbose ) $ this ->emit ('[FUNCTION] ' );
227- $ response = $ this ->commands ->handle ($ command );
230+ $ response = $ this ->commands ->handle ($ command, $ dataArr );
228231 }
229232
230233 //Whitelisted commands
231234 if ( in_array ($ this ->lastuser , $ this ->whitelist ) || ($ this ->lastuser == $ this ->nick ) ) {
232235 if (in_array ($ command , $ this ->restricted_functions )) {
233236 if ($ this ->verbose ) $ this ->emit ('[RESTRICTED FUNCTION] ' );
234- $ response = $ this ->commands ->handle ($ command );
237+ $ response = $ this ->commands ->handle ($ command, $ dataArr );
235238 }
236239 }
237240
238241 //Bot owner commands (shares the same username)
239242 if ($ this ->lastuser == $ this ->nick ) {
240243 if (in_array ($ command , $ this ->private_functions )) {
241244 if ($ this ->verbose ) $ this ->emit ('[PRIVATE FUNCTION] ' );
242- $ response = $ this ->commands ->handle ($ command );
245+ $ response = $ this ->commands ->handle ($ command, $ dataArr );
243246 }
244247 }
245248
0 commit comments