Skip to content

Commit 0df1c20

Browse files
committed
Make group_regex optional
1 parent fe27980 commit 0df1c20

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

mariusz/main.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def list(self) -> Generator[int, Any, None]:
125125
class Mariusz:
126126
"""Main class of the bot. Handles all the commands."""
127127

128-
def __init__(self, api_key: str, path_to_chat_db: str, group_regex: str):
128+
def __init__(
129+
self, api_key: str, path_to_chat_db: str, group_regex: str | None
130+
):
129131
self.update_id: int | None = None
130132
self.reactions: dict[
131133
re.Pattern[str],
@@ -442,15 +444,14 @@ async def main() -> None:
442444
path_to_chat_db = os.environ.get("SCIEZKA_DO_BAZY_CHATOW")
443445
group_regex = os.environ.get("GROUP_REGEX")
444446

445-
if api_key and path_to_chat_db and group_regex:
446-
m = Mariusz(api_key, path_to_chat_db, group_regex)
447-
await m.run()
448-
else:
447+
if not api_key or not path_to_chat_db:
449448
raise ValueError(
450-
"Set all required environment variables: "
451-
"API_KEY, SCIEZKA_DO_BAZY_CHATOW, GROUP_REGEX"
449+
"Set API_KEY and SCIEZKA_DO_BAZY_CHATOW environment variables."
452450
)
453451

452+
m = Mariusz(api_key, path_to_chat_db, group_regex)
453+
await m.run()
454+
454455

455456
if __name__ == "__main__":
456457
asyncio.run(main(), debug=True)

0 commit comments

Comments
 (0)