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