32 lines
858 B
Python
Executable File
32 lines
858 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
An iPython interactive console for debugging purposes.
|
|
"""
|
|
from IPython.terminal.embed import InteractiveShellEmbed
|
|
|
|
import module
|
|
|
|
def setup(bot):
|
|
bot.memory["iconsole_running"] = False
|
|
|
|
@module.require_admin("Only admins can start the interactive console")
|
|
@module.commands('console')
|
|
def interactive_shell(bot, trigger):
|
|
"""
|
|
Starts an interactive IPython console
|
|
"""
|
|
if bot.memory['iconsole_running']:
|
|
return bot.msg('Console already running')
|
|
|
|
banner1 = 'Fulvia interactive shell (embedded IPython)'
|
|
banner2 = '`bot` and `trigger` are available. To exit, type exit'
|
|
exitmsg = 'Interactive shell closed'
|
|
|
|
console = InteractiveShellEmbed(banner1=banner1, banner2=banner2,
|
|
exit_msg=exitmsg)
|
|
|
|
bot.memory['iconsole_running'] = True
|
|
bot.msg('console started')
|
|
console()
|
|
bot.memory['iconsole_running'] = False
|