From 4b884e0ddf1c44334644862c1546b2b137950261 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 21 Nov 2011 18:18:22 +1300 Subject: [PATCH] Added API key for GEOIP to the config file --- core/config.py | 2 +- plugins/location.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/config.py b/core/config.py index f80b234..d6cbb30 100644 --- a/core/config.py +++ b/core/config.py @@ -26,7 +26,7 @@ if not os.path.exists('config'): "disabled_commands": [], "prefix": ".", "acls": {}, - "api_keys": {}, + "api_keys": {"geoip":"6ddac03a5a67a534045f59908e5c17fd68169609b453e3c6398823fff86a87c0"}, "censored_strings": [ "DCC SEND", diff --git a/plugins/location.py b/plugins/location.py index 7d8b2e4..83f6af7 100644 --- a/plugins/location.py +++ b/plugins/location.py @@ -1,9 +1,8 @@ from util import hook -def find_location(ip): +def find_location(ip, api): import string import urllib - api = "6ddac03a5a67a534045f59908e5c17fd68169609b453e3c6398823fff86a87c0" response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key="+api+"&ip="+ip).read() response = response.split(";") give = {} @@ -21,9 +20,12 @@ def timezone(ip): return int(time) @hook.command -def location(inp, say = None, me = None): +def locations(inp, say = None, me = None, bot = None): ".location - Performs a GeoIP check on the ip given." - give = find_location(inp) + api = bot.config['api_keys']['geoip'] + if api == "": + return "No API key" + give = find_location(inp, api) if give["country"] not in [""," ","-"," - "]: if give["state"] == give["city"]: localstring = give["city"]