Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ WebBot Plugin steals focus

WebBot Plugin steals focus

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Daniel P   USA  (97 posts)  Bio
Date Wed 27 Apr 2011 08:33 AM (UTC)

Amended on Wed 27 Apr 2011 08:39 AM (UTC) by Daniel P

Message
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","&lt;?php\r\necho "..string.char(34).."&lt;ul&gt;"..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).."&lt;/ul&gt;"..string.char(34).."\r\n?&gt;")
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).."&lt;li/&gt;%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","&amp;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
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 27 Apr 2011 08:44 AM (UTC)
Message
My initial reaction when I saw this was: are you doing this stuff with a notepad window just to make a disk file? It looks a bit like it.

In that case, why not just use io.open, io.write, io.close? That definitely won't steal the focus:

http://www.gammon.com.au/scripts/doc.php?lua=io.open
http://www.gammon.com.au/scripts/doc.php?lua=io.write
http://www.gammon.com.au/scripts/doc.php?lua=io.close

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Daniel P   USA  (97 posts)  Bio
Date Reply #2 on Wed 27 Apr 2011 04:13 PM (UTC)

Amended on Wed 27 Apr 2011 04:26 PM (UTC) by Daniel P

Message
...There is such a thing!? Ooh. Lemme try this out!

Edit: It works! Awesome! I should probably print out the help files, bind them into a little book and read through them some evening. Thank you for pointing this out.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,844 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.