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

Commit 0b6840d

Browse files
author
DirectiveAthena
committed
Fix: various to get working
1 parent cb9eb54 commit 0b6840d

File tree

6 files changed

+57
-16
lines changed

6 files changed

+57
-16
lines changed

src/AthenaTwitchBot/decorators/scheduled_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def wrapper(*args, **kwargs):
4949
elif isinstance(channel, TwitchChannel):
5050
channels.append(c)
5151
else:
52-
return NotImplemented(channel)
52+
return NotImplemented
5353
else:
54-
return NotImplemented(channel)
54+
return NotImplemented
5555

5656
wrapper.tsk = ScheduledTask(
5757
delay=convert_time_to_seconds(delay,to_int=True),

src/AthenaTwitchBot/functions/launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def launch(
3434
if outputs is None:
3535
outputs=[OutputTwitch()]
3636
# thanks for fikotta for pointing me to use isinstance here
37-
elif not any(isinstance(o, OutputTwitch) for o in outputs):
37+
if not any(isinstance(o, OutputTwitch) for o in outputs):
3838
# always make sure OutputTwitch callbacks are the first to be made
3939
outputs.insert(0,OutputTwitch())
40-
elif not any(isinstance(o, OutputConsole) for o in outputs) and console_enabled:
40+
if not any(isinstance(o, OutputConsole) for o in outputs) and console_enabled:
4141
# placement of the Console does not matter
4242
outputs.append(OutputConsole())
4343

src/AthenaTwitchBot/models/outputs/output.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ async def connection_ping(self, transport: asyncio.transports.Transport, ping_re
2626

2727
@abstractmethod
2828
async def undefined(self,text:str, **kwargs):
29-
"""Output response to anything that wasn't caught correctly"""
29+
"""Output response to anything that wasn't caught correctly"""
30+
31+
@abstractmethod
32+
async def command(self,context, **kwargs):
33+
"""Output response to a command that was given to the bot by a viewer"""

src/AthenaTwitchBot/models/outputs/output_console.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ async def connection_ping(self,**kwargs):
3030
print(ForeNest.ForestGreen("PING RECEIVED"))
3131

3232
async def undefined(self,text:str,**kwargs):
33-
print(ForeNest.SlateGray(text),)
33+
print(ForeNest.SlateGray(text),)
34+
35+
async def command(self,context, **kwargs):
36+
pass

src/AthenaTwitchBot/models/outputs/output_twitch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ class OutputTwitch(Output):
2121
async def connection_made(self, bot:TwitchBot, transport: asyncio.transports.Transport,**kwargs):
2222
transport.write(format_message(f"{PASS}{bot.oauth_token}"))
2323
transport.write(format_message(f"{NICK} {bot.nickname}"))
24-
transport.write(format_message(f"{JOIN} {','.join(bot.channels)}"))
24+
transport.write(format_message(f"{JOIN} {','.join(str(c) for c in bot.channels)}"))
2525
transport.write(format_message(REQUEST_TAGS))
2626

2727
async def connection_ping(self, transport: asyncio.transports.Transport, ping_response:list[str], **kwargs):
2828
transport.write(format_message(f"{PONG} {' '.join(ping_response)}"))
2929

3030
async def undefined(self,**kwargs):
31-
pass # don't answer to something that is undefined
31+
pass # don't answer to something that is undefined
32+
33+
async def command(self,context, **kwargs):
34+
pass

src/AthenaTwitchBot/models/twitch_bot_protocol.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Callable
99

1010
# Custom Library
11+
from AthenaColor import ForeNest
1112

1213
# Custom Packages
1314
from AthenaTwitchBot.models.twitch_message import TwitchMessage
@@ -113,7 +114,8 @@ def data_parser(self, data: bytearray):
113114
for d in data.decode("utf_8").split("\r\n"):
114115
# catch some patterns early to be either ignored or parsed
115116
match d_split:= d.split(" "):
116-
case PING(), *ping_response:
117+
case _ping, *ping_response \
118+
if _ping == PING:
117119
# CATCHES the following pattern:
118120
# PING
119121
# :tmi.twitch.tv
@@ -124,7 +126,8 @@ def data_parser(self, data: bytearray):
124126
)
125127
continue # go to next piece of data
126128

127-
case TMI_TWITCH_TV(), str(int_id), self.bot.nickname, str(text):
129+
case _tmi_twitch_tv, str(int_id), self.bot.nickname, *text \
130+
if _tmi_twitch_tv == TMI_TWITCH_TV:
128131
# CATCHES the following pattern:
129132
# :tmi.twitch.tv
130133
# 001
@@ -138,7 +141,8 @@ def data_parser(self, data: bytearray):
138141
)
139142

140143

141-
case str(info), str(user_name), PRIVMSG(), str(channel), str(text):
144+
case str(info), str(user_name), _privmsg, str(channel), *text \
145+
if _privmsg == PRIVMSG:
142146
# CATCHES the following pattern:
143147
# @badge-info=;badges=;client-nonce=4ac36d90556713038f596be25cc698a2;color=#1E90FF;display-name=badcop_;emotes=;first-msg=0;flags=;id=8b506bf0-517d-4ae7-9dcb-bce5c2145412;mod=0;room-id=600187263;subscriber=0;tmi-sent-ts=1655367514927;turbo=0;user-id=56931496;user-type=
144148
# :badcop_!badcop_@badcop_.tmi.twitch.tv
@@ -152,8 +156,9 @@ def data_parser(self, data: bytearray):
152156
text=" ".join(d_split)
153157
)
154158

