Skip to content

Commit

Permalink
Merge pull request #43 from Technik-Tueftler/202405_bugfix_v140
Browse files Browse the repository at this point in the history
set correct default values if user is not set
  • Loading branch information
Technik-Tueftler authored May 8, 2024
2 parents 7ab7f86 + 23356bc commit e112754
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
10 changes: 5 additions & 5 deletions source/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
CACHE_FILE_PATH = "../files/cache.json"
HASHTAG_FILE_PATH = "../files/hashtags.txt"
LOG_FILE_PATH = "../files/log.txt"
HASHTAG_MAX_LENGTH = 10
HASHTAG_MIN_LENGTH = 3
TWEET_MAX_LENGTH = 280
HASHTAG_MAX_LENGTH = "10"
HASHTAG_MIN_LENGTH = "3"
TWEET_MAX_LENGTH = "280"
TWEET_START_STRING = "Highlights: "
TWEET_END_STRING = "Thanks!"
HASHTAG_ALL_LOWER_CASE = False
Expand All @@ -17,7 +17,7 @@
START_BOT_AT_STREAMSTART = False
FINISH_BOT_AT_STREAMEND = False
PUBLISH_NEW_CLIPS = False
UPDATE_INTERVAL_PUBLISH_NEW_CLIPS = 30
UPDATE_INTERVAL_PUBLISH_NEW_CLIPS = "30"
DC_FEATURE_HASHTAG = "off"
DC_FEATURE_CLIPS = "off"
BOT_COMMAND_PATTERN = r"^[A-Za-z0-9]+$"
Expand All @@ -34,4 +34,4 @@
DEFAULT_CACHE_DATA = {"Version": "v1.3.0", "clip_last_timestamp": "2024-02-02T12:00:00Z"}
DEFAULT_CLIP_THANK_YOU_TEXT = "A clip from the current stream #link Thanks to #user for clipping"
CLIP_WAIT_TIME = 2
CHECK_STREAM_INTERVAL = 60
CHECK_STREAM_INTERVAL = "60"
4 changes: 2 additions & 2 deletions source/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from sqlalchemy import ForeignKey, select
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
from constants import UPDATE_INTERVAL_PUBLISH_NEW_CLIPS
import environment_verification as env

engine = create_async_engine("sqlite+aiosqlite:///../files/HenCommander.db", echo=False)

Expand Down Expand Up @@ -115,7 +115,7 @@ async def fetch_last_clip_ids() -> List[int]:
List[int]: List of clip IDs
"""
timestamp = datetime.now(UTC)
seconds = UPDATE_INTERVAL_PUBLISH_NEW_CLIPS
seconds = env.app_settings["clips_fetch_time"]
start_timestamp = (timestamp - timedelta(seconds=seconds)).strftime(
"%Y-%m-%dT%H:%M:%SZ"
)
Expand Down
10 changes: 5 additions & 5 deletions source/environment_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ def check_tweet_settings():
tweet_settings["hashtag_max_length"] = (
int(hashtag_max_length)
if hashtag_max_length.isdecimal()
else HASHTAG_MAX_LENGTH
else int(HASHTAG_MAX_LENGTH)
)
tweet_settings["hashtag_min_length"] = (
int(hashtag_min_length)
if hashtag_min_length.isdecimal()
else HASHTAG_MIN_LENGTH
else int(HASHTAG_MIN_LENGTH)
)
tweet_settings["tweet_max_length"] = (
int(tweet_max_length) if tweet_max_length.isdecimal() else TWEET_MAX_LENGTH
int(tweet_max_length) if tweet_max_length.isdecimal() else int(TWEET_MAX_LENGTH)
)
tweet_settings["hashtag_all_lower_case"] = hashtag_all_lower_case.lower() in (
OPTIONS_POSITIVE_ARG
Expand All @@ -217,7 +217,7 @@ def check_twitch_env_available() -> bool:
app_settings["check_stream_interval"] = (
int(check_stream_interval)
if check_stream_interval.isdecimal()
else CHECK_STREAM_INTERVAL
else int(CHECK_STREAM_INTERVAL)
)
return None not in (client_id, token, nickname, init_channels)

Expand Down Expand Up @@ -275,7 +275,7 @@ def discord_setting_verification() -> None:
app_settings["clips_fetch_time"] = (
int(clips_fetch_time)
if clips_fetch_time.isdecimal()
else UPDATE_INTERVAL_PUBLISH_NEW_CLIPS
else int(UPDATE_INTERVAL_PUBLISH_NEW_CLIPS)
)


Expand Down
5 changes: 2 additions & 3 deletions source/twitch_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import hashtag_handler as hashh
from constants import (
REQUEST_TIMEOUT,
UPDATE_INTERVAL_PUBLISH_NEW_CLIPS,
CLIP_WAIT_TIME,
TIMESTAMP_PATTERN,
)
Expand All @@ -36,7 +35,7 @@ async def fetch_new_clips(settings) -> list:
client_id = settings["ID"]
token = settings["token"]
timestamp = datetime.now(UTC)
seconds = UPDATE_INTERVAL_PUBLISH_NEW_CLIPS
seconds = settings["clips_fetch_time"]
start_timestamp = (timestamp - timedelta(seconds=seconds)).strftime(
TIMESTAMP_PATTERN
)
Expand Down Expand Up @@ -79,7 +78,7 @@ async def streaming_handler(**settings) -> None:
# 'title': '🐔 Noch 2 Achievements #34 🐔',
# 'started_at': ''}], 'pagination': {}}
response = requests.get(is_live_url, headers=headers, timeout=REQUEST_TIMEOUT).json()
print(response)
# print(response)
if settings["start_bot_at_streamstart"]:
if response["data"] and not hashh.app_data["online"] and response["data"][0]["is_live"]:
await hashh.allow_collecting(True)
Expand Down

0 comments on commit e112754

Please sign in to comment.