U
    (`H                     @   sp   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mZ G dd deZedddd	ZdS )
    N)AnyMapping)Bridge)OutPortChannelMessageProtoConfigMetadatac                   @   sB   e Zd Ze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metareturnc                    s   t d| d|  d S )N[z] )print)selfr   r   r    r    /opt/tsbridge/plugins/console.pysend_message   s    zConsole.send_message)bridgeout_portinstance_cfgr   c                    s"   || _ t }|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   s2   t j  }td|dd}t| j| d S )Nconsole)usertextchannel)	r   r   readlinestripr   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   r      s   r   )r   r   c                 C   s   |  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   r   <module>   s    