155-
case str(bot_name_long), JOIN(), str(channel) \
156-
if bot_name_long == f":{self.bot.nickname}!{self.bot.nickname}@{self.bot.nickname}.tmi.twitch.tv":
159+
case str(bot_name_long), _join, str(channel) \
160+
if _join == JOIN \
161+
and bot_name_long == f":{self.bot.nickname}!{self.bot.nickname}@{self.bot.nickname}.tmi.twitch.tv":
157162
# CATCHES the following pattern:
158163
# :eva_athenabot!eva_athenabot@eva_athenabot.tmi.twitch.tv
159164
# JOIN
@@ -165,7 +170,7 @@ def data_parser(self, data: bytearray):
165170
text=" ".join(d_split)
166171
)
167172

168-
case TMI_TWITCH_TV(), CAP(), ASTERISK(), ACK(), TWITCH_TAGS():
173+
case _list if _list == [TMI_TWITCH_TV, CAP, ASTERISK, ACK, TWITCH_TAGS]:
169174
# CATCHES the following pattern:
170175
# :tmi.twitch.tv
171176
# CAP
@@ -179,8 +184,10 @@ def data_parser(self, data: bytearray):
179184
text=" ".join(d_split)
180185
)
181186

182-
case str(bot_name_long), str(int_id), self.bot.nickname, EQUALS(), str(channel), str(bot_name_short) \
183-
if bot_name_long == f":{self.bot.nickname}.tmi.twitch.tv" and bot_name_short == f":{self.bot.nickname}":
187+
case str(bot_name_long), str(int_id), self.bot.nickname, _equals, str(channel), str(bot_name_short) \
188+
if _equals == EQUALS \
189+
and bot_name_long == f":{self.bot.nickname}.tmi.twitch.tv" \
190+
and bot_name_short == f":{self.bot.nickname}":
184191
# CATCHES the following pattern:
185192
# :eva_athenabot.tmi.twitch.tv
186193
# 353
@@ -195,3 +202,27 @@ def data_parser(self, data: bytearray):
195202
text=" ".join(d_split)
196203
)
197204

205+
case str(bot_name_long), str(int_id), self.bot.nickname, str(channel), *text \
206+
if bot_name_long == f":{self.bot.nickname}.tmi.twitch.tv":
207+
# CATCHES the following pattern:
208+
# :eva_athenabot.tmi.twitch.tv
209+
# 353
210+
# eva_athenabot
211+
# =
212+
# #directiveathena
213+
# :eva_athenabot
214+
pass # todo functionality
215+
self.output_handler(
216+
callback=output_undefined,
217+
# below this point is all **kwargs
218+
text=" ".join(d_split)
219+
)
220+
221+
case _:
222+
self.output_handler(
223+
callback=output_undefined,
224+
# below this point is all **kwargs
225+
text=ForeNest.Maroon("UNDEFINED : '",ForeNest.SlateGray(" ".join(d_split)), "'", sep="")
226+
)
227+
228+

0 commit comments

Comments
 (0)