mirror of
https://github.com/kurbezz/discord-bot.git
synced 2026-03-03 20:40:48 +01:00
Fix
This commit is contained in:
@@ -12,20 +12,24 @@ class GameItem(BaseModel):
|
|||||||
date: str | None
|
date: str | None
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
# set timezone to Moscow
|
if self.date is not None:
|
||||||
_date = self.date or datetime.now().strftime("%d.%m.%Y")
|
return f"* {self.name} ({self.customer}) | {self.date}"
|
||||||
return f"* {self.name} ({self.customer}) | {_date}"
|
else:
|
||||||
|
return f"* {self.name} ({self.customer})"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, line: str) -> Self:
|
def parse(cls, line: str) -> Self:
|
||||||
regex_result = re.search(r"^\* (.+) \((.+)\) \| (.+)$", line)
|
regex_result_with_date = re.search(r"^\* (.+) \((.+)\) \| (.+)$", line)
|
||||||
|
if regex_result_with_date is not None:
|
||||||
|
name, customer, date = regex_result_with_date.groups()
|
||||||
|
return cls(name=name, customer=customer, date=date)
|
||||||
|
|
||||||
if regex_result is None:
|
regex_result_without_date = re.search(r"^\* (.+) \((.+)\)$", line)
|
||||||
raise ValueError(f"Invalid game item: {line}")
|
if regex_result_without_date is not None:
|
||||||
|
name, customer = regex_result_without_date.groups()
|
||||||
|
return cls(name=name, customer=customer, date=None)
|
||||||
|
|
||||||
name, customer, date = regex_result.groups()
|
raise ValueError(f"Invalid line: {line}")
|
||||||
|
|
||||||
return cls(name=name, customer=customer, date=date)
|
|
||||||
|
|
||||||
|
|
||||||
class Category(BaseModel):
|
class Category(BaseModel):
|
||||||
|
|||||||
@@ -62,8 +62,9 @@ class TwitchService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def start(cls):
|
async def start(cls):
|
||||||
twith = await cls.authorize()
|
print("Starting Twitch service...")
|
||||||
|
|
||||||
|
twith = await cls.authorize()
|
||||||
await cls(twith).run()
|
await cls(twith).run()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user