I'm working on a plugin at the moment, and one of the features I need to be able to do is capture the commands I send to the mud... I would prefer to stay away from aliases with this if possible. Is there some sort of function I can use that will allow for this?
Capturing outgoing commands
Posted by LupusFatalis on Fri 05 Jun 2009 09:03 PM — 7 posts, 32,320 views.
See http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks
In particular, the OnPluginSent callback. This lets you know something is definitely being sent (whether via a script, plugin, alias or whatever), if that is what you want. The idea here was for situations where you needed to know if you sent "north" to the MUD (for example), so you could track a mapping situation.
However if you literally want to capture commands you type (as opposed to what gets sent) then you might want the OnPluginCommand callback or the OnPluginCommandEntered callback. This captures things you type (which may or may not end up going to the MUD, because of aliases etc.).
In particular, the OnPluginSent callback. This lets you know something is definitely being sent (whether via a script, plugin, alias or whatever), if that is what you want. The idea here was for situations where you needed to know if you sent "north" to the MUD (for example), so you could track a mapping situation.
However if you literally want to capture commands you type (as opposed to what gets sent) then you might want the OnPluginCommand callback or the OnPluginCommandEntered callback. This captures things you type (which may or may not end up going to the MUD, because of aliases etc.).
Perfect, i'll check it out later today... And you guessed it, I need it for mapping purposes.
I get a type mismatch here... not sure what thats about... And then it stops sending anything to the mud. Any ideas?
def OnPluginSent(sText):
import os
path = 'C:\\DM_Maps\\'
if not os.path.exists(path): os.mkdir(path)
logfile = open(path + 'RoomCaptureTest.log', 'a')
logfile.write('MoveCommand=' + str(sText))
logfile.write('\n')
logfile.close()
I do. :)
Add return 0 to the end of your plugin callbacks that do not return a value. Something about the Python WSH bindings is odd and MUSHclient chokes on it. My experience says you totally mess up the innards, since triggering that error a second time tends to crash MUSHclient hard.
Add return 0 to the end of your plugin callbacks that do not return a value. Something about the Python WSH bindings is odd and MUSHclient chokes on it. My experience says you totally mess up the innards, since triggering that error a second time tends to crash MUSHclient hard.
Perfect, thanks! I always miss stuff like that... Probably because I'm more of a chronic dabbling coder than a programmer. Thanks again.
I ran into it around four years ago. Nick helped me out with the answer then. I'm just sharing the knowledge.