タイムアウト処理の実装
This commit is contained in:
parent
e48a0fc3c2
commit
a9109dba0a
1 changed files with 11 additions and 4 deletions
15
dislocker.py
15
dislocker.py
|
@ -649,13 +649,17 @@ class Monitor():
|
|||
print(type(start_time))
|
||||
current_time = datetime.now()
|
||||
time_difference = current_time - start_time
|
||||
if time_difference >= timedelta(seconds=self.allowable_time):
|
||||
print(current_time, start_time)
|
||||
print(time_difference.seconds, timedelta(seconds=self.allowable_time).seconds)
|
||||
if time_difference.seconds >= timedelta(seconds=self.allowable_time).seconds:
|
||||
cursor.execute("SELECT * FROM club_member WHERE id = %s", (user_id,))
|
||||
user_info = cursor.fetchall()
|
||||
stop = bot.stop(user_id=user_info[0][3])
|
||||
|
||||
bot.timeout_notify(pc_number=pc_list[0][0], discord_display_name=user_info[0][1])
|
||||
time.sleep(1)
|
||||
else:
|
||||
result = {"result": "BUT SAFE"}
|
||||
|
||||
|
||||
elif len(pc_list) >= 2:
|
||||
|
@ -670,13 +674,16 @@ class Monitor():
|
|||
print(type(start_time))
|
||||
current_time = datetime.now()
|
||||
time_difference = current_time - start_time
|
||||
if time_difference >= timedelta(seconds=self.allowable_time):
|
||||
print(time_difference.seconds, timedelta(seconds=self.allowable_time).seconds)
|
||||
if time_difference.seconds >= timedelta(seconds=self.allowable_time).seconds:
|
||||
cursor.execute("SELECT * FROM club_member WHERE id = %s", (user_id,))
|
||||
user_info = cursor.fetchall()
|
||||
stop = bot.stop(user_id=user_info[0][3])
|
||||
|
||||
bot.timeout_notify(pc_number=i[0], discord_display_name=user_info[0][1])
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
result = {"result": "BUT SAFE"}
|
||||
|
||||
else:
|
||||
result = {"result": "NONE"}
|
||||
|
@ -740,8 +747,8 @@ if dislocker.init_result == "ok":
|
|||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
bot = Bot(intents=intents)
|
||||
#monitor = Monitor()
|
||||
#monitor.start(search_time=10, allowable_time=300)
|
||||
monitor = Monitor()
|
||||
monitor.start(search_time=10, allowable_time=300)
|
||||
bot.run(dislocker.server_config['bot']['token'])
|
||||
else:
|
||||
pass
|
Loading…
Reference in a new issue