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
|
||||
shortcodes = {
|
||||
'<b>': '\x02',
|
||||
'</b>': '\x02',
|
||||
'<u>': '\x1F',
|
||||
'</u>': '\x1F',
|
||||
'<i>': '\x16',
|
||||
'</i>': '\x16'}
|
||||
'[b]': '\x02',
|
||||
'[/b]': '\x02',
|
||||
'[u]': '\x1F',
|
||||
'[/u]': '\x1F',
|
||||
'[i]': '\x16',
|
||||
'[/i]': '\x16'}
|
||||
|
||||
|
||||
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)
|
||||
|
||||
# attempt to get the factoid from the database
|
||||
data = get_memory(db, inp.group(1).strip())
|
||||
|
||||
if data:
|
||||
out = multiwordReplace(data, shortcodes)
|
||||
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
from util import hook
|
||||
from util import hook, http
|
||||
|
||||
|
||||
def find_location(ip, api):
|
||||
import string
|
||||
import urllib
|
||||
response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key=" \
|
||||
+ api + "&ip=" + ip).read()
|
||||
response = http.get("http://api.ipinfodb.com/v3/ip-city/", key=api, ip=ip)
|
||||
response = response.split(";")
|
||||
give = {}
|
||||
give["country"] = response[4].title()
|
||||
give["country_short"] = response[3].upper()
|
||||
give["state"] = response[5].title()
|
||||
give["city"] = response[6].title()
|
||||
give["timezone"] = response[10].title()
|
||||
return give
|
||||
results = {}
|
||||
results["country"] = response[4].title()
|
||||
results["country_short"] = response[3].upper()
|
||||
results["state"] = response[5].title()
|
||||
results["city"] = response[6].title()
|
||||
results["timezone"] = response[10].title()
|
||||
return results
|
||||
|
||||
|
||||
def timezone(ip):
|
||||
|
|
Reference in a new issue