Added API key for GEOIP to the config file
This commit is contained in:
parent
f712ee2633
commit
4b884e0ddf
2 changed files with 7 additions and 5 deletions
|
@ -26,7 +26,7 @@ if not os.path.exists('config'):
|
||||||
"disabled_commands": [],
|
"disabled_commands": [],
|
||||||
"prefix": ".",
|
"prefix": ".",
|
||||||
"acls": {},
|
"acls": {},
|
||||||
"api_keys": {},
|
"api_keys": {"geoip":"6ddac03a5a67a534045f59908e5c17fd68169609b453e3c6398823fff86a87c0"},
|
||||||
"censored_strings":
|
"censored_strings":
|
||||||
[
|
[
|
||||||
"DCC SEND",
|
"DCC SEND",
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
|
|
||||||
def find_location(ip):
|
def find_location(ip, api):
|
||||||
import string
|
import string
|
||||||
import urllib
|
import urllib
|
||||||
api = "6ddac03a5a67a534045f59908e5c17fd68169609b453e3c6398823fff86a87c0"
|
|
||||||
response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key="+api+"&ip="+ip).read()
|
response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key="+api+"&ip="+ip).read()
|
||||||
response = response.split(";")
|
response = response.split(";")
|
||||||
give = {}
|
give = {}
|
||||||
|
@ -21,9 +20,12 @@ def timezone(ip):
|
||||||
return int(time)
|
return int(time)
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def location(inp, say = None, me = None):
|
def locations(inp, say = None, me = None, bot = None):
|
||||||
".location <ip> - Performs a GeoIP check on the ip given."
|
".location <ip> - 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["country"] not in [""," ","-"," - "]:
|
||||||
if give["state"] == give["city"]:
|
if give["state"] == give["city"]:
|
||||||
localstring = give["city"]
|
localstring = give["city"]
|
||||||
|
|
Reference in a new issue