diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -47,7 +47,7 @@ async def get_user(id): }) return await get_user(id) -async def search_teammates(who, query): +async def search_teammates(who, query, notify=True): cal = parsedatetime.Calendar() if " for " in query or " until " in query: @@ -64,11 +64,12 @@ async def search_teammates(who, query): start = cal.parseDT(startstr)[0] end = cal.parseDT(endstr, sourceTime=start)[0] - db.playwithme.insert_one({ - "player": who.id, - "start": start, - "end": end - }) + if notify: + db.playwithme.insert_one({ + "player": who.id, + "start": start, + "end": end + }) log.info(who.name + " requested a game " + ", ".join([str(d) for d in (start, end)])) @@ -98,9 +99,12 @@ async def search_teammates(who, query): if not mention in players: players += [mention] if len(players) > 1: - return ", ".join(players) + " can play together at." + return ", ".join(players) + " can play together." else: - 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")) + if notify: + 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")) + else: + return "Nobody can play at that time." @cli.event async def on_message(message): @@ -114,14 +118,15 @@ async def on_message(message): if msg.startswith("?help"): await cli.send_message(message.channel, "Commands: ?help, ?ping, ?about") await cli.send_message(message.channel, "<play with me [now (default) | in (timespan) | at,from (time)] [for (timespan, default 30 minutes) | until (time)]> to find teammates.") + await cli.send_message(message.channel, "<who can play [now (default) | in (timespan) | at,from (time)] [for (timespan, default 30 minutes) | until (time)]> to see who registered for notifications.") await cli.send_message(message.channel, "<don't play with me> to cancel.") - if msg.startswith("play with me") or msg.startswith("?play"): + if msg.startswith("play with me") or msg.startswith("who can play"): if msg.startswith("play with me"): when = message.content[len("play with me"):] else: - when = message.content[len("?play"):] - response = await search_teammates(message.author, when) + when = message.content[len("who can play"):] + response = await search_teammates(message.author, when, False) await cli.send_message(message.channel, response) if msg.startswith("don't play with me") or msg.startswith("dont play with me"): |
