@@ -39,9 +39,11 @@ class TwitchBotProtocol(asyncio.Protocol):
3939 transport :asyncio .transports .Transport = field (init = False )
4040 message_constructor :Callable = field (init = False )
4141 loop :asyncio .AbstractEventLoop = field (init = False )
42+ PREFIX_FULL :str = field (init = False )
4243
4344 def __post_init__ (self ):
4445 self .loop = asyncio .get_running_loop ()
46+ self .PREFIX_FULL = f":{ self .bot .prefix } "
4547
4648 # ------------------------------------------------------------------------------------------------------------------
4749 # - Support Methods -
@@ -97,7 +99,6 @@ def connection_made(self, transport: asyncio.transports.Transport) -> None:
9799 coro = self .loop .create_task (self .scheduled_task_coro (tsk , channel = channel ))
98100 asyncio .ensure_future (coro , loop = self .loop )
99101
100-
101102 def data_received (self , data : bytearray ) -> None :
102103 self .parse_data (data )
103104
@@ -253,11 +254,9 @@ def parse_data(self, data: bytearray):
253254 # - Message Parsing -
254255 # ------------------------------------------------------------------------------------------------------------------
255256 def parse_user_message (self , context :TwitchContext ) -> TwitchContext :
256- PREFIX_FULL = f":{ self .bot .prefix } "
257-
258- if (cmd_str := context .raw_text [0 ]).startswith (PREFIX_FULL ) and cmd_str != PREFIX_FULL :
257+ if (cmd_str := context .raw_text [0 ]).startswith (self .PREFIX_FULL ) and cmd_str != self .PREFIX_FULL :
259258
260- context .command_str = cmd_str .replace (PREFIX_FULL , "" )
259+ context .command_str = cmd_str .replace (self . PREFIX_FULL , "" )
261260 cmd_str_lower = context .command_str .lower ()
262261
263262 try :
0 commit comments