Rework prompt: add exception classes for errors and reload/quit

This commit is contained in:
nemunaire 2015-01-01 23:17:02 +01:00
commit fd6d9288f7
6 changed files with 89 additions and 19 deletions

View file

@ -26,6 +26,7 @@ import sys
import bot
import prompt
from prompt.builtins import load_file
from prompt.reset import PromptReset
import importer
if __name__ == "__main__":
@ -116,7 +117,13 @@ if __name__ == "__main__":
print ("Nemubot v%s ready, my PID is %i!" % (bot.__version__,
os.getpid()))
context.start()
while prmpt.run(context):
while True:
try:
prmpt.run(context)
except PromptReset as e:
if e.type == "quit":
break
try:
# Reload context
imp.reload(bot)