<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: advanced_telopt</title> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>advanced_telopt</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/mud/nakedmud-mod/lib/pymodules/advanced_telopt.py">/mud/nakedmud-mod/lib/pymodules/advanced_telopt.py</a></font></td></tr></table> <p><tt>advanced_telopt.py<br> <br> Adds advanced TELOPT negotiations to the MUD, including support for:<br> <br> * TELOPT_NAWS - Negotiate About Window Size<br> Determine the size of the client window in columns and rows.<br> <br> * TELOPT_TTYPE - Terminal Type<br> Determine the connected client to estimate its capabilities.<br> <br> * TELOPT_EOR - End-of-Record<br> Mark the end of text transmission from the server with IAC EOR to let a<br> client know the exact point. If enabled, this is automatically appended<br> to the end of the prompt.<br> <br> * TELOPT_MSP - MUD Sound Protocol<br> Trigger the playback of sounds and music on the client. Only basic support<br> is included... negotiation and the triggering of hooks when it's enabled<br> or disabled. The rest of the implementation is up to the MUD creator, though<br> it consists merely of sending your own MSP commands to the client.<br> <br> * TELOPT_MSDP - MUD Server Data Protocol<br> MSDP allows you to easilly send variables to the client.<br> <br> * TELOPT_MXP - MUD eXtension Protocol<br> MXP is, for those who don't know, an application of HTML-like tags to the<br> MUD itself, allowing for richer interaction with the user. It is in no way<br> critical to playing and enjoying the game, but it is a nice touch.<br> <br> Note that this implementation of MXP isn't complete, as it doesn't handle<br> asking the client which tags it supports. I'd recommend keeping yourself<br> limited to simple tags like <SEND> if you don't add <SUPPORTS> support.<br> <br> For more information about MXP, visit <a href="http://www.zuggsoft.com/zmud/mxp.htm">http://www.zuggsoft.com/zmud/mxp.htm</a><br> <br> * Window Title Text<br> Set a custom string to the window's title bar. This also works together<br> with TELOPT_TTYPE to avoid sending the code to clients that wouldn't<br> properly interpret it.<br> <br> If the bell() function of a socket is called, the title will be flashed<br> with two prepended asterisks until the next command is recieved. This can<br> be used to notify a distracted player when the MUD needs their input.<br> <br> * XTERM 256 and ANSI Colors<br> This file also handles color code parsing, taking that functionality away<br> from colour.py as to combine color formatting and MXP conversion into one<br> post-processing function. I haven't tested it, but I can only assume that<br> one less function call makes things easier on the server.</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom> <br> <font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="auxiliary.html">auxiliary</a><br> <a href="event.html">event</a><br> <a href="hooks.html">hooks</a><br> </td><td width="25%" valign=top><a href="mud.html">mud</a><br> <a href="mudsock.html">mudsock</a><br> <a href="mudsys.html">mudsys</a><br> </td><td width="25%" valign=top><a href="random.html">random</a><br> <a href="re.html">re</a><br> <a href="storage.html">storage</a><br> </td><td width="25%" valign=top><a href="telnetlib.html">telnetlib</a><br> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ee77aa"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> <td width="100%"><dl> <dt><font face="helvetica, arial"><a href="advanced_telopt.html#TeloptAux">TeloptAux</a> </font></dt><dt><font face="helvetica, arial"><a href="advanced_telopt.html#VariableData">VariableData</a> </font></dt></dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="TeloptAux">class <strong>TeloptAux</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="TeloptAux-__init__"><strong>__init__</strong></a>(self, set<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="TeloptAux-copy"><strong>copy</strong></a>(self)</dt></dl> <dl><dt><a name="TeloptAux-copyTo"><strong>copyTo</strong></a>(self, to)</dt></dl> <dl><dt><a name="TeloptAux-load"><strong>load</strong></a>(self, set<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="TeloptAux-store"><strong>store</strong></a>(self)</dt></dl> </td></tr></table> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="VariableData">class <strong>VariableData</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>################################################################################<br> # Auxiliary Data for the Socket<br> ################################################################################<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="VariableData-__delitem__"><strong>__delitem__</strong></a>(self, key)</dt></dl> <dl><dt><a name="VariableData-__getitem__"><strong>__getitem__</strong></a>(self, key)</dt></dl> <dl><dt><a name="VariableData-__init__"><strong>__init__</strong></a>(self)</dt></dl> <dl><dt><a name="VariableData-__setitem__"><strong>__setitem__</strong></a>(self, key, val)</dt></dl> <dl><dt><a name="VariableData-__str__"><strong>__str__</strong></a>(self)</dt></dl> <dl><dt><a name="VariableData-copy"><strong>copy</strong></a>(self)</dt></dl> <dl><dt><a name="VariableData-has_key"><strong>has_key</strong></a>(self, key)</dt></dl> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#eeaa77"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> <td width="100%"><dl><dt><a name="-__unload__"><strong>__unload__</strong></a>()</dt><dd><tt>Detatch our hooks from the game.</tt></dd></dl> <dl><dt><a name="-ansi_color"><strong>ansi_color</strong></a>(match)</dt><dd><tt>Replace a matching color code with the simplified ANSI escape sequence.</tt></dd></dl> <dl><dt><a name="-begin_negotiations"><strong>begin_negotiations</strong></a>(info)</dt><dd><tt>Sends the initial negotiation strings to new sockets.</tt></dd></dl> <dl><dt><a name="-c256_color"><strong>c256_color</strong></a>(match)</dt><dd><tt>Replace a matching color code with the proper 256-color escape sequence.</tt></dd></dl> <dl><dt><a name="-cmd_colors"><strong>cmd_colors</strong></a>(ch, cmd, arg)</dt><dd><tt>Usage: {Wcolors{n<br> <br> Displays a table of avaliable colors and the code used to select them.</tt></dd></dl> <dl><dt><a name="-copyover"><strong>copyover</strong></a>()</dt><dd><tt>Saves the telopt auxiliary data of all active connections with set players<br> to be restored after the copyover is complete.</tt></dd></dl> <dl><dt><a name="-copyover_complete"><strong>copyover_complete</strong></a>(info)</dt><dd><tt>Loads socket auxiliary data for the active connections from a file.</tt></dd></dl> <dl><dt><a name="-flash_title"><strong>flash_title</strong></a>(owner, data, arg)</dt><dd><tt>Scheduled event that, once per second, toggles the titlebar notification flag and sends the updated title to the client.</tt></dd></dl> <dl><dt><a name="-msdp_start_hook"><strong>msdp_start_hook</strong></a>(info)</dt><dd><tt>Send out all the current MSDP variables.</tt></dd></dl> <dl><dt><a name="-mxp_color"><strong>mxp_color</strong></a>(match)</dt><dd><tt>Replace a matching color code with an MXP tag. This is for zMUD.</tt></dd></dl> <dl><dt><a name="-mxp_start_hook"><strong>mxp_start_hook</strong></a>(info)</dt><dd><tt>Send out our notice that MXP is starting, along with the MXP tags.</tt></dd></dl> <dl><dt><a name="-mxp_stop_hook"><strong>mxp_stop_hook</strong></a>(info)</dt><dd><tt>Send a wont MXP string.</tt></dd></dl> <dl><dt><a name="-mxp_tag"><strong>mxp_tag</strong></a>(sock, text<font color="#909090">=''</font>, tag<font color="#909090">=''</font>, args<font color="#909090">=''</font>, closing<font color="#909090">=False</font>)</dt><dd><tt>Output a MXP tag. If it's a secure tag, flag the socket so it's next line is sent secure.<br> <br> If closing is true and text is not supplied, only a closing tag will be returned. Be sure that args is None if you're making a closing tag.<br> If text is None, only a single tag will be created. This can be useful for sending things like the <IMAGE> tag.</tt></dd></dl> <dl><dt><a name="-post_command"><strong>post_command</strong></a>(info)</dt><dd><tt>Hook that will stop flashing the titlebar once a command is recieved.</tt></dd></dl> <dl><dt><a name="-process_iac_sequence"><strong>process_iac_sequence</strong></a>(info)</dt><dd><tt>Process the IAC sequence to see if it was one of the options supported.</tt></dd></dl> <dl><dt><a name="-process_outbound_prompt"><strong>process_outbound_prompt</strong></a>(info)</dt><dd><tt>Process outbound prompt to add END-OF-RECORD on the end if necessary.</tt></dd></dl> <dl><dt><a name="-process_outbound_text"><strong>process_outbound_text</strong></a>(info)</dt><dd><tt>Process outbound text by replacing color codes and escaping MXP tags.</tt></dd></dl> <dl><dt><a name="-register_mxp_flag"><strong>register_mxp_flag</strong></a>(name, flag)</dt><dd><tt>Add a new MXP flag to the list of tags. This is good for easilly setting a list of<br> variables for things like the prompt, or adding custom tags for flagging room<br> names and descriptions and the like.</tt></dd></dl> <dl><dt><a name="-register_mxp_tag"><strong>register_mxp_tag</strong></a>(name, args<font color="#909090">=None</font>, secure<font color="#909090">=False</font>)</dt><dd><tt>Add a new MXP tag to the list of tags. The name must be an alphanumeric string, and<br> args should be a string of the element's arguments, though it could be None. If secure<br> is true, the tag will be added to a list of flags that are sent via an MXP secure line.</tt></dd></dl> <dl><dt><a name="-rgb2hsv"><strong>rgb2hsv</strong></a>(r, g, b)</dt><dd><tt>Convert an RGB color to HSV.</tt></dd></dl> <dl><dt><a name="-send_title"><strong>send_title</strong></a>(sock)</dt><dd><tt>Sends the current title string to the socket.</tt></dd></dl> <dl><dt><a name="-simplecolor"><strong>simplecolor</strong></a>(c, html<font color="#909090">=False</font>)</dt><dd><tt>Simplify an xterm 256 color code down to ANSI 16. It isn't perfect,<br> but it works a whole lot better than stripping all color, or letting<br> people with poor client choices from seeing a screen of garbled mess.<br> <br> Will return an HTML hex color code if html is true</tt></dd></dl> </td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> <td width="100%"><strong>MSDP</strong> = 'E'<br> <strong>MSDP_VAL</strong> = '<font color="#c040c0">\x02</font>'<br> <strong>MSDP_VAR</strong> = '<font color="#c040c0">\x01</font>'<br> <strong>MSP</strong> = 'Z'<br> <strong>MXP</strong> = '['<br> <strong>client_do_eor</strong> = '<font color="#c040c0">\xff\xfd\x19</font>'<br> <strong>client_do_msdp</strong> = '<font color="#c040c0">\xff\xfd</font>E'<br> <strong>client_do_msp</strong> = '<font color="#c040c0">\xff\xfd</font>Z'<br> <strong>client_do_mxp</strong> = '<font color="#c040c0">\xff\xfd</font>['<br> <strong>client_dont_eor</strong> = '<font color="#c040c0">\xff\xfe\x19</font>'<br> <strong>client_dont_msdp</strong> = '<font color="#c040c0">\xff\xfe</font>E'<br> <strong>client_dont_msp</strong> = '<font color="#c040c0">\xff\xfe</font>Z'<br> <strong>client_dont_mxp</strong> = '<font color="#c040c0">\xff\xfe</font>['<br> <strong>client_naws</strong> = '<font color="#c040c0">\xff\xfa\x1f</font>'<br> <strong>client_ttype_is</strong> = '<font color="#c040c0">\xff\xfa\x18</font>'<br> <strong>client_will_naws</strong> = '<font color="#c040c0">\xff\xfb\x1f</font>'<br> <strong>client_will_ttype</strong> = '<font color="#c040c0">\xff\xfb\x18</font>'<br> <strong>clients</strong> = ['jmud', 'xterm', 'fmud', 'zmud', 'mushclient', 'tintin++', 'ansi', 'unknown']<br> <strong>clients256</strong> = ['jmud', 'zmud', 'mushclient', 'tintin++', 'xterm']<br> <strong>coloreg</strong> = <_sre.SRE_Pattern object><br> <strong>colorletters</strong> = 'drgybpcwDRGYBPCW'<br> <strong>colors</strong> = {'b': '34', 'c': '36', 'd': '30', 'g': '32', 'n': '0', 'p': '35', 'r': '31', 'w': '37', 'y': '33'}<br> <strong>colorvalues</strong> = [0, 95, 135, 175, 215, 255]<br> <strong>copyover_file</strong> = '../lib/misc/copyover'<br> <strong>extcolors</strong> = ['0;30', '0;31', '0;32', '0;33', '0;34', '0;35', '0;36', '0;37', '1;30', '1;31', '1;32', '1;33', '1;34', '1;35', '1;36', '1;37', '0;30', '0;34', '0;34', '0;34', ...]<br> <strong>htmlcolors</strong> = ['#000000', '#800000', '#008000', '#808000', '#000080', '#800080', '#008080', '#C0C0C0', '#808080', '#FF0000', '#00FF00', '#FFFF00', '#0000FF', '#FF00FF', '#00FFFF', '#FFFFFF', '#000000', '#00005f', '#000087', '#0000af', ...]<br> <strong>linkreg</strong> = <_sre.SRE_Pattern object><br> <strong>msdp_end</strong> = '<font color="#c040c0">\xff\xf0</font>'<br> <strong>msdp_start</strong> = '<font color="#c040c0">\xff\xfa</font>E'<br> <strong>mxp_and</strong> = '<font color="#c040c0">\x04</font>MXP<font color="#c040c0">\x03</font>'<br> <strong>mxp_escape</strong> = '<font color="#c040c0">\x1b</font>['<br> <strong>mxp_lock_locked</strong> = '<font color="#c040c0">\x1b</font>[7z'<br> <strong>mxp_lock_open</strong> = '<font color="#c040c0">\x1b</font>[5z'<br> <strong>mxp_lock_secure</strong> = '<font color="#c040c0">\x1b</font>[6z'<br> <strong>mxp_locked_line</strong> = '<font color="#c040c0">\x1b</font>[2z'<br> <strong>mxp_open_line</strong> = '<font color="#c040c0">\x1b</font>[0z'<br> <strong>mxp_reset</strong> = '<font color="#c040c0">\x1b</font>[3z'<br> <strong>mxp_secure_line</strong> = '<font color="#c040c0">\x1b</font>[1z'<br> <strong>mxp_secure_tags</strong> = ['SEND', 'A', 'VAR', 'NOBR', 'P', 'BR', 'SBR', 'EXPIRE', 'VERSION', 'SUPPORT', 'GAUGE', 'STAT', 'SOUND', 'MUSIC', 'FRAME', 'DEST', 'RELOCATE', 'IMAGE', 'FILTER']<br> <strong>mxp_tag_end</strong> = '<font color="#c040c0">\x02</font>MXP<font color="#c040c0">\x03</font>'<br> <strong>mxp_tag_start</strong> = '<font color="#c040c0">\x01</font>MXP<font color="#c040c0">\x03</font>'<br> <strong>mxp_tags</strong> = []<br> <strong>mxp_temp_secure</strong> = '<font color="#c040c0">\x1b</font>[4z'<br> <strong>mxpreg</strong> = <_sre.SRE_Pattern object><br> <strong>no_title</strong> = ['fmud', 'zmud', 'mushclient', 'ansi', 'unknown']<br> <strong>server_do_naws</strong> = '<font color="#c040c0">\xff\xfd\x1f</font>'<br> <strong>server_do_ttype</strong> = '<font color="#c040c0">\xff\xfd\x18</font>'<br> <strong>server_eor_code</strong> = '<font color="#c040c0">\xff\xef</font>'<br> <strong>server_send_ttype</strong> = '<font color="#c040c0">\xff\xfa\x18\x01\xff\xf0</font>'<br> <strong>server_start_mxp</strong> = '<font color="#c040c0">\xff\xfa</font>[<font color="#c040c0">\xff\xf0</font>'<br> <strong>server_will_eor</strong> = '<font color="#c040c0">\xff\xfb\x19</font>'<br> <strong>server_will_msdp</strong> = '<font color="#c040c0">\xff\xfb</font>E'<br> <strong>server_will_msp</strong> = '<font color="#c040c0">\xff\xfb</font>Z'<br> <strong>server_will_mxp</strong> = '<font color="#c040c0">\xff\xfb</font>['<br> <strong>server_wont_eor</strong> = '<font color="#c040c0">\xff\xfc\x19</font>'<br> <strong>server_wont_msp</strong> = '<font color="#c040c0">\xff\xfc</font>Z'<br> <strong>server_wont_mxp</strong> = '<font color="#c040c0">\xff\xfc</font>['</td></tr></table> </body></html>