@@ -45,29 +45,30 @@ def connection_made(self, transport: asyncio.transports.Transport) -> None:
4545 self .transport .write (messages .request_tags )
4646
4747 def data_received (self , data : bytearray ) -> None :
48- match (twitch_message := self .message_constructor (data , bot_name = self .bot .nickname )):
49- # Keepalive messages : https://dev.twitch.tv/docs/irc#keepalive-messages
50- case TwitchMessagePing ():
51- print (ForeNest .ForestGreen ("PINGED BY TWITCH" ))
52- self .transport .write (pong_message := messages .pong (message = twitch_message .text ))
53- print (pong_message )
48+ for message in data .split (b"\r \n " ):
49+ match (twitch_message := self .message_constructor (message , bot_name = self .bot .nickname )):
50+ # Keepalive messages : https://dev.twitch.tv/docs/irc#keepalive-messages
51+ case TwitchMessagePing ():
52+ print (ForeNest .ForestGreen ("PINGED BY TWITCH" ))
53+ self .transport .write (pong_message := messages .pong (message = twitch_message .text ))
54+ print (pong_message )
5455
55- # catch a message which starts with a command:
56- case TwitchMessage (message = [_,_,_,str (user_message ),* user_message_other ]) if user_message .startswith (f":{ self .bot .prefix } " ):
57- user_message :str
58- print (ForeNest .ForestGreen ("COMMAND CAUGHT" ))
59- try :
60- user_cmd = user_message .replace (f":{ self .bot .prefix } " , "" )
61- result = self .bot .commands [user_cmd ](self = self .bot ,transport = self .transport )
62- print (result )
63- except KeyError :
64- pass
56+ # catch a message which starts with a command:
57+ case TwitchMessage (message = [_,_,_,str (user_message ),* user_message_other ]) if user_message .startswith (f":{ self .bot .prefix } " ):
58+ user_message :str
59+ print (ForeNest .ForestGreen ("COMMAND CAUGHT" ))
60+ try :
61+ user_cmd = user_message .replace (f":{ self .bot .prefix } " , "" )
62+ result = self .bot .commands [user_cmd ](self = self .bot ,transport = self .transport )
63+ print (result )
64+ except KeyError :
65+ pass
6566
66- # catch a message which has a command within it:
67- case TwitchMessage (message = [_,_,_,* messages_parts ]):
68- for message in messages_parts :
69- if message .startswith (self .bot .prefix ):
70- print (ForeNest .ForestGreen ("COMMAND CAUGHT" ))
67+ # catch a message which has a command within it:
68+ case TwitchMessage (message = [_,_,_,* messages_parts ]):
69+ for message in messages_parts :
70+ if message .startswith (self .bot .prefix ):
71+ print (ForeNest .ForestGreen ("COMMAND CAUGHT" ))
7172
7273 def connection_lost (self , exc : Exception | None ) -> None :
7374 self .main_loop .stop ()
0 commit comments