def start(bot: Bot, message: Message):
+ i = 0
+ wait = 5
while True:
- tools.smart_start_stream_time.update_start_stream_timestamp()
- analyze_auto_message.do_auto_message(bot, message, auto_message_modules)
- time.sleep(30)
+ i += wait
+ started = tools.smart_start_stream_time.update_start_stream_timestamp()
+ if started == "START":
+ bot.send_privmsg(message.channel, "Stream has started, you can now use ?join")
+ elif started == "END":
+ bot.send_privmsg(message.channel, "Stream has ended")
+ if i >= 30:
+ analyze_auto_message.do_auto_message(bot, message, auto_message_modules)
+ i = 0
+ time.sleep(wait)
def main(bot: Bot, message: Message):
return None
-def update_start_stream_timestamp() -> Optional[int]:
+def update_start_stream_timestamp() -> Optional[str]:
conn = sqlite3.connect(os.path.join(PATH, "database.db"))
c = conn.cursor()
if time.time() < last_checked + CHECK_STREAMTIME_CD:
logger.info(f"returned cached start stream time: {start_stream_ts}")
conn.close()
- return start_stream_ts
+ return
stream_info = ttv_api.stream.get_streams(user_logins=[streamer_login])
logger.info(f"used twitch api to get stream info")
conn.close()
# TODO add hook, streamer ended stream
end_stream()
- return
+ return "END"
if not fetched:
start_stream_ts = int(stream_info[0].started_at.timestamp())
logger.info(f"returned api start stream time: {start_stream_ts}")
# TODO add hook, streamer started streaming
start_stream()
- return start_stream_ts
+ return "START"
start_stream_ts, last_checked = fetched
current_time = int(time.time())
)
conn.close()
logger.info(f"returned cached start stream time: {start_stream_ts}")
- return start_stream_ts
+ return