浏览代码

Improve !remind time detection (allow e.g. "!remind 7d-2h")

tags/v0.3
Ben Kurtovic 9 年前
父节点
当前提交
ac678c0f14
共有 2 个文件被更改,包括 4 次插入6 次删除
  1. +1
    -1
      CHANGELOG
  2. +3
    -5
      earwigbot/commands/remind.py

+ 1
- 1
CHANGELOG 查看文件

@@ -1,7 +1,7 @@
v0.3 (unreleased):

- Copyvio detector: improved sentence splitting algorithm.
- IRC: Added !remind all.
- IRC > !remind: Added !remind all. Improved time detection.
- IRC: Improved detection of maximum IRC message length.
- IRC: Improved some help commands.



+ 3
- 5
earwigbot/commands/remind.py 查看文件

@@ -78,13 +78,11 @@ class Remind(Command):
else:
raise ValueError(node)

if arg and arg[-1] in time_units:
factor, arg = time_units[arg[-1]], arg[:-1]
else:
factor = 1
for unit, factor in time_units.iteritems():
arg = arg.replace(unit, "*" + str(factor))

try:
parsed = int(_evaluate(ast.parse(arg, mode="eval").body) * factor)
parsed = int(_evaluate(ast.parse(arg, mode="eval").body))
except (SyntaxError, KeyError):
raise ValueError(arg)
if parsed <= 0:


正在加载...
取消
保存