diff --git a/rustplus/api/api.py b/rustplus/api/api.py index 598e711..1846fa1 100644 --- a/rustplus/api/api.py +++ b/rustplus/api/api.py @@ -80,7 +80,7 @@ async def __getTime(self) -> RustTime: time_parser = TimeParser() - return RustTime(time.dayLengthMinutes, time_parser.convert(time.sunrise), time_parser.convert(time.sunset), time_parser.convert(time.time)) + return RustTime(time.dayLengthMinutes, time_parser.convert(time.sunrise), time_parser.convert(time.sunset), time_parser.convert(time.time), time.time) async def __getInfo(self) -> RustInfo: diff --git a/rustplus/api/structures/rust_chat_message.py b/rustplus/api/structures/rust_chat_message.py index 7782b80..77f1b6f 100644 --- a/rustplus/api/structures/rust_chat_message.py +++ b/rustplus/api/structures/rust_chat_message.py @@ -2,11 +2,11 @@ class RustChatMessage(): def __init__(self, data): - self.steamId = data.steamId - self.name = data.name + self.steamId = int(data.steamId) + self.name = str(data.name) self.message = str(data.message) self.colour = data.color - self.time = data.time + self.time = int(data.time) def __repr__(self): return "RustChatMessage[steamId={}, senderName={}, message={}, colour={}, time={}]".format(self.steamId, self.name, self.message, self.colour, self.time) \ No newline at end of file diff --git a/rustplus/api/structures/rust_time.py b/rustplus/api/structures/rust_time.py index a00fd39..0f528b6 100644 --- a/rustplus/api/structures/rust_time.py +++ b/rustplus/api/structures/rust_time.py @@ -1,11 +1,12 @@ class RustTime: - def __init__(self, day_length, sunrise, sunset, time) -> None: + def __init__(self, day_length, sunrise, sunset, time, raw_time) -> None: self.day_length = day_length self.sunrise = sunrise self.sunset = sunset self.time = time + self.raw_time = raw_time def __str__(self) -> str: - return "RustTime[day_length={}, sunrise={}, sunset={}, time={}]".format(self.day_length, self.sunset, self.sunset, self.time) \ No newline at end of file + return "RustTime[day_length={}, sunrise={}, sunset={}, time={}, raw_time={}]".format(self.day_length, self.sunset, self.sunset, self.time, self.raw_time) \ No newline at end of file diff --git a/rustplus/commands/__init__.py b/rustplus/commands/__init__.py index a586508..e2d8d03 100644 --- a/rustplus/commands/__init__.py +++ b/rustplus/commands/__init__.py @@ -1,3 +1,3 @@ from .command_options import CommandOptions from .command_handler import RustCommandHandler -from .command import Command +from .command import Command, CommandTime diff --git a/rustplus/commands/command.py b/rustplus/commands/command.py index c055ef3..7560101 100644 --- a/rustplus/commands/command.py +++ b/rustplus/commands/command.py @@ -1,6 +1,15 @@ +from typing import List + +class CommandTime: + + def __init__(self, formatted_time, raw_time) -> None: + + self.formatted_time = formatted_time + self.raw_time = raw_time + class Command: - def __init__(self, sender_name, sender_steamid, time, command, args) -> None: + def __init__(self, sender_name : str, sender_steamid : int, time : CommandTime, command : str, args : List[str]) -> None: self.sender_name = sender_name self.sender_steamid = sender_steamid diff --git a/rustplus/commands/command_handler.py b/rustplus/commands/command_handler.py index 850ca23..252ab56 100644 --- a/rustplus/commands/command_handler.py +++ b/rustplus/commands/command_handler.py @@ -1,10 +1,9 @@ import asyncio - -from rustplus import commands, exceptions +from datetime import datetime from ..api.structures import RustChatMessage from .command_options import CommandOptions -from .command import Command +from .command import Command, CommandTime class RustCommandHandler: @@ -26,4 +25,6 @@ async def run_command(self, message : RustChatMessage) -> None: coro = getattr(self, command) - await coro(Command(message.name, message.steamId, message.time, command, message.message.split(" ")[1:])) + time = CommandTime(datetime.utcfromtimestamp(message.time), message.time) + + await coro(Command(message.name, message.steamId, time, command, message.message.split(" ")[1:]))