mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-05 17:15:36 +02:00
28 lines
538 B
Python
28 lines
538 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
import sys
|
|
|
|
|
|
class ConsoleChatter:
|
|
"""
|
|
Bot engine that reads from a stream and outputs to another
|
|
"""
|
|
|
|
input = None
|
|
output = None
|
|
|
|
def __init__( self, input=sys.stdin, output=sys.stdout ):
|
|
self.input = input
|
|
self.output = output
|
|
|
|
def start( self, bot ):
|
|
for line in self.input:
|
|
bot.onMessage( line )
|
|
|
|
def send( self, message ):
|
|
print( message, file=self.output, flush=True )
|
|
|
|
def stop( self ):
|
|
sys.exit(0)
|