From 5c405624d908216d6c1df69a6a4f7949678e09fc Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Fri, 17 Jan 2014 13:37:09 -0800 Subject: [PATCH] near: add 'miles' option --- plugins/tag.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/tag.py b/plugins/tag.py index b55acb8..665e754 100644 --- a/plugins/tag.py +++ b/plugins/tag.py @@ -219,10 +219,17 @@ def near(inp, nick='', chan='', db=None): nearby = db.execute("select nick, distance(lat, lon, ?, ?) as dist from location where chan=?" " and nick != lower(?) order by dist limit 20", (lat, lon, chan, nick)).fetchall() + in_miles = 'mi' in inp.lower() + out = '(km) ' + factor = 1.0 + if in_miles: + out = '(mi) ' + factor = 0.621 + while nearby and len(out) < 200: nick, dist = nearby.pop(0) - out += '%s:%.0f ' % (munge(nick, 1), dist) + out += '%s:%.0f ' % (munge(nick, 1), dist * factor) return out