#NEWLINE# def data_out( self , text = None , **kwargs ) : #NEWLINE# #INDENT# '\n        Data Evennia -> User. A generic hook method for engine to call\n        in order to send data through the telnet connection.\n\n        Kwargs:\n            text (str): Text to send.\n            oob (list): `[(cmdname,args,kwargs), ...]`, supply an\n                Out-of-Band instruction.\n            xterm256 (bool): Enforce xterm256 setting. If not given,\n                ttype result is used. If client does not suport xterm256,\n                the ansi fallback will be used\n            mxp (bool): Enforce mxp setting. If not given, enables if\n                we detected client support for it\n            ansi (bool): Enforce ansi setting. If not given, ttype\n                result is used.\n            nomarkup (bool): If True, strip all ansi markup (this is\n                the same as `xterm256=False, ansi=False`)\n            raw (bool):Pass string through without any ansi processing\n                (i.e. include Evennia ansi markers but do not convert them\n                into ansi tokens)\n            prompt (str): Supply a prompt text which gets sent without\n                a newline added to the end.\n            echo (str): Turn on/off line echo on the client, if the\n                client supports it (e.g. for password input). Remember\n                that you must manually activate it again later.\n\n        Notes:\n            The telnet TTYPE negotiation flags, if any, are used if no kwargs\n            are given.\n\n        ' #NEWLINE# try : #NEWLINE# #INDENT# text = utils . to_str ( ( text if text else '' ) , encoding = self . encoding ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . sendLine ( str ( e ) ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( ( 'oob' in kwargs ) and ( 'OOB' in self . protocol_flags ) ) : #NEWLINE# #INDENT# for ( cmdname , args , okwargs ) in kwargs [ 'oob' ] : #NEWLINE# #INDENT# self . oob . data_out ( cmdname , * args , ** useansi ) #NEWLINE# #UNINDENT# #UNINDENT# ttype = self . protocol_flags . get ( 'TTYPE' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# xterm256 = kwargs . get ( 'xterm256' , ( ttype . get ( '256 COLORS' , False ) if ttype . get ( 'init_done' ) else True ) ) #NEWLINE# useansi = kwargs . get ( 'ansi' , ( ( ttype and ttype . get ( 'ANSI' , False ) ) if ttype . get ( 'init_done' ) else True ) ) #NEWLINE# raw = kwargs . get ( 'raw' , False ) #NEWLINE# nomarkup = kwargs . get ( 'nomarkup' , ( not ( xterm256 or useansi ) ) ) #NEWLINE# prompt = kwargs . get ( 'prompt' ) #NEWLINE# echo = kwargs . get ( 'echo' , None ) #NEWLINE# mxp = kwargs . get ( 'mxp' , self . protocol_flags . get ( 'MXP' , False ) ) #NEWLINE# if raw : #NEWLINE# #INDENT# self . sendLine ( text ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if text : #NEWLINE# #INDENT# linetosend = ansi . parse_ansi ( ( _RE_N . sub ( '' , text ) + '{n' ) , strip_ansi = nomarkup , xterm256 = xterm256 , mxp = mxp ) #NEWLINE# if mxp : #NEWLINE# #INDENT# linetosend = mxp_parse ( linetosend ) #NEWLINE# #UNINDENT# self . sendLine ( linetosend ) #NEWLINE# #UNINDENT# #UNINDENT# if prompt : #NEWLINE# #INDENT# prompt = ansi . parse_ansi ( ( _RE_N . sub ( '' , prompt ) + '{n' ) , strip_ansi = nomarkup , xterm256 = xterm256 ) #NEWLINE# if mxp : #NEWLINE# #INDENT# prompt = mxp_parse ( prompt ) #NEWLINE# #UNINDENT# prompt = prompt . replace ( IAC , ( IAC + IAC ) ) . replace ( '\n' , '\r\n' ) #NEWLINE# prompt += ( IAC + GA ) #NEWLINE# self . transport . write ( mccp_compress ( self , prompt ) ) #NEWLINE# #UNINDENT# if echo : #NEWLINE# #INDENT# self . transport . write ( mccp_compress ( self , ( ( IAC + WONT ) + ECHO ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( echo == False ) : #NEWLINE# #INDENT# self . transport . write ( mccp_compress ( self , ( ( IAC + WILL ) + ECHO ) ) )