fix (accountability): Disallow near bookings.
Don't allow members to book within 11 minutes of the room start. Patches a race condition where the open room doesn't include the member.
This commit is contained in:
@@ -39,6 +39,7 @@ def time_format(time):
|
|||||||
time.timestamp() + 3600,
|
time.timestamp() + 3600,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
user_locks = {} # Map userid -> ctx
|
user_locks = {} # Map userid -> ctx
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +230,10 @@ async def cmd_rooms(ctx):
|
|||||||
start_time + datetime.timedelta(hours=n)
|
start_time + datetime.timedelta(hours=n)
|
||||||
for n in range(1, 25)
|
for n in range(1, 25)
|
||||||
)
|
)
|
||||||
times = [time for time in times if time not in already_joined_times]
|
times = [
|
||||||
|
time for time in times
|
||||||
|
if time not in already_joined_times and (time - utc_now()).total_seconds() > 660
|
||||||
|
]
|
||||||
lines = [
|
lines = [
|
||||||
"`[{num:>2}]` | `{count:>{count_pad}}` attending | {time}".format(
|
"`[{num:>2}]` | `{count:>{count_pad}}` attending | {time}".format(
|
||||||
num=i,
|
num=i,
|
||||||
@@ -255,7 +259,7 @@ async def cmd_rooms(ctx):
|
|||||||
await ctx.cancellable(
|
await ctx.cancellable(
|
||||||
out_msg,
|
out_msg,
|
||||||
cancel_message="Booking menu cancelled, no sessions were booked.",
|
cancel_message="Booking menu cancelled, no sessions were booked.",
|
||||||
timeout=70
|
timeout=60
|
||||||
)
|
)
|
||||||
|
|
||||||
def check(msg):
|
def check(msg):
|
||||||
@@ -265,7 +269,7 @@ async def cmd_rooms(ctx):
|
|||||||
|
|
||||||
with ensure_exclusive(ctx):
|
with ensure_exclusive(ctx):
|
||||||
try:
|
try:
|
||||||
message = await ctx.client.wait_for('message', check=check, timeout=60)
|
message = await ctx.client.wait_for('message', check=check, timeout=30)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await out_msg.edit(
|
await out_msg.edit(
|
||||||
@@ -325,6 +329,7 @@ async def cmd_rooms(ctx):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Handle case where the slot has already opened
|
# Handle case where the slot has already opened
|
||||||
|
# TODO: Fix this, doesn't always work
|
||||||
aguild = AGuild.cache.get(ctx.guild.id, None)
|
aguild = AGuild.cache.get(ctx.guild.id, None)
|
||||||
if aguild:
|
if aguild:
|
||||||
if aguild.upcoming_slot and aguild.upcoming_slot.start_time in to_book:
|
if aguild.upcoming_slot and aguild.upcoming_slot.start_time in to_book:
|
||||||
|
|||||||
Reference in New Issue
Block a user