Skip to content

Commit 50154e3

Browse files
committed
fd leak fixed for reals this time?
1 parent 4c0f276 commit 50154e3

File tree

5 files changed

+30
-38
lines changed

5 files changed

+30
-38
lines changed

Constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Constants:
5151
WAIT_BETWEEN_MESSAGES = 1800 # minimum amount of time in seconds the stream has to be offline before new notification messages.
5252
MIN_TIME_BEFORE_AVATAR_CHANGE = 48 # Minimum time before avatar changes -- in hours
5353
ONLINE_MESSAGE_REBROADCAST_TIME = 86400 #Time in seconds the stream will be online before another online notification will be broadcasted
54-
TIME_BEFORE_BOT_RESTART = 3600 #time in seconds before bot will restart. Restart checks are made every 10 minutes
54+
TIME_BEFORE_BOT_RESTART = 43200 #time in seconds before bot will restart. Restart checks are made every 10 minutes
5555
TIME_OFFLINE_BEFORE_RESTART = 900 #minimum time in seconds stream needs to be offline before bot will restart IF TIME_BEFORE_BOT_RESTART time has been met
5656
TEMP_TITLE_UPTIME = 57600 #Time in seconds temp titles will be used before default titles are used
5757
TIME_BEFORE_REVIEW_RESET = 300 # Time a whitelisted person has to review a confession before its added back to the queue

checkers/Fansly.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
import NoDriverBrowserCreator as ndb
55
import globals
66

7-
def isModelOnline(fansUserName):
8-
isOnline, title, thumbUrl, icon = uc.loop().run_until_complete(GetOnlineStatus(fansUserName))
9-
return isOnline, title, thumbUrl, icon
10-
11-
async def GetOnlineStatus(fansUserName):
7+
async def isModelOnline(fansUserName):
128
fansUrl = f"https://fansly.com/{fansUserName}"
139
thumbUrl = ""
1410
title = Constants.fansDefaultTitle

checkers/Kick.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import globals
77
from Constants import Constants
88

9-
def isModelOnline(kickUserName):
10-
isOnline, title, thumbUrl, icon = uc.loop().run_until_complete(GetOnlineStatus(kickUserName))
11-
return isOnline, title, thumbUrl, icon
12-
13-
async def GetOnlineStatus(kickUserName):
9+
async def isModelOnline(kickUserName):
1410
isOnline, title, thumbUrl, icon = setDefaultStreamValues()
1511
apiUrl = f"https://kick.com/api/v1/channels/{kickUserName}"
1612
try:

checkers/Onlyfans.py

+22-26
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,7 @@
66
import globals
77
from Constants import Constants
88

9-
async def GetIcon(page:uc.Tab):
10-
icon = 'images/errIcon.png'
11-
reString = r'^https:\/\/.+avatar.jpg$'
12-
try:
13-
imageElements = await page.find_all("data-v-325c6981")
14-
for element in imageElements:
15-
if element.attrs.get("src") and re.search(reString, element.attrs.get("src")):
16-
icon = element.attrs.get("src")
17-
except:
18-
pass
19-
return icon
20-
21-
async def IsLiveBadge(page:uc.Tab):
22-
live = False
23-
try:
24-
liveBadge = await page.find("g-avatar__icon m-live", best_match=True)
25-
if liveBadge:
26-
live = True
27-
except:
28-
pass
29-
return live
30-
31-
async def GetOnlineStatus(ofUserName):
9+
async def isModelOnline(ofUserName):
3210
isOnline = False
3311
ofUrl = f"https://onlyfans.com/{ofUserName}"
3412
title = Constants.ofDefaultTitle
@@ -52,6 +30,24 @@ async def GetOnlineStatus(ofUserName):
5230
globals.browserOpen = False
5331
return isOnline, title, thumbUrl, icon
5432

55-
def isModelOnline(ofUserName):
56-
isOnline, title, thumbUrl, icon = uc.loop().run_until_complete(GetOnlineStatus(ofUserName))
57-
return isOnline, title, thumbUrl, icon
33+
async def GetIcon(page:uc.Tab):
34+
icon = 'images/errIcon.png'
35+
reString = r'^https:\/\/.+avatar.jpg$'
36+
try:
37+
imageElements = await page.find_all("data-v-325c6981")
38+
for element in imageElements:
39+
if element.attrs.get("src") and re.search(reString, element.attrs.get("src")):
40+
icon = element.attrs.get("src")
41+
except:
42+
pass
43+
return icon
44+
45+
async def IsLiveBadge(page:uc.Tab):
46+
live = False
47+
try:
48+
liveBadge = await page.find("g-avatar__icon m-live", best_match=True)
49+
if liveBadge:
50+
live = True
51+
except:
52+
pass
53+
return live

plugins/checks.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from datetime import date
2424
import datetime
2525
from datetime import timedelta
26+
import inspect
2627

2728
component = tanjun.Component()
2829

@@ -31,7 +32,10 @@ def load(client: tanjun.abc.Client) -> None:
3132
client.add_component(component.copy())
3233

3334
async def platformChecker(isOnlineFunc: Callable,platformNotifFunc: Callable, userName: str, platformName: str, rest: hikari.impl.RESTClientImpl):
34-
isOnline, title, thumbUrl, icon = await asyncio.get_running_loop().run_in_executor(None,isOnlineFunc,userName)
35+
if inspect.iscoroutinefunction(isOnlineFunc):
36+
isOnline, title, thumbUrl, icon = await isOnlineFunc(userName)
37+
else:
38+
isOnline, title, thumbUrl, icon = await asyncio.get_running_loop().run_in_executor(None,isOnlineFunc,userName)
3539
isRerun = False
3640
db = Database()
3741
lastOnlineMessage,streamStartTime,streamEndTime = db.getPlatformAccountsRowValues(platformName,userName)

0 commit comments

Comments
 (0)