-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4231d9f
commit b391cc7
Showing
51 changed files
with
134 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .command import Command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Callable | ||
|
||
from ..identification import RegisteredListener, ServerID | ||
from ..commands import ChatCommand, ChatCommandData | ||
|
||
|
||
def Command(server_id: ServerID, aliases: list = None, alias_func: Callable = None): | ||
|
||
def wrapper(func): | ||
|
||
if isinstance(func, RegisteredListener): | ||
func = func.get_coro() | ||
|
||
command_data = ChatCommandData(coroutine=func, aliases=aliases, callable_func=alias_func) | ||
ChatCommand.REGISTERED_COMMANDS[server_id][func.__name__] = command_data | ||
|
||
return RegisteredListener(func.__name__, func) | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .chat_command_data import ChatCommandData | ||
from .chat_command import ChatCommand, ChatCommandTime | ||
from .command_options import CommandOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import dataclasses | ||
from collections import defaultdict | ||
from typing import Dict, List | ||
|
||
from .chat_command_data import ChatCommandData | ||
from ..identification import ServerID | ||
|
||
|
||
@dataclasses.dataclass | ||
class ChatCommandTime: | ||
formatted_time: str | ||
raw_time: int | ||
|
||
|
||
class ChatCommand: | ||
|
||
REGISTERED_COMMANDS: Dict[ServerID, Dict[str, ChatCommandData]] = defaultdict(dict) | ||
|
||
def __init__( | ||
self, | ||
sender_name: str, | ||
sender_steam_id: int, | ||
time: ChatCommandTime, | ||
command: str, | ||
args: List[str], | ||
) -> None: | ||
self.sender_name = sender_name | ||
self.sender_steam_id = sender_steam_id | ||
self.time = time | ||
self.command = command | ||
self.args = args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import Callable | ||
|
||
|
||
class ChatCommandData: | ||
|
||
def __init__(self, coroutine: Callable, aliases=None, callable_func=None) -> None: | ||
self.coroutine = coroutine | ||
self._aliases = aliases | ||
self._callable_func = callable_func | ||
|
||
@property | ||
def aliases(self): | ||
if self._aliases is None: | ||
return [] | ||
|
||
return self._aliases | ||
|
||
@property | ||
def callable_func(self): | ||
if self._callable_func is None: | ||
return lambda x: False | ||
|
||
return self._callable_func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from ..exceptions import PrefixNotDefinedError | ||
|
||
|
||
class CommandOptions: | ||
def __init__( | ||
self, prefix: str = None | ||
) -> None: | ||
if prefix is None: | ||
raise PrefixNotDefinedError("No prefix") | ||
|
||
self.prefix = prefix |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .deprecated import deprecated | ||
from .utils import convert_time | ||
from .grab_items import translate_stack_to_id, translate_id_to_stack | ||
from .yielding_event import YieldingEvent |