diff --git a/plugins/ping.py b/plugins/ping.py index e2f6fe2..c9424da 100755 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -3,7 +3,7 @@ from util import hook import subprocess import re -PING_REGEX = "rtt min/avg/max/mdev = (\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)" +ping_regex = re.compile(r"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)") @hook.command @@ -27,9 +27,9 @@ def ping(inp, reply=None): reply("Attempting to ping %s %s times..." % (host, count)) pingcmd = subprocess.check_output(["ping", "-c", count, host]) - if 'request timed out' in pingcmd or 'unknown host' in pingcmd: + if "request timed out" in pingcmd or "unknown host" in pingcmd: return "error: could not ping host" else: - m = re.search(PING_REGEX, pingcmd) + m = re.search(ping_regex, pingcmd) return "min: %sms, max: %sms, average: %sms, range: %sms, count: %s" \ % (m.group(1), m.group(3), m.group(2), m.group(4), count) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index 088bc85..d8a9b62 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -1,7 +1,8 @@ from util import hook, http, urlnorm import re -titler = re.compile(r'(?si)(.+?)'); +titler = re.compile(r'(?si)(.+?)') + def parse(url): """ an improved version of our parsing code - now regex powered """ @@ -20,17 +21,17 @@ def parse(url): title = match.group(1) except: return "Could not parse URL! Are you sure its valid?" - + title = http.unescape(title) - + # if the url has been redirected, show us if real_url == url: return title else: return u"%s [%s]" % (title, real_url) + @hook.command def title(inp): ".title -- gets the title of a web page" return parse(inp) -