-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I noticed today that I haven't received any webhook drop notifications since March, so I began investigating the issue.
I found that I hadn't set countDrops to any value in my config file. However, as I understand it, countDrops defaults to True. Therefore, this should not be the cause of the issue
EsportsHelper/EsportsHelper/Config.py
Line 85 in a3429db
| self.countDrops = configFile.get("countDrops", True) |
I tested the webhook by setting connectorTest to True, and it succeeded. This indicates that the webhook itself is working correctly.
I debugged currentDropsList, and it successfully retrieved and set the data.
Based on my findings, I suspect that the issue may be related to the following line of code:
EsportsHelper/EsportsHelper/Rewards.py
Line 544 in a3429db
| newDropList = [drop for drop in stats.currentDropsList if (stats.lastDropCheckTime - 6000) <= drop.get("unlockedDateMillis", -1)] |
If unlockedDateMillis is older than stats.lastDropCheckTime - 6000, that drop will not be included in the newDropList i think that's the issue
As I understand, stats.lastDropCheckTime is updated at the end of the checkNewDrops function. The frequency of checkNewDrops calls is influenced by delays and sleep periods in watchMatches function in (Match.py)
EsportsHelper/EsportsHelper/Match.py
Lines 105 to 232 in a3429db
| # Random numbers, used for random delay | |
| randomDelay = randint(int(config.delay * 0.08), int(config.delay * 0.15)) | |
| newDelay = randomDelay * 10 | |
| nowTimeHour = int(time.localtime().tm_hour) | |
| nowTimeDay = int(time.localtime().tm_mday) | |
| liveUrlList = [] | |
| sleepEndTime = "" | |
| # If you are not currently sleeping, | |
| # get match information (including matches that are still counting down). | |
| if isSleep is False: | |
| log.info(_log("检查赛区直播状态...")) | |
| liveUrlList = fetchLiveMatches(ignoreBroadCast=False, ignoreDisWatchMatches=True) | |
| if liveUrlList == ["ERROR"]: | |
| liveUrlList = self.getMatchInfo(ignoreBroadCast=False) | |
| if config.autoSleep: | |
| # When the next game time is correct, go into sleep judgment. | |
| if self.nextMatchHour is not None and self.nextMatchDay is not None: | |
| # If the next match is on the same day as now, but the current time has exceeded the match time, sober up. | |
| if nowTimeDay == self.nextMatchDay and \ | |
| nowTimeHour >= self.nextMatchHour: | |
| isSleep = False | |
| # If the next match is on the same day as the current day, | |
| # and there is still over an hour before the match starts, | |
| # and no regions are currently live-streaming, then enter a one-hour sleep mode. | |
| elif nowTimeDay == self.nextMatchDay and \ | |
| nowTimeHour < self.nextMatchHour - 1 and \ | |
| self.currentWindows == {} and liveUrlList == []: | |
| isSleep = True | |
| newDelay = 3599 | |
| # If the next game is the same day as now, but the current time is already an hour before the game, sober up. | |
| elif nowTimeDay == self.nextMatchDay and \ | |
| nowTimeHour == self.nextMatchHour - 1: | |
| isSleep = False | |
| # If the next game date is greater than the current date, and there is no live game now, | |
| # and the current time hours are less than 23, sleep is entered with an interval of one hour. | |
| elif nowTimeDay < self.nextMatchDay and self.currentWindows == {} \ | |
| and nowTimeHour < 23 and liveUrlList == []: | |
| isSleep = True | |
| newDelay = 3599 | |
| elif nowTimeDay < self.nextMatchDay and nowTimeHour >= 23: | |
| isSleep = False | |
| elif (nowTimeDay == 31 or nowTimeDay == 30 or nowTimeDay == 29) and \ | |
| (self.nextMatchDay == 1 or self.nextMatchDay == 2 or self.nextMatchDay == 3) \ | |
| and nowTimeHour < 23 and liveUrlList == []: | |
| isSleep = True | |
| newDelay = 3599 | |
| else: | |
| isSleep = False | |
| # Stay awake when the next game time is wrong. | |
| else: | |
| isSleep = False | |
| else: | |
| if self.nextMatchHour is not None and self.nextMatchDay is not None: | |
| if nowTimeDay < self.nextMatchDay and self.currentWindows == {} and nowTimeHour < 23 and liveUrlList == []: | |
| newDelay = 3599 | |
| # When the time of the next game is longer than 1 hour from the current time, the check interval is one hour | |
| elif nowTimeHour < self.nextMatchHour - 1 and self.currentWindows == {} and liveUrlList == []: | |
| newDelay = 3599 | |
| # The sleep period set has a higher priority than the autoSleep function. | |
| if self.sleepBeginList == [] and self.sleepEndList == []: | |
| pass | |
| else: | |
| nowTimeHour = int(time.localtime().tm_hour) | |
| for sleepBegin, sleepEnd in zip(self.sleepBeginList, self.sleepEndList): | |
| if sleepBegin <= nowTimeHour < sleepEnd: | |
| if nowTimeHour < sleepEnd - 1: | |
| newDelay = 3599 | |
| else: | |
| randomDelay = randint( | |
| int(config.delay * 0.08), int(config.delay * 0.15)) | |
| newDelay = randomDelay * 10 | |
| isSleep = True | |
| sleepEndTime = sleepEnd | |
| break | |
| else: | |
| isSleep = False | |
| if isSleep: | |
| if sleepFlag is False: | |
| log.info(_log("进入休眠时间")) | |
| stats.info.append(f"{datetime.now().strftime('%H:%M:%S')} " + _("进入休眠时间", color="green")) | |
| stats.liveRegions = [] | |
| stats.status = _("休眠", color="yellow") | |
| self.closeAllTabs() | |
| sleepFlag = True | |
| else: | |
| log.info(_log("处于休眠时间...")) | |
| stats.status = _("休眠", color="yellow") | |
| if sleepEndTime: | |
| wakeTime = sleepEndTime | |
| else: | |
| wakeTime = stats.nextMatch.split("|")[1] | |
| log.info(f'{_log("预计休眠状态将持续到")} {wakeTime}') | |
| if not any(f'{_("预计休眠状态将持续到", color="bold yellow")} [cyan]{wakeTime}[/cyan]' in info for info in stats.info): | |
| stats.info.append(f"{datetime.now().strftime('%H:%M:%S')} " + | |
| f'{_("预计休眠状态将持续到", color="bold yellow")} [cyan]{wakeTime}[/cyan]') | |
| log.info( | |
| f"{_log('下次检查在:')} " | |
| f"{(datetime.now() + timedelta(seconds=newDelay)).strftime('%m-%d %H:%M:%S')}") | |
| stats.nextCheckTime = "[cyan]" + (datetime.now() + timedelta(seconds=newDelay)).strftime('%H:%M:%S') + "[/cyan]" | |
| log.info(f"{'=' * 50}") | |
| sleep(newDelay) | |
| continue | |
| elif sleepFlag is True: | |
| log.info(_log("休眠时间结束")) | |
| stats.info.append(f"{datetime.now().strftime('%H:%M:%S')} " + _("休眠时间结束", color="green")) | |
| stats.lastCheckTime = "[cyan]" + datetime.now().strftime('%H:%M:%S') + "[/cyan]" | |
| stats.nextCheckTime = "" | |
| stats.status = _("检查中", color="green") | |
| log.info(_log("开始检查...")) | |
| sleepFlag = False | |
| if config.countDrops: | |
| self.driver.switch_to.window(self.rewardWindow) | |
| self.rewardWindow = self.rewards.getRewardPage() | |
| # Get the number of drops and total hours watched | |
| if config.countDrops: | |
| watchRegion = fetchWatchRegions() | |
| if watchRegion != "ERROR": | |
| stats.watchRegion = watchRegion | |
| else: | |
| stats.watchRegion = _log("未知") | |
| log.info(f"{_log('观看属地')}: {stats.watchRegion}") | |
| self.driver.switch_to.window(self.rewardWindow) | |
| checkRewardPage(self.driver, isInit=False) | |
| setTodayDropsNumber() | |
| self.rewards.checkNewDrops() |
Should we subtract the maximum possible delay or sleep time (whatever is greater) from stats.lastDropCheckTime to ensure that no drops are missed? Increasing the time window or adjusting the logic to account for potential delays might resolve the issue.
max sleep time as i understand is 1 hour
Please let me know if this adjustment would help or if there are any other factors to consider. Also, it would be useful to know if other users are experiencing the same issue. I have yet to test this change since I haven’t received any new drops recently.
Thank you!