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

Commit 1a9d610

Browse files
author
DirectiveAthena
committed
Feat: working TwitchContext
1 parent 0b6840d commit 1a9d610

21 files changed

+370
-201
lines changed

src/AthenaTwitchBot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from AthenaTwitchBot.models.twitch_bot import TwitchBot
88
from AthenaTwitchBot.models.twitch_bot_protocol import TwitchBotProtocol
9-
from AthenaTwitchBot.models.twitch_message_context import TwitchMessageContext
9+
from AthenaTwitchBot.models.twitch_context import TwitchContext
1010

1111
from AthenaTwitchBot.functions.launch import launch
1212

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ----------------------------------------------------------------------------------------------------------------------
2+
# - Package Imports -
3+
# ----------------------------------------------------------------------------------------------------------------------
4+
# General Packages
5+
from __future__ import annotations
6+
from typing import Callable
7+
8+
# Custom Library
9+
from AthenaColor import HEX
10+
11+
# Custom Packages
12+
13+
# ----------------------------------------------------------------------------------------------------------------------
14+
# - Code -
15+
# ----------------------------------------------------------------------------------------------------------------------
16+
MESSAGE_TAG_MAPPING:dict[str:Callable] = {
17+
"@badge-info": "badge_info",
18+
"badges": "badges",
19+
"client-nonce": "client_nonce",
20+
"color": "color",
21+
"display-name": "display_name",
22+
"emotes": "emotes",
23+
"first-msg": "first_msg",
24+
"flags": "flags",
25+
"id": "message_id",
26+
"mod": "mod",
27+
"room-id": "room_id",
28+
"subscriber": "subscriber",
29+
"tmi-sent-ts": "tmi_sent_ts",
30+
"turbo": "turbo",
31+
"user-id": "user_id",
32+
"user-type": "user_type",
33+
"reply-parent-display-name": "reply_parent_display_name",
34+
"reply-parent-msg-body": "reply_parent_msg_body",
35+
"reply-parent-msg-id": "reply_parent_msg_id",
36+
"reply-parent-user-id": "reply_parent_user_id",
37+
"reply-parent-user-login": "reply_parent_user_login",
38+
"emote-only": "emote_only",
39+
}
40+
41+
MESSAGE_TAG_CONVERSION_MAPPING:dict[str:Callable] = {
42+
"@badge-info": lambda value: value,
43+
"badges": lambda value: value,
44+
"client-nonce": lambda value: value,
45+
"color": lambda value: HEX(value) if value else HEX(),
46+
"display-name": lambda value: value,
47+
"emotes": lambda value: value,
48+
"first-msg": lambda value: bool(int(value)),
49+
"flags": lambda value: value,
50+
"id": lambda value: value,
51+
"mod": lambda value: bool(int(value)),
52+
"room-id": lambda value: value,
53+
"subscriber": lambda value: bool(int(value)),
54+
"tmi-sent-ts": lambda value: int(value),
55+
"turbo": lambda value: bool(int(value)),
56+
"user-id": lambda value: int(value),
57+
"user-type": lambda value: value,
58+
"reply-parent-display-name":lambda value: value,
59+
"reply-parent-msg-body": lambda value: value,
60+
"reply-parent-msg-id": lambda value: int(value),
61+
"reply-parent-user-id": lambda value: int(value),
62+
"reply-parent-user-login": lambda value: value,
63+
"emote-only": lambda value: bool(int(value)),
64+
}

src/AthenaTwitchBot/data/message_logic.py

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ----------------------------------------------------------------------------------------------------------------------
2+
# - Package Imports -
3+
# ----------------------------------------------------------------------------------------------------------------------
4+
# General Packages
5+
from __future__ import annotations
6+
7+
# Custom Library
8+
9+
# Custom Packages
10+
11+
# ----------------------------------------------------------------------------------------------------------------------
12+
# - All -
13+
# ----------------------------------------------------------------------------------------------------------------------
14+
__all__ = [
15+
"PING_RECEIVED"
16+
]
17+
18+
# ----------------------------------------------------------------------------------------------------------------------
19+
# - Code -
20+
# ----------------------------------------------------------------------------------------------------------------------
21+
PING_RECEIVED = "PING RECEIVED"

