Add tell command to remind someone of something when they're back
Diff
dave/modules/speedtest.py | 1 +
dave/modules/tell.py | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
@@ -1,3 +1,4 @@
"""Read details from a speedtest test and print them to the channel."""
from requests import get
from bs4 import BeautifulSoup
import dave.module
@@ -1,0 +1,31 @@
"""Tell a user something next time we see them."""
import dave.module
import dave.config
import pickle
@dave.module.help("Syntax: tell [user] [message]. Tell a user something when we next "
"see them")
@dave.module.command(["tell"], "([A-Za-z_\-\[\]\\^{}|`][A-Za-z0-9_\-\[\]\\^{}|`]*) (.*)")
def tell(bot, args, sender, source):
dave.config.redis.lpush("tell:{}".format(args[0].lower()), pickle.dumps({
"sender": sender,
"msg": args[1]
}))
bot.reply(source, sender, "I'll let {} know when they're back.".format(args[0]))
@dave.module.match(r"(.*)")
@dave.module.priority(dave.module.Priority.HIGHEST)
@dave.module.always_run()
def check_msgs(bot, args, sender, source):
msgs = dave.config.redis.lrange("tell:{}".format(sender.lower()), 0, -1)
if msgs and len(msgs):
bot.msg(sender, "You have messages waiting for you:")
for msg in msgs:
msg = pickle.loads(msg)
bot.msg(sender, "<{}> {}".format(msg["sender"], msg["msg"]))
dave.config.redis.delete("tell:{}".format(sender.lower()))