summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/main.py b/main.py
index 813e7ab..589c942 100644
--- a/main.py
+++ b/main.py
@@ -73,14 +73,34 @@ async def search_teammates(who, query):
log.info(who.name + " requested a game " + ", ".join([str(d) for d in (start, end)]))
players = []
- for teammate in db.playwithme.find({"end": {"$gt": start, "$lt": end}}):
+ query = {
+ "$or": [
+ {
+ "start": {
+ "$gt": start,
+ "$lt": end
+ }
+ },
+ {
+ "end": {
+ "$gt": start,
+ "$lt": end
+ }
+ },
+ {
+ "start": {"$lt": start},
+ "end": {"$gt": end}
+ }
+ ]
+ }
+ for teammate in db.playwithme.find(query):
mention = (await get_user(teammate["player"]))["mention"]
if not mention in players:
players += [mention]
if len(players) > 1:
- return ", ".join(players) + " can play together at %s. It is now %s." % (start.strftime("%H:%M"), datetime.datetime.now().strftime("%H:%M"))
+ return ", ".join(players) + " can play together at."
else:
- return "Nobody can play at that time. I will notify you if anyone can play between %s and %s. It is now %s." % (start.strftime("%H:%M"), end.strftime("%H:%M"), datetime.datetime.now().strftime("%H:%M"))
+ return "Nobody can play at that time. I will notify you if anyone wants to play between %s and %s. It is now %s." % (start.strftime("%H:%M"), end.strftime("%H:%M"), datetime.datetime.now().strftime("%H:%M"))
@cli.event
async def on_message(message):