Skip to content

Commit

Permalink
make it backwards compatible with REDIS_HOST and REDIS_DB
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr88 committed Dec 25, 2024
1 parent 4f9ddf6 commit 34e87a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tag=$(git describe --tags `git rev-list --tags --max-count=1`)
# check if current commit is already tagged if so tell the user and exit
if [ $(git describe --tags) == $tag ]; then
echo "Current commit is already tagged with $tag"
echo "Did you forget to commit your changes?"
exit 1
fi
# commit the requirements.txt file
Expand Down
15 changes: 9 additions & 6 deletions plugins/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ class Helper:
"""helper class for the bot"""
VALKEY_HOST = env.str("VALKEY_HOST", "localhost")
VALKEY_DB = env.int("VALKEY_DB", 0)
"""helper functions"""
VALKEY = valkey.Valkey(host=VALKEY_HOST, port=6379,
db=VALKEY_DB, decode_responses=True, protocol=3)
REDIS_HOST = env.str("REDIS_HOST", "localhost")
REDIS_DB = env.int("REDIS_DB", 0)

def __init__(self, driver, log_channel=None):
self.driver = driver
self.valkey = self.VALKEY
self.valkey = self.valkey
self.valkey_pool = self.VALKEY.connection_pool
# fallback to REDIS instead of valkey if VALKEY_HOST is not set
if self.VALKEY_HOST == "localhost" and self.REDIS_HOST != "localhost":
self.VALKEY_HOST = self.REDIS_HOST
self.VALKEY_DB = self.REDIS_DB
self.valkey = valkey.Valkey(host=self.VALKEY_HOST, port=6379,
db=self.VALKEY_DB, decode_responses=True, protocol=3)
self.valkey_pool = self.valkey.connection_pool
self.log_channel = log_channel
env_log_channel = env.str("MM_BOT_LOG_CHANNEL", None)
if self.log_channel is None and env_log_channel is None:
Expand Down

0 comments on commit 34e87a0

Please sign in to comment.