src/AthenaTwitchBot/decorators/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Custom Library
88

99
# Custom Packages
10-
from AthenaTwitchBot.models.wrapper_helpers.command import Command
10+
from AthenaTwitchBot.models.decorator_helpers.command import Command
1111

1212
# ----------------------------------------------------------------------------------------------------------------------
1313
# - Code -

src/AthenaTwitchBot/decorators/scheduled_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from AthenaLib.functions.time import convert_time_to_seconds
1010

1111
# Custom Packages
12-
from AthenaTwitchBot.models.wrapper_helpers.scheduled_task import ScheduledTask
12+
from AthenaTwitchBot.models.decorator_helpers.scheduled_task import ScheduledTask
1313
from AthenaTwitchBot.models.twitch_channel import TwitchChannel
1414

1515
from AthenaTwitchBot.data.unions import CHANNEL, CHANNELS

src/AthenaTwitchBot/functions/launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Custom Packages
1212
from AthenaTwitchBot.models.twitch_bot import TwitchBot
1313
from AthenaTwitchBot.models.twitch_bot_protocol import TwitchBotProtocol
14-
from AthenaTwitchBot.models.outputs.output import Output
14+
from AthenaTwitchBot.models.outputs.abstract_output import AbstractOutput
1515
from AthenaTwitchBot.models.outputs.output_twitch import OutputTwitch
1616
from AthenaTwitchBot.models.outputs.output_console import OutputConsole
1717

@@ -22,7 +22,7 @@ def launch(
2222
*, # after this, keywords only
2323
bot:TwitchBot=None,
2424
protocol_factory:Callable=None,
25-
outputs:list[Output]=None,
25+
outputs:list[AbstractOutput]=None,
2626
console_enabled:bool=True,
2727
irc_connection:bool=True,
2828
irc_host:str='irc.chat.twitch.tv',

src/AthenaTwitchBot/functions/output.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,31 @@
77
# Custom Library
88

99
# Custom Packages
10-
from AthenaTwitchBot.models.outputs.output import Output
10+
from AthenaTwitchBot.models.outputs.abstract_output import AbstractOutput
1111

1212
# ----------------------------------------------------------------------------------------------------------------------
1313
# - All -
1414
# ----------------------------------------------------------------------------------------------------------------------
1515
__all__ = [
16-
"output_connection_made", "output_connection_ping", "output_undefined"
16+
"output_connection_made", "output_connection_ping", "output_undefined", "output_scheduled_task", "output_reply",
17+
"output_write"
1718
]
1819

1920
# ----------------------------------------------------------------------------------------------------------------------
2021
# - Code -
2122
# ----------------------------------------------------------------------------------------------------------------------
22-
async def output_connection_made(output:Output, **kwargs):
23+
async def output_connection_made(output:AbstractOutput, **kwargs):
2324
await output.connection_made(**kwargs)
2425

25-
async def output_connection_ping(output:Output, **kwargs):
26+
async def output_connection_ping(output:AbstractOutput, **kwargs):
2627
await output.connection_ping(**kwargs)
2728

28-
async def output_undefined(output:Output, **kwargs):
29-
await output.undefined(**kwargs)
29+
async def output_undefined(output:AbstractOutput, **kwargs):
30+
await output.undefined(**kwargs)
31+
32+
async def output_scheduled_task(output:AbstractOutput, **kwargs):
33+
await output.scheduled_task(**kwargs)
34+
async def output_write(output:AbstractOutput, **kwargs):
35+
await output.write(**kwargs)
36+
async def output_reply(output:AbstractOutput, **kwargs):
37+
await output.reply(**kwargs)

0 commit comments

Comments
 (0)