Various tweaks
This commit is contained in:
parent
6bb9819501
commit
61752baa24
11
bot.py
11
bot.py
|
@ -14,6 +14,7 @@ import os
|
|||
import Queue
|
||||
import sys
|
||||
import time
|
||||
import platform
|
||||
|
||||
sys.path += ['plugins'] # so 'import hook' works without duplication
|
||||
sys.path += ['lib']
|
||||
|
@ -25,6 +26,16 @@ class Bot(object):
|
|||
|
||||
print 'CloudBot %s (%s) <http://git.io/cloudbotirc>' % (__version__, __status__)
|
||||
|
||||
# print debug info
|
||||
opsys = platform.platform()
|
||||
python_imp = platform.python_implementation()
|
||||
python_ver = platform.python_version()
|
||||
architecture = ' '.join(platform.architecture())
|
||||
|
||||
print "Operating System: %s, Python " \
|
||||
"Version: %s %s, Architecture: %s" \
|
||||
"" % (opsys, python_imp, python_ver, architecture)
|
||||
|
||||
bot = Bot()
|
||||
bot.start_time = time.time()
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ def fact(inp, say=False, nick=False):
|
|||
|
||||
attempts = 0
|
||||
|
||||
# all of this is because omgfacts is fail
|
||||
while True:
|
||||
try:
|
||||
soup = http.get_soup('http://www.omg-facts.com/random')
|
||||
|
@ -22,7 +23,7 @@ def fact(inp, say=False, nick=False):
|
|||
fact = ''.join(response.find(text=True))
|
||||
|
||||
if fact:
|
||||
fact = http.unescape(fact.decode("utf-8")).strip()
|
||||
fact = http.unescape(unicode(fact)).strip()
|
||||
break
|
||||
else:
|
||||
if attempts > 2:
|
||||
|
|
|
@ -7,13 +7,13 @@ def eval_py(code, paste_multiline=True):
|
|||
while True:
|
||||
try:
|
||||
output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n')
|
||||
break
|
||||
except http.HTTPError:
|
||||
if attempts > 2:
|
||||
return "Failed to execute code."
|
||||
else:
|
||||
attempts += 1
|
||||
continue
|
||||
break
|
||||
|
||||
if "Traceback (most recent call last):" in output:
|
||||
status = "Python error: "
|
||||
|
|
Reference in New Issue