PEP8 clean
This commit is contained in:
parent
e1aff6c4cf
commit
2dfe1f0e9a
15 changed files with 338 additions and 168 deletions
|
|
@ -12,12 +12,16 @@ nemubotversion = 3.4
|
|||
|
||||
from more import Response
|
||||
|
||||
|
||||
def help_full():
|
||||
return "If you would like to sleep soon, use !sleepytime to know the best time to wake up; use !sleepytime hh:mm if you want to wake up at hh:mm"
|
||||
return ("If you would like to sleep soon, use !sleepytime to know the best"
|
||||
" time to wake up; use !sleepytime hh:mm if you want to wake up at"
|
||||
" hh:mm")
|
||||
|
||||
|
||||
@hook("cmd_hook", "sleepytime")
|
||||
def cmd_sleep(msg):
|
||||
if len (msg.cmds) > 1 and re.match("[0-9]{1,2}[h':.,-]([0-9]{1,2})?[m'\":.,-]?",
|
||||
if len(msg.cmds) > 1 and re.match("[0-9]{1,2}[h':.,-]([0-9]{1,2})?[m'\":.,-]?",
|
||||
msg.cmds[1]) is not None:
|
||||
# First, parse the hour
|
||||
p = re.match("([0-9]{1,2})[h':.,-]([0-9]{1,2})?[m':.,-]?", msg.cmds[1])
|
||||
|
|
@ -26,10 +30,10 @@ def cmd_sleep(msg):
|
|||
datetime.now(timezone.utc).day,
|
||||
hour=int(p.group(1)))]
|
||||
if p.group(2) is not None:
|
||||
f[0] += timedelta(minutes=int(p.group(2)))
|
||||
f[0] += timedelta(minutes=int(p.group(2)))
|
||||
g = list()
|
||||
for i in range(0,6):
|
||||
f.append(f[i] - timedelta(hours=1,minutes=30))
|
||||
for i in range(6):
|
||||
f.append(f[i] - timedelta(hours=1, minutes=30))
|
||||
g.append(f[i+1].strftime("%H:%M"))
|
||||
return Response("You should try to fall asleep at one of the following"
|
||||
" times: %s" % ', '.join(g), channel=msg.channel)
|
||||
|
|
@ -38,8 +42,8 @@ def cmd_sleep(msg):
|
|||
else:
|
||||
f = [datetime.now(timezone.utc) + timedelta(minutes=15)]
|
||||
g = list()
|
||||
for i in range(0,6):
|
||||
f.append(f[i] + timedelta(hours=1,minutes=30))
|
||||
for i in range(6):
|
||||
f.append(f[i] + timedelta(hours=1, minutes=30))
|
||||
g.append(f[i+1].strftime("%H:%M"))
|
||||
return Response("If you head to bed right now, you should try to wake"
|
||||
" up at one of the following times: %s" %
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue