Tweaks
This commit is contained in:
parent
be7eb12ade
commit
9906bfbcb6
2 changed files with 17 additions and 18 deletions
|
@ -6,12 +6,12 @@ import re
|
||||||
|
|
||||||
# some simple "shortcodes" for formatting purposes
|
# some simple "shortcodes" for formatting purposes
|
||||||
shortcodes = {
|
shortcodes = {
|
||||||
'<b>': '\x02',
|
'[b]': '\x02',
|
||||||
'</b>': '\x02',
|
'[/b]': '\x02',
|
||||||
'<u>': '\x1F',
|
'[u]': '\x1F',
|
||||||
'</u>': '\x1F',
|
'[/u]': '\x1F',
|
||||||
'<i>': '\x16',
|
'[i]': '\x16',
|
||||||
'</i>': '\x16'}
|
'[/i]': '\x16'}
|
||||||
|
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
|
@ -115,7 +115,9 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||||
|
|
||||||
db_init(db)
|
db_init(db)
|
||||||
|
|
||||||
|
# attempt to get the factoid from the database
|
||||||
data = get_memory(db, inp.group(1).strip())
|
data = get_memory(db, inp.group(1).strip())
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
out = multiwordReplace(data, shortcodes)
|
out = multiwordReplace(data, shortcodes)
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
from util import hook
|
from util import hook, http
|
||||||
|
|
||||||
|
|
||||||
def find_location(ip, api):
|
def find_location(ip, api):
|
||||||
import string
|
response = http.get("http://api.ipinfodb.com/v3/ip-city/", key=api, ip=ip)
|
||||||
import urllib
|
|
||||||
response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key=" \
|
|
||||||
+ api + "&ip=" + ip).read()
|
|
||||||
response = response.split(";")
|
response = response.split(";")
|
||||||
give = {}
|
results = {}
|
||||||
give["country"] = response[4].title()
|
results["country"] = response[4].title()
|
||||||
give["country_short"] = response[3].upper()
|
results["country_short"] = response[3].upper()
|
||||||
give["state"] = response[5].title()
|
results["state"] = response[5].title()
|
||||||
give["city"] = response[6].title()
|
results["city"] = response[6].title()
|
||||||
give["timezone"] = response[10].title()
|
results["timezone"] = response[10].title()
|
||||||
return give
|
return results
|
||||||
|
|
||||||
|
|
||||||
def timezone(ip):
|
def timezone(ip):
|
||||||
|
|
Reference in a new issue