-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Launching the bot now using ENTRYPOINT.SH
- Loading branch information
Showing
6 changed files
with
68 additions
and
38 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
|
||
# (c) Copyright 2024, Denis Rozhnovskiy <pytelemonbot@mail.ru> | ||
# pyTMBot - A simple Telegram bot to handle Docker containers and images, | ||
# also providing basic information about the status of local servers. | ||
|
||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
--log-level) | ||
LOG_LEVEL="$2" | ||
shift 2 | ||
;; | ||
--mode) | ||
MODE="$2" | ||
shift 2 | ||
;; | ||
--salt) | ||
SALT="$2" | ||
shift 2 | ||
;; | ||
*) | ||
echo "Unknown argument: $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Set default values if not provided | ||
LOG_LEVEL=${LOG_LEVEL:INFO} | ||
MODE=${MODE:prod} | ||
SALT=${SALT:-false} | ||
|
||
# Check if --salt was provided | ||
if [ "$SALT" = true ]; then | ||
/venv/bin/python3 pytmbot/utils/salt.py | ||
else | ||
/venv/bin/python3 main.py --log-level "$LOG_LEVEL" --mode "$MODE" | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import base64 | ||
import secrets | ||
|
||
|
||
def generate_random_auth_salt(length=32): | ||
""" | ||
Generates a random authentication salt for the bot. | ||
Args: | ||
length (int, optional): The length of the salt in bytes. Defaults to 32. | ||
Returns: | ||
str: The generated authentication salt. | ||
""" | ||
random_bytes = secrets.token_bytes(length) | ||
salt = base64.b32encode(random_bytes).decode('utf-8') | ||
return salt | ||
|
||
|
||
if __name__ == "__main__": | ||
print(generate_random_auth_salt()) |
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