monitorの時間類の設定をconfigファイルへ移動
This commit is contained in:
parent
3073f12e6c
commit
f7ecdc535f
1 changed files with 13 additions and 7 deletions
20
dislocker.py
20
dislocker.py
|
@ -43,7 +43,12 @@ class DL():
|
|||
},
|
||||
"log_channel_id" : "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)",
|
||||
"config_channel_id": "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)",
|
||||
"config_public_channel_id": "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)"
|
||||
"config_public_channel_id": "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)",
|
||||
"monitor": {
|
||||
"search_frequency": 1,
|
||||
"allowable_time": 180,
|
||||
"fstop_time": "21:00:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -655,13 +660,14 @@ class Bot(discord.Client):
|
|||
|
||||
class Monitor():
|
||||
def __init__(self, **kwargs) -> None:
|
||||
self.serach_time = kwargs["search_time"]
|
||||
self.search_frequency = kwargs["search_frequency"]
|
||||
self.allowable_time = kwargs["allowable_time"]
|
||||
self.fstop_time = kwargs["fstop_time"]
|
||||
self.init_wait_time = 10
|
||||
|
||||
def start(self, **kwargs):
|
||||
serach_thread = threading.Thread(target=self.search)
|
||||
serach_thread.start()
|
||||
search_thread = threading.Thread(target=self.search)
|
||||
search_thread.start()
|
||||
|
||||
|
||||
def search(self):
|
||||
|
@ -672,7 +678,7 @@ class Monitor():
|
|||
cursor.execute("SELECT * FROM pc_list WHERE password_hash IS NOT NULL")
|
||||
pc_list = cursor.fetchall()
|
||||
current_datetime = datetime.now()
|
||||
fstop_time = "21:00:00"
|
||||
fstop_time = self.fstop_time
|
||||
print(pc_list)
|
||||
print(len(pc_list))
|
||||
if current_datetime.time().strftime("%H:%M:%S") == fstop_time:
|
||||
|
@ -731,7 +737,7 @@ class Monitor():
|
|||
result = {"result": "NONE"}
|
||||
|
||||
print(result["result"])
|
||||
time.sleep(self.serach_time)
|
||||
time.sleep(self.search_frequency)
|
||||
|
||||
|
||||
except Exception as error:
|
||||
|
@ -786,7 +792,7 @@ if dislocker.init_result == "ok":
|
|||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
bot = Bot(intents=intents)
|
||||
monitor = Monitor(search_time=1, allowable_time=60)
|
||||
monitor = Monitor(search_frequency=dislocker.server_config["bot"]["monitor"]["search_frequency"], allowable_time=dislocker.server_config["bot"]["monitor"]["allowable_time"], fstop_time=dislocker.server_config["bot"]["monitor"]["fstop_time"])
|
||||
monitor.start()
|
||||
bot.run(dislocker.server_config['bot']['token'])
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue