Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Message
| This is a small plugin that negotiates ATCP2, and displays what it receives. You can see the general idea of the protocol here.
![Template:saveplugin=ATCP2_Logger](/images/mushclient_logo_tiny.png) |
To save and install the ATCP2_Logger plugin do this:
- Copy between the lines below (to the Clipboard)
- Open a text editor (such as Notepad) and paste the plugin into it
- Save to disk on your PC, preferably in your plugins directory, as ATCP2_Logger.xml
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file ATCP2_Logger.xml (which you just saved in step 3) as a plugin
- Click "Close"
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="ATCP2_Logger"
author="Nick Gammon"
id="4a33087c6b66ca6c4611afed"
language="Lua"
purpose="Displays ATCP2 info"
date_written="2010-07-14"
requires="4.40"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
require "json"
require "tprint"
local IAC, SB, SE, DO = 0xFF, 0xFA, 0xF0, 0xFD
local ATCP = 200
local ATCP2 = 201
function Send_Telnet_Packet (what)
SendPkt (string.char (IAC, SB, ATCP2) ..
what ..
string.char (IAC, SE))
end -- Send_Telnet_Packet
function OnPluginTelnetSubnegotiation (msg_type, data)
if msg_type ~= ATCP2 then
return
end -- if not ATCP2
ColourNote ("darkorange", "", data)
message, params = string.match (data, "([%a.]+)%s+(.*)")
if not message then
return
end -- if
if not string.match (params, "^[%[{]") then
params = "[" .. params .. "]" -- sigh
end -- if
local t = json.decode (params)
if type (t) == "table" then
tprint (t)
end -- if
end -- function OnPluginTelnetSubnegotiation
function OnPluginTelnetRequest (msg_type, data)
if msg_type == ATCP2 and data == "WILL" then
return true
end -- if
if msg_type == ATCP2 and data == "SENT_DO" then
Note ("Enabling ATCP.")
Send_Telnet_Packet (string.format ('Core.Hello { "client": "MUSHclient", "version": "%s" }', Version ()))
Send_Telnet_Packet ('Core.Supports.Set [ "Char 1", "Char.Skills 1", "Char.Items 1" ]')
return true
end -- if ATCP login needed (just sent DO)
return false
end -- function OnPluginTelnetRequest
]]>
</script>
</muclient>
Sample output (my name x'd for privacy):
Char.StatusVars { "name": "Name", "fullname": "Full Name", "level": "Experience Level", "xp": "Experience To Next Level", "class": "Class", "city": "City", "house": "House", "order": "Order", "race": "Race" }
"order"="Order"
"class"="Class"
"xp"="Experience To Next Level"
"house"="House"
"race"="Race"
"city"="City"
"level"="Experience Level"
"name"="Name"
"fullname"="Full Name"
Char.Status { "name": "Cxxxxxxxx", "fullname": "Cxxxxxxxx", "level": "6", "xp": "2%", "class": "Paladin", "city": "(None)", "house": "(None)", "order": "(None)", "race": "Troll" }
"order"="(None)"
"class"="Paladin"
"xp"="2%"
"house"="(None)"
"race"="Troll"
"city"="(None)"
"level"="6"
"name"="Cxxxxxxxx"
"fullname"="Cxxxxxxxx"
Char.Skills.Groups [ "Vision Inept", "Avoidance Inept", "Tattoos Inept", "Survival Novice", "Weaponry Inept", "Riding Inept", "Devotion Inept", "Chivalry Inept", "Constitution Inept", "Thermology Inept", "Frost Inept", "Antidotes Inept", "Fitness Inept", "Galvanism Inept", "Philosophy Inept" ]
1="Vision Inept"
2="Avoidance Inept"
3="Tattoos Inept"
4="Survival Novice"
5="Weaponry Inept"
6="Riding Inept"
7="Devotion Inept"
8="Chivalry Inept"
9="Constitution Inept"
10="Thermology Inept"
11="Frost Inept"
12="Antidotes Inept"
13="Fitness Inept"
14="Galvanism Inept"
15="Philosophy Inept"
The caustic voice of Pandemonium clamours from the heavens as He shouts, "If My
heritage is all that You can think to disparage, then We will soon see the
continent drown beneath Your righteous ichor! To battle! To War!"
Char.Vitals "H:594/594 M:440/468 E:1870/1870 W:1240/1240 NL:2/100 "
1="H:594/594 M:440/468 E:1870/1870 W:1240/1240 NL:2/100 "
The plugin uses the Lua JSON module to decode the JSON. If you don't have that, just omit the couple of lines that do the decoding (although you will probably want to have it, to make more sense of the JSON code). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|