Skip to content

Commit

Permalink
Add simple readline support to text console. (errbotio#960)
Browse files Browse the repository at this point in the history
This enables use of usual shell-like line-editing behaviours and provides an in-memory command history.
Unix-only: no-ops when readline module isn't available.
  • Loading branch information
rcoup authored and gbin committed Feb 6, 2017
1 parent 1c6c56b commit 253b20f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions errbot/backends/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ class TextBackend(ErrBot):
def __init__(self, config):
super().__init__(config)
log.debug("Text Backend Init.")

try:
# Load readline for better editing/history behaviour
import readline
except ImportError:
# Readline is Unix-only
log.debug("Python readline module is not available")
pass

self.bot_identifier = self.build_identifier('Err')
self.demo_mode = self.bot_config.TEXT_DEMO_MODE if hasattr(self.bot_config, 'TEXT_DEMO_MODE') else False
self._rooms = set()
Expand Down

0 comments on commit 253b20f

Please sign in to comment.