diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2016-12-09 14:57:31 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-12-09 14:57:31 +0100 |
| commit | d4aebc915d803fc54211e9aa22f0d2415935a677 (patch) | |
| tree | e16141fb321ee60c0e100ffa81600ca557ac1ff1 | |
| parent | e3258f68822d4ec89565bd8bcdb0336872a1d579 (diff) | |
| download | Vainbot-d4aebc915d803fc54211e9aa22f0d2415935a677.tar.gz Vainbot-d4aebc915d803fc54211e9aa22f0d2415935a677.zip | |
consider all timing cases
| -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): |
