Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 5259c95

Browse files
author
DirectiveAthena
committed
Update twitch_bot_protocol.py
1 parent ab1ef77 commit 5259c95

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/AthenaTwitchBot/models/twitch_bot_protocol.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)