From 1fb6c8e1ba44e327c1892dc032a7c0fe246470f9 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Wed, 15 Jun 2022 11:17:20 +0200 Subject: [PATCH] Typo fixes Brought to my attention by: NoirPi and billy_ikanda: --- setup.py | 2 +- src/AthenaTwitchBot/__init__.py | 4 ++-- src/AthenaTwitchBot/_info/_v.py | 2 +- src/AthenaTwitchBot/decorators/command.py | 2 +- src/AthenaTwitchBot/decorators/frequentoutput.py | 4 ++-- .../functions/twitch_irc_messages.py | 1 - .../functions/twitch_message_constructors.py | 14 ++++++-------- src/AthenaTwitchBot/models/twitch_bot.py | 13 +++++-------- src/AthenaTwitchBot/models/twitch_bot_protocol.py | 8 ++++---- src/AthenaTwitchBot/models/twitch_bot_server.py | 2 +- src/AthenaTwitchBot/models/twitch_message.py | 3 +-- 11 files changed, 24 insertions(+), 31 deletions(-) diff --git a/setup.py b/setup.py index a4afba0..ab33603 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ # - Code - # ---------------------------------------------------------------------------------------------------------------------- def version_handler() -> str: - version = 0,1,0 + version = 0,1,1 version_str = ".".join(str(i) for i in version) with open("src/AthenaTwitchBot/_info/_v.py", "w") as file: diff --git a/src/AthenaTwitchBot/__init__.py b/src/AthenaTwitchBot/__init__.py index 1e12cd8..22d1246 100644 --- a/src/AthenaTwitchBot/__init__.py +++ b/src/AthenaTwitchBot/__init__.py @@ -1,8 +1,8 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Package Imports - # ---------------------------------------------------------------------------------------------------------------------- -from AthenaTwitchBot.decorators.command import commandmethod -from AthenaTwitchBot.decorators.frequentoutput import frequentoutputmethod +from AthenaTwitchBot.decorators.command import command_method +from AthenaTwitchBot.decorators.frequentoutput import frequent_output_method from AthenaTwitchBot.models.twitch_bot import TwitchBot from AthenaTwitchBot.models.twitch_bot_protocol import TwitchBotProtocol diff --git a/src/AthenaTwitchBot/_info/_v.py b/src/AthenaTwitchBot/_info/_v.py index 4e54bf0..85c1c73 100644 --- a/src/AthenaTwitchBot/_info/_v.py +++ b/src/AthenaTwitchBot/_info/_v.py @@ -1,2 +1,2 @@ def _version(): - return '0.1.0' \ No newline at end of file + return '0.1.1' \ No newline at end of file diff --git a/src/AthenaTwitchBot/decorators/command.py b/src/AthenaTwitchBot/decorators/command.py index d43dd96..7ed2ed7 100644 --- a/src/AthenaTwitchBot/decorators/command.py +++ b/src/AthenaTwitchBot/decorators/command.py @@ -11,7 +11,7 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- -def commandmethod(name:str): +def command_method(name:str): def decorator(fnc): def wrapper(*args, **kwargs): return fnc(*args, **kwargs) diff --git a/src/AthenaTwitchBot/decorators/frequentoutput.py b/src/AthenaTwitchBot/decorators/frequentoutput.py index 0788a54..4f738f4 100644 --- a/src/AthenaTwitchBot/decorators/frequentoutput.py +++ b/src/AthenaTwitchBot/decorators/frequentoutput.py @@ -11,7 +11,7 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- -def frequentoutputmethod(delay:int=3600): # defult is every hour +def frequent_output_method(delay:int=3600): # default is every hour """ Create a method that runs every couple of seconds. The delay parameter is defined in seconds @@ -25,7 +25,7 @@ def wrapper(*args, **kwargs): # store attributes for later use by the bot # to be used by the protocol to assign it top an async call loop - wrapper.is_frequent_ouput = True + wrapper.is_frequent_output = True # typo caught by NoirPi wrapper.delay = delay return wrapper return decorator \ No newline at end of file diff --git a/src/AthenaTwitchBot/functions/twitch_irc_messages.py b/src/AthenaTwitchBot/functions/twitch_irc_messages.py index b62232d..be7d5f6 100644 --- a/src/AthenaTwitchBot/functions/twitch_irc_messages.py +++ b/src/AthenaTwitchBot/functions/twitch_irc_messages.py @@ -3,7 +3,6 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations -import asyncio # Custom Library diff --git a/src/AthenaTwitchBot/functions/twitch_message_constructors.py b/src/AthenaTwitchBot/functions/twitch_message_constructors.py index b906d0d..3943865 100644 --- a/src/AthenaTwitchBot/functions/twitch_message_constructors.py +++ b/src/AthenaTwitchBot/functions/twitch_message_constructors.py @@ -4,8 +4,6 @@ # General Packages from __future__ import annotations from typing import Callable -from datetime import datetime -import time # Custom Library from AthenaColor import StyleNest, ForeNest, HEX @@ -71,13 +69,13 @@ def twitch_message_constructor_tags(message_bytes:bytearray, bot_name:str) -> Tw # with tags enabled, we know that the first element of the list above contains all the user's tags # This enables us to loop them and assign them to the message # This is done to make them accessible to the command parsing - # The second part of the split message is the user definement. The user id is found in the tags + # The second part of the split message is the user definition. The user id is found in the tags # IRC message string is found next - # The channel from which it is sent is also recieved. - # When the bot is only installed in one channel, this isn't usefull, but if a bot is used in multiple channels - # this is part of the usefull known context + # The channel from which it is sent is also received. + # When the bot is only installed in one channel, this isn't useful, but if a bot is used in multiple channels + # this is part of the usefully known context # Finally all text should be clumped together again, to be searched though for a custom command - # This is to be done by the protocol class, not the message constructir + # This is to be done by the protocol class, not the message constructor tags, user, irc_message, channel, *text = content twitch_message:TwitchMessage = TwitchMessage( @@ -95,7 +93,7 @@ def twitch_message_constructor_tags(message_bytes:bytearray, bot_name:str) -> Tw try: TAG_MAPPING[tag_name](tm=twitch_message,tag_value=tag_value) except KeyError: - print(StyleNest.Bold(ForeNest.Maroon(f"Unkown tag of '{tag_name}' found. Please create a bug report on the git repo"))) + print(StyleNest.Bold(ForeNest.Maroon(f"Unknown tag of '{tag_name}' found. Please create a bug report on the git repo"))) pass return twitch_message \ No newline at end of file diff --git a/src/AthenaTwitchBot/models/twitch_bot.py b/src/AthenaTwitchBot/models/twitch_bot.py index c2dc91e..1e526e5 100644 --- a/src/AthenaTwitchBot/models/twitch_bot.py +++ b/src/AthenaTwitchBot/models/twitch_bot.py @@ -3,14 +3,11 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations -import asyncio from dataclasses import dataclass, field, InitVar from typing import Callable import inspect # Custom Library -import AthenaLib -import AthenaColor # Custom Packages @@ -25,9 +22,9 @@ class TwitchBot: prefix:str # Twitch-specific capabilities : https://dev.twitch.tv/docs/irc/capabilities - twitch_capibility_commands:bool=False - twitch_capibility_membership:bool=False - twitch_capibility_tags:bool=True # only one that has the default set to true, as this is required to make reply's work + twitch_capability_commands:bool=False + twitch_capability_membership:bool=False + twitch_capability_tags:bool=True # only one that has the default set to true, as this is required to make reply's work predefined_commands:InitVar[dict[str: Callable]]=None # made part of init if someone wants to feel the pain of adding commands manually @@ -49,12 +46,12 @@ def __new__(cls, *args, **kwargs): # Which is to be used in the commands tuple obj = super(TwitchBot, cls).__new__(cls,*args,**kwargs) - # loop over the bot's metods and parse the different methods + # loop over the bots methods and parse the different methods for k,v in cls.__dict__.items(): if inspect.isfunction(v): if "is_command" in (attributes := [attribute for attribute in dir(v) if not attribute.startswith("__")]): cls.commands[v.command_name] = v - elif "is_frequent_ouput" in attributes: + elif "is_frequent_output" in attributes: cls.frequent_outputs.append((v,v.delay)) return obj diff --git a/src/AthenaTwitchBot/models/twitch_bot_protocol.py b/src/AthenaTwitchBot/models/twitch_bot_protocol.py index adcbdcd..4e91cac 100644 --- a/src/AthenaTwitchBot/models/twitch_bot_protocol.py +++ b/src/AthenaTwitchBot/models/twitch_bot_protocol.py @@ -31,13 +31,13 @@ class TwitchBotProtocol(asyncio.Protocol): message_constructor:Callable = field(init=False) def __post_init__(self): - if self.bot.twitch_capibility_tags: + if self.bot.twitch_capability_tags: self.message_constructor = twitch_message_constructor_tags else: raise NotImplementedError("This needs to be created") # ---------------------------------------------------------------------------------------------------------------------- - # - Protocol neseccary - + # - Protocol necessary - # ---------------------------------------------------------------------------------------------------------------------- def connection_made(self, transport: asyncio.transports.Transport) -> None: self.transport = transport @@ -47,7 +47,7 @@ def connection_made(self, transport: asyncio.transports.Transport) -> None: self.transport.write(messages.join(channel=self.bot.channel)) self.transport.write(messages.request_tags) - # add frequent_ouput methods to the coroutine loop + # add frequent_output methods to the coroutine loop loop = asyncio.get_running_loop() for callback, delay in self.bot.frequent_outputs: coro = loop.create_task(self.frequent_output_call(callback,delay)) @@ -82,7 +82,7 @@ def data_received(self, data: bytearray) -> None: self.bot.commands[user_cmd]( self=self.bot, # Assign a context so the user doesn't need to write the transport messages themselves - # A user opnly has to write the text + # A user only has to write the text context=TwitchMessageContext( message=twitch_message, transport=self.transport diff --git a/src/AthenaTwitchBot/models/twitch_bot_server.py b/src/AthenaTwitchBot/models/twitch_bot_server.py index 09822df..be5db5e 100644 --- a/src/AthenaTwitchBot/models/twitch_bot_server.py +++ b/src/AthenaTwitchBot/models/twitch_bot_server.py @@ -18,7 +18,7 @@ @dataclass(slots=True,eq=False,order=False,kw_only=True) class Server: bot: TwitchBot - socket:socket.socket=None + socket:socket.socket=field(default_factory=socket.socket) # non init slots server:asyncio.AbstractServer = field(init=False) diff --git a/src/AthenaTwitchBot/models/twitch_message.py b/src/AthenaTwitchBot/models/twitch_message.py index 7250649..3fc9129 100644 --- a/src/AthenaTwitchBot/models/twitch_message.py +++ b/src/AthenaTwitchBot/models/twitch_message.py @@ -4,7 +4,6 @@ # General Packages from __future__ import annotations from dataclasses import dataclass, field -from datetime import datetime # Custom Library from AthenaColor import HEX @@ -18,7 +17,7 @@ @dataclass(slots=True, eq=True, match_args=True) class TwitchMessage: - message:str=EMPTY_STR # complete message without the sufix: "\r\n" + message:str=EMPTY_STR # complete message without the suffix: "\r\n" message_type:str=EMPTY_STR channel:str=EMPTY_STR text:str=EMPTY_STR