suggest similar feeds when trying to remove an unknown feed

closes #100
This commit is contained in:
jesopo 2019-08-12 16:07:07 +01:00
parent 81a077c43a
commit d9426abec1

View file

@ -1,7 +1,7 @@
#--depends-on config #--depends-on config
#--depends-on shorturl #--depends-on shorturl
import hashlib, time import difflib, hashlib, time
from src import ModuleManager, utils from src import ModuleManager, utils
import feedparser import feedparser
@ -153,6 +153,10 @@ class Module(ModuleManager.BaseModule):
url = utils.http.url_sanitise(event["args_split"][1]) url = utils.http.url_sanitise(event["args_split"][1])
if not url in rss_hooks: if not url in rss_hooks:
matches = difflib.get_close_matches(url, rss_hooks, cutoff=0.5)
if matches:
raise utils.EventError("Did you mean %s ?" % matches[0])
else:
raise utils.EventError("I'm not watching that URL") raise utils.EventError("I'm not watching that URL")
rss_hooks.remove(url) rss_hooks.remove(url)
changed = True changed = True