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

Commit 520ad75

Browse files
author
DirectiveAthena
committed
Fixes: various
1 parent 5259c95 commit 520ad75

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ class newBot(AthenaTwitchBot.TwitchBot):
4141
# - Command -
4242
# A command is only ran when it is invoked by a user in chat
4343
# In the following case this would be by typing "!ping" in chat
44-
@AthenaTwitchBot.command_method(name="ping")
44+
@AthenaTwitchBot.TwitchBotMethod.command(names="ping")
4545
def command_ping(self, context: AthenaTwitchBot.TwitchContext):
46-
context.reply("pong!") # a "context.reply" function will reply to the user whi invoked the command
46+
context.reply("pong!") # a "context.reply" function will reply to the user who invoked the command
4747

4848
# - Task -
4949
# A task is run automatically every "delay" amount of seconds
5050
# In the following case, the method will be run every minute
51-
# The "wait_before" kwarg defines if the asyncio.sleep runs before or after the first call of the callback
52-
@AthenaTwitchBot.scheduled_task_method(delay=60, wait_before=True)
51+
# The "call_on_startup" kwarg defines if the task has to be run on bot startup
52+
@AthenaTwitchBot.TwitchBotMethod.scheduled_task(interval=AthenaLib.models.Minute(1), call_on_startup=True)
5353
def task_post_github(self, context: AthenaTwitchBot.TwitchContext):
5454
context.write(f"This bot is made possible by: https://github.com/DirectiveAthena/AthenaTwitchBot")
5555

5656
# --- Main function ---
5757
def main():
58+
# the launch function handles everything about the protocol setup and command handling
5859
AthenaTwitchBot.launch(
5960
bot=newBot(),
6061
ssl=True # set to true to enable ssl connection to Twitch

src/AthenaTwitchBot/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from AthenaTwitchBot.models.twitch_bot import TwitchBot
55
from AthenaTwitchBot.models.twitch_bot_protocol import TwitchBotProtocol
66
from AthenaTwitchBot.models.twitch_context import TwitchContext
7+
from AthenaTwitchBot.models.twitch_bot_method import TwitchBotMethod
78

89
from AthenaTwitchBot.functions.launch import launch
910

src/AthenaTwitchBot/models/outputs/output_console.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# Custom Packages
1111
from AthenaTwitchBot.models.outputs.abstract_output import AbstractOutput
12+
# noinspection PyProtectedMember
1213
from AthenaTwitchBot._info._v import VERSION
1314

1415
from AthenaTwitchBot.data.output_console import PING_RECEIVED

src/AthenaTwitchBot/models/twitch_bot_method.py

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

99
# Custom Library
10-
from AthenaLib.models import Second, Minute, Hour
11-
from AthenaLib.functions.time import convert_time_to_seconds
10+
from AthenaLib.models import Hour
11+
from AthenaLib.models.time import TimeValue
1212

1313
# Custom Packages
1414
from AthenaTwitchBot.models.twitch_channel import TwitchChannel
@@ -79,12 +79,12 @@ def command(
7979
def scheduled_task(
8080
self=None,
8181
*,
82-
interval:int|Second|Minute|Hour=Hour(1),
82+
interval:TimeValue=Hour(1),
8383
call_on_startup:bool=False
8484
) -> TwitchBotMethod:
8585
kwargs: dict = {
8686
"is_scheduled_task": True,
87-
"task_interval": convert_time_to_seconds(interval, to_int=True),
87+
"task_interval": interval.to_int_as_seconds(),
8888
"task_call_on_startup": call_on_startup
8989
}
9090

src/AthenaTwitchBot/models/twitch_bot_protocol.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ def parse_data(self, data: bytearray):
243243
text=" ".join(d_split)
244244
)
245245

246+
case str(a), if not a:
247+
# skip empty lines
248+
continue
249+
246250
case _:
247251
self.output_handler(
248252
callback=output_undefined,

0 commit comments

Comments
 (0)