diff options
| -rw-r--r-- | main.py | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -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): |
