Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Message
| Here is my test bed plugin.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="plugin1"
author="Nick Gammon"
id="91b90c3974e1da6daf1e3b9e"
language="Lua"
purpose="Tests script callbacks"
date_written="2010-09-18 10:49:15"
requires="4.61"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
-- Tests all plugin callbacks (for version 4.62 testing)
-- Author: Nick Gammon
-- Date: 18 Sep 2010
-- what to return
retval = true
function showinfo (name, args)
CallPlugin ("126d9061f9758498c878a204", "MsgNote", "Plugin1 got: " .. name)
for k, v in ipairs (args) do
CallPlugin ("126d9061f9758498c878a204", "MsgNote", " arg " .. k .. " = " .. v)
end -- for
CallPlugin ("126d9061f9758498c878a204", "MsgNote", "")
end -- showinfo
function OnPluginBroadcast (...)
showinfo ("OnPluginBroadcast", {...})
return retval
end -- OnPluginBroadcast
function OnPluginChatAccept (...)
showinfo ("OnPluginChatAccept", {...})
return retval
end -- OnPluginChatAccept
function OnPluginChatDisplay (...)
showinfo ("OnPluginChatDisplay", {...})
return retval
end -- OnPluginChatDisplay
function OnPluginChatMessage (...)
showinfo ("OnPluginChatMessage", {...})
return retval
end -- OnPluginChatMessage
function OnPluginChatMessageOut (...)
showinfo ("OnPluginChatMessageOut", {...})
return retval
end -- OnPluginChatMessageOut
function OnPluginChatNewUser (...)
showinfo ("OnPluginChatNewUser", {...})
return retval
end -- OnPluginChatNewUser
function OnPluginChatUserDisconnect (...)
showinfo ("OnPluginChatUserDisconnect", {...})
return retval
end -- OnPluginChatUserDisconnect
function OnPluginClose (...)
showinfo ("OnPluginClose", {...})
return retval
end -- OnPluginClose
function OnPluginCommand (...)
showinfo ("OnPluginCommand", {...})
return true
end -- OnPluginCommand
function OnPluginCommandChanged (...)
showinfo ("OnPluginCommandChanged", {...})
return retval
end -- OnPluginCommandChanged
function OnPluginCommandEntered (...)
showinfo ("OnPluginCommandEntered", {...})
return retval
end -- OnPluginCommandEntered
function OnPluginConnect (...)
showinfo ("OnPluginConnect", {...})
return retval
end -- OnPluginConnect
function OnPluginDisable (...)
showinfo ("OnPluginDisable", {...})
return retval
end -- OnPluginDisable
function OnPluginDisconnect (...)
showinfo ("OnPluginDisconnect", {...})
return retval
end -- OnPluginDisconnect
function OnPluginEnable (...)
showinfo ("OnPluginEnable", {...})
return retval
end -- OnPluginEnable
function OnPluginGetFocus (...)
showinfo ("OnPluginGetFocus", {...})
return retval
end -- OnPluginGetFocus
function OnPlugin_IAC_GA (...)
showinfo ("OnPlugin_IAC_GA", {...})
return retval
end -- OnPlugin_IAC_GA
function OnPluginInstall (...)
showinfo ("OnPluginInstall", {...})
return retval
end -- OnPluginInstall
function OnPluginLineReceived (...)
showinfo ("OnPluginLineReceived", {...})
return retval
end -- OnPluginLineReceived
function OnPluginListChanged (...)
showinfo ("OnPluginListChanged", {...})
return retval
end -- OnPluginListChanged
function OnPluginLoseFocus (...)
showinfo ("OnPluginLoseFocus", {...})
return retval
end -- OnPluginLoseFocus
function OnPluginMouseMoved (...)
showinfo ("OnPluginMouseMoved", {...})
return retval
end -- OnPluginMouseMoved
function OnPluginMXPcloseTag (...)
showinfo ("OnPluginMXPcloseTag", {...})
return retval
end -- OnPluginMXPcloseTag
function OnPluginMXPerror (...)
showinfo ("OnPluginMXPerror", {...})
return retval
end -- OnPluginMXPerror
function OnPluginMXPopenTag (...)
showinfo ("OnPluginMXPopenTag", {...})
return retval
end -- OnPluginMXPopenTag
function OnPluginMXPsetEntity (...)
showinfo ("OnPluginMXPsetEntity", {...})
return retval
end -- OnPluginMXPsetEntity
function OnPluginMXPsetVariable (...)
showinfo ("OnPluginMXPsetVariable", {...})
return retval
end -- OnPluginMXPsetVariable
function OnPluginMXPstart (...)
showinfo ("OnPluginMXPstart", {...})
return retval
end -- OnPluginMXPstart
function OnPluginMXPstop (...)
showinfo ("OnPluginMXPstop", {...})
return retval
end -- OnPluginMXPstop
function OnPluginPacketReceived (...)
showinfo ("OnPluginPacketReceived", {...})
return retval
end -- OnPluginPacketReceived
function OnPluginPartialLine (...)
showinfo ("OnPluginPartialLine", {...})
return retval
end -- OnPluginPartialLine
function OnPluginPlaySound (...)
showinfo ("OnPluginPlaySound", {...})
return retval
end -- OnPluginPlaySound
function OnPluginSaveState (...)
showinfo ("OnPluginSaveState", {...})
return retval
end -- OnPluginSaveState
function OnPluginScreendraw (...)
showinfo ("OnPluginScreendraw", {...})
return retval
end -- OnPluginScreendraw
function OnPluginSend (...)
showinfo ("OnPluginSend", {...})
return retval
end -- OnPluginSend
function OnPluginSent (...)
showinfo ("OnPluginSent", {...})
return retval
end -- OnPluginSent
function OnPluginTabComplete (...)
showinfo ("OnPluginTabComplete", {...})
return retval
end -- OnPluginTabComplete
function OnPluginTelnetOption (...)
showinfo ("OnPluginTelnetOption", {...})
return retval
end -- OnPluginTelnetOption
function OnPluginTelnetRequest (...)
showinfo ("OnPluginTelnetRequest", {...})
return retval
end -- OnPluginTelnetRequest
function OnPluginTelnetSubnegotiation (...)
showinfo ("OnPluginTelnetSubnegotiation", {...})
return retval
end -- OnPluginTelnetSubnegotiation
function OnPluginTick (...)
showinfo ("OnPluginTick", {...})
return retval
end -- OnPluginTick
function OnPluginTrace (...)
showinfo ("OnPluginTrace", {...})
return retval
end -- OnPluginTrace
function OnPluginWorldOutputResized (...)
showinfo ("OnPluginWorldOutputResized", {...})
return retval
end -- OnPluginWorldOutputResized
function OnPluginWorldSave (...)
showinfo ("OnPluginWorldSave", {...})
return retval
end -- OnPluginWorldSave
]]>
</script>
</muclient>
You'll see if you install it that you soon want to comment out some lines.
It requires the Messages_Window as described on this page:
http://www.gammon.com.au/forum/bbshowpost.php?id=10515
The basic idea is that it is a plugin will all possible callbacks in it. It shows when callbacks are called and what arguments get passed to them. You can also edit to control the return value (for example, if you return false or nil from some callbacks they suppress input and output).
I made a second one, almost identical copy, to see what happens with two plugins. Apart from changing the plugin name and plugin ID, the showinfo function was changed to:
function showinfo (name, args)
CallPlugin ("126d9061f9758498c878a204", "MsgNote", "Plugin2 got: " .. name, "yellow")
for k, v in ipairs (args) do
CallPlugin ("126d9061f9758498c878a204", "MsgNote", " arg " .. k .. " = " .. v, "yellow")
end -- for
CallPlugin ("126d9061f9758498c878a204", "MsgNote", "")
end -- showinfo
Basically it has the different plugin name, and the messages in a different colour.
Example output:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|