Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local IAC, SB, SE = 0xFF, 0xFA, 0xF0
- local GMCP = 201
- function gmcp_send(data)
- SendPkt(string.char(IAC, SB, GMCP) .. string.gsub(data, "\255", "\255\255") .. string.char(IAC, SE))
- end
- function gmcp_handshake()
- gmcp_send('Core.Hello {"client": "MUSHclient", "version": "'..Version()..'"}')
- gmcp_send('Core.Supports.Set ["Char 1", "Char.Skills 1", "Char.Items 1", "Char.Defences 1", "Char.Afflictions 1", "Comm.Channel 1", "Room 1", "Redirect 1", "IRE.Rift 1", "IRE.Composer 1", "IRE.Time 1", "IRE.Target 1"]')
- end
- function OnPluginTelnetRequest(protocol, cmd)
- if (protocol == GMCP) and (cmd == "WILL") then
- return true
- end
- if (protocol == GMCP) and (cmd == "SENT_DO") then
- gmcp_handshake()
- return true
- end
- return false
- end
- function OnPluginTelnetSubnegotiation(protocol, data)
- if (protocol ~= GMCP) then
- return
- end
- local cmd, jd = string.match(data, "^([A-za-z%.]+)%s*(.*)$")
- if not cmd then
- return
- end
- if jd then
- if not string.match(jd, "^[%[%{]") then
- jd = "["..jd.."]"
- end
- end
- -- The following line has been commented out so as to allow you to handle the data as you wish (and to prevent accidentally spamming yourself out of your gourd in an infinite Char.Vitals loop as has happened to us all).
- -- Instead, I've added in echoes to display the data.
- -- Execute("parsegmcp "..cmd.." "..jd)
- Note("GMCP command: "..cmd)
- Note("GMCP data: "..jd)
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement