summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2016-12-09 15:03:13 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2016-12-09 15:03:13 +0100
commit5e7e6aa45cbe1e2a07d336ad482546705494676a (patch)
treeeb2e5aac3006e755a6b6fb0994eb825e8ec7a9c1 /main.py
parentd4aebc915d803fc54211e9aa22f0d2415935a677 (diff)
downloadVainbot-5e7e6aa45cbe1e2a07d336ad482546705494676a.tar.gz
Vainbot-5e7e6aa45cbe1e2a07d336ad482546705494676a.zip
who can play: ask passively for games
Diffstat (limited to 'main.py')
-rw-r--r--main.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/main.py b/main.py
index 589c942..6e83a9d 100644
--- a/main.py
+++ b/main.py
@@ -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"):