From d9426abec13df8f9743f49e7c87a2393c883e2b9 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 12 Aug 2019 16:07:07 +0100 Subject: [PATCH] suggest similar feeds when trying to remove an unknown feed closes #100 --- modules/rss.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/rss.py b/modules/rss.py index 42c333d1..41084e4c 100644 --- a/modules/rss.py +++ b/modules/rss.py @@ -1,7 +1,7 @@ #--depends-on config #--depends-on shorturl -import hashlib, time +import difflib, hashlib, time from src import ModuleManager, utils import feedparser @@ -153,7 +153,11 @@ class Module(ModuleManager.BaseModule): url = utils.http.url_sanitise(event["args_split"][1]) if not url in rss_hooks: - raise utils.EventError("I'm not watching that URL") + 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") rss_hooks.remove(url) changed = True message = "Removed RSS feed"