3
ąU^&                 @   sl   d dl Z d dlZd dlmZmZ d dlmZ d dlmZm	Z	m
Z
mZmZ G dd deZedddd	ZdS )
    N)AnyMapping)Bridge)OutPortChannelMessageProtoConfigc               @   s@   e Zd ZeeddddZeeeddddZ	ddd	d
Z
dS )ConsoleN)
to_channelmessagereturnc                s   t d| d|  d S )N[z] )print)selfr   r    r    /opt/tsbridge/plugins/console.pysend_message   s    zConsole.send_message)bridgeout_portinstance_cfgr   c                s"   || _ tj }|jtj| j d S )N)r   asyncioget_event_loop
add_readersysstdinmessage_handler)r   r   r   r   loopr   r   r   start   s    zConsole.start)r   c             C   s.   t jj }td|dd}tj| jj| d S )Nconsole)usertextchannel)r   r   readliner   r   create_taskr   put_message)r   datamsgr   r   r   r      s    
zConsole.message_handler)__name__
__module____qualname__r   r   r   r   r   r	   r   r   r   r   r   r   r
      s   r
   )r   r   c             C   s   | j dt d S )Nr   )add_protocolr
   )r   r   r   r   init   s    r,   )r   r   typingr   r   core.bridger   
core.typesr   r   r   r   r	   r
   r,   r   r   r   r   <module>   s   