Because I don't want to learn yet another programming language (Ruby), and because every time I tried learning sockets in C++ I screwed SOMETHING up, I decided to do it the easy way and create a sort of Webbot plugin via MUSHClient that will run in my PennMUSH world and update a php file in my htdocs folder.
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
group="WebBot"
match="WEBSITE_UPDATE"
omit_from_log="y"
omit_from_output="y"
send_to="12"
sequence="100"
>
<send>EnableTrigger("Status_Write",true)
AppendToNotepad("WebUpdate","<?php\r\necho "..string.char(34).."<ul>"..string.char(34)..";\r\n")</send>
</trigger>
<trigger
enabled="y"
group="WebBot"
match="^END\_WEBSITE\_UPDATE$"
omit_from_log="y"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>EnableTrigger("Status_Write",false)
AppendToNotepad("WebUpdate","echo "..string.char(34).."</ul>"..string.char(34).."\r\n?>")
SaveNotepad("WebUpdate",GetVariable("wwwroot") .. "serverstat.php",1)
CloseNotepad("WebUpdate",0)</send>
</trigger>
<trigger
group="WebBot"
keep_evaluating="y"
match="^(.*?)$"
name="Status_Write"
omit_from_log="y"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "%1" == "END_WEBSITE_UPDATE" then
else
AppendToNotepad("WebUpdate", "echo "..string.char(34).."<li/>%1"..string.char(34)..";\r\n");
end -- if
</send>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="set webbot path=*"
enabled="y"
group="WebBot"
send_to="12"
sequence="100"
>
<send>SetVariable("wwwroot","%1")
ColourNote("#7700FF","black","WEBUPDATE will save to: '","#FF00FF","black",GetVariable("wwwroot") .. "serverstat.php","#7700FF","black","'")</send>
</alias>
<alias
match="set webbot timer=*"
enabled="y"
group="WebBot"
send_to="12"
sequence="100"
>
<send>SetVariable("webbot_time","%1")
SetTimerOption("webbot_timer", "minute", GetVariable("webbot_time"))
ColourNote("#7700FF","black","WebBot will now update every ", "#FF00FF","black",GetVariable("webbot_time") .. " minutes")
if tostring(GetTimerInfo("webbot_timer",2)) == tostring(GetVariable("webbot_time")) then
ColourNote("#7700FF","black"," -Timer verified")
else
ColourNote("red","black","Timer not verified.")
ColourNote("red","black","Timer Minute: " .. GetTimerInfo("webbot_timer",2) .. ", Variable Minute: " .. GetVariable("webbot_time"))
end -- if</send>
</alias>
<alias
match="^webbot (stat|status)$"
enabled="y"
regexp="y"
group="WebBot"
send_to="12"
sequence="100"
>
<send>ColourNote("#7700FF","black","WebBot will update every ", "#FF00FF","black",GetVariable("webbot_time") .. " minutes")
ColourNote("#7700FF","black","WEBUPDATE will save to: '","#FF00FF","black",GetVariable("wwwroot") .. "serverstat.php","#7700FF","black","'")</send>
</alias>
<alias
match="^webbot standard command$"
enabled="y"
regexp="y"
group="WebBot"
send_to="12"
sequence="100"
>
<send>ColourNote("#7700FF","black","Standard TFG webupdate command:")
ColourNote("#FF00FF","black","&webupdate me = $webupdate:think WEBSITE_UPDATE%rName: [mudname()]%rMore stuff...%rEND_WEBSITE_UPDATE")</send>
</alias>
</aliases>
<!-- Timers -->
<timers>
<timer enabled="y" minute="30" second="0.00" offset_second="0.00" group="phpDump" omit_from_output="y" omit_from_log="y" name="webbot_timer">
<send>webupdate</send>
</timer>
</timers>
<script>
function OnPluginInstall()
SetTimerOption("webbot_timer", "minute", GetVariable("webbot_time"))
ColourNote("#6600FF","black","WebBot Timer Initialised")
end -- function
</script>
--------------------------------
Variables stored via state file
--------------------------------
Okay, so apart from all the extraneous scripting to make everything integrate properly with nice colored commands, my problem is this: every time this runs, it forces the PennMUSH world to steal focus. If I'm playing in another world, more often than not, this one will pop up (along with the quick flash of the notepad window) and stay on top, usually forcing me to type a few stupid characters into that window which were meant for the other one.
Is there a way to keep the world's focus status unchanged when messing around with CloseNotepad()? Or is there something I'm missing somewhere? I'm pretty sure that this plugin is rather straightforward, so I don't understand what would cause this.
Thanks.
-Daniel |