[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Plugin to gag players using new array script routines

Plugin to gag players using new array script routines

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


Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Fri 19 Mar 2004 02:06 AM (UTC)

Amended on Fri 19 Mar 2004 02:07 AM (UTC) by Nick Gammon

Message
As a demonstration of how you might use the new array features (discussed elsewhere) I have written a plugin that uses them.

This shows some of the new script calls. For example, in the "plugin install" section we load up an array ...


ArrayCreate "gags"
ArrayImport "gags", GetVariable ("gags"), "|"


Then when the number of gagged players changes we save it back to the variable ...


SetVariable "gags", ArrayExport ("gags", "|")


We can see if a player is in the gag array like this:


If Not ArrayKeyExists ("gags", who) Then
    ColourNote "white", "red", who & " is not gagged."
  ...


We can add them with ArraySet. Note that the "key is the data" here, so the "value" is just the empty string ...


ArraySet "gags", who, ""  


We can delete them with ArrayDeleteKey ...


ArrayDeleteKey "gags", who


We can get a list of the gagged players with ArrayExportKeys ...


ArrayExportKeys ("gags", ",")


The full plugin is below. Note that you need version 3.46 to use this, which is not released at the present moment.


<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, March 19, 2004, 12:02 PM -->
<!-- MuClient version 3.46 -->

<!-- Plugin "Gag" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Gag"
   author="Nick Gammon"
   id="36e75e5c438fcd6f6c9f994d"
   language="VBscript"
   purpose="Gags annoying players"
   save_state="y"
   date_written="2004-03-19 11:58:21"
   requires="3.46"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This plugin will automatically customise a trigger to gag players who are annoying you.

You need to specify the regular expression that matches the text to be gagged, 
where "!!" represents the list of players whose names are to be gagged.

Usage
-----

gagsetmatch (regular expression)

eg.  gagsetmatch (!!) (says|whispers|tells you).*$

gag (player)      <-- gags a player

eg. gag turkey

ungag (player)    <-- ungags a player

eg. ungag turkey

gagshow           <-- shows list of gagged players

gaginfo           <-- shows information about the gag plugin

gaghelp           <-- show this information
]]>
</description>

</plugin>

<!--  Get our standard constants -->

<include name="constants.vbs"/>

<!--  Triggers  -->

<triggers>
  <trigger
   custom_colour="1"
   enabled="n"
   match="will be replaced when you gag someone"
   name="gags"
   omit_from_output="y"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   script="OnUnGag"
   match="ungag *"
   enabled="y"
   echo_alias="y"
   sequence="100"
  >
  </alias>
  <alias
   script="OnGag"
   match="gag *"
   enabled="y"
   echo_alias="y"
   sequence="100"
  >
  </alias>
  <alias
   script="OnShowGags"
   match="gagshow"
   enabled="y"
   sequence="100"
  >
  </alias>
  <alias
   script="OnGagInfo"
   match="gaginfo"
   enabled="y"
   sequence="100"
  >
  </alias>
  <alias
   script="OnGagSetMatch"
   match="gagsetmatch *"
   enabled="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Variables  -->

<variables>
  <variable name="regexp">(!!) (says|tells you).*$</variable>
</variables>

<!--  Script  -->


<script>
<![CDATA[
Sub OnPluginInstall

  ArrayCreate "gags"
  ArrayImport "gags", GetVariable ("gags"), "|"
'
'  Set up trigger after install
'
  Call MakeTrigger
  
  ColourNote "white", "maroon", "Gag plugin installed."
  Call OnShowGags "","",""

End Sub

Sub OnGag (name, line, wildcards)
dim who

  who = Trim (Lcase (wildcards (1)))

  If ArrayKeyExists ("gags", who) Then
    ColourNote "white", "red", who & " is already gagged."
  Else
    ArraySet "gags", who, ""  ' add to array of gagged players
    ColourNote "white", "blue", who & " added to list of gagged players."
    Call MakeTrigger
  End If  

End Sub

Sub OnUnGag (name, line, wildcards)

dim who

  who = Trim (Lcase (wildcards (1)))

  If Not ArrayKeyExists ("gags", who) Then
    ColourNote "white", "red", who & " is not gagged."
  Else
    ArrayDeleteKey "gags", who  ' remove from array of gagged players
    ColourNote "white", "blue", who & " removed from list of gagged players."
    Call MakeTrigger
  End If  

End Sub

Sub MakeTrigger
 
'
'  remember gag list in variable for plugin state save
'
  SetVariable "gags", ArrayExport ("gags", "|")
'
'  enable/disable trigger depending on whether we have gagged players
'
  EnableTrigger "gags", ArraySize ("gags") <> 0
'
'  change the trigger match text - replace !! by the gag list
'
  If SetTriggerOption ("gags", "match", _
     Replace (GetVariable ("regexp"), "!!", _
     ArrayExportKeys ("gags", "|"))) = eBadRegularExpression Then
    ColourNote "white", "red", _
      "Could not set trigger - check regular expression syntax"
    ColourNote "white", "red", "Regular expression is currently: " _
      & GetVariable ("regexp")
  End If

End Sub

Sub OnShowGags (name, line, wildcards)
dim gaglist

  If ArraySize ("gags") = 0 Then
    ColourNote "white", "blue", "No gagged players."
  Else
    gaglist = Replace (ArrayExportKeys ("gags", ","), ",", ", ")
    ColourNote "white", "maroon", "You have gagged: " & gaglist
  End If

End Sub

Sub OnGagSetMatch (name, line, wildcards)

  SetVariable "regexp", wildcards (1)
  Call MakeTrigger

End Sub

Sub OnGagInfo (name, line, wildcards)

  ColourNote "white", "blue", "Number of gagged players = " & _
      ArraySize ("gags")
  ColourNote "white", "blue", "Gagging regular expression = " & _
      GetVariable ("regexp")
  ColourNote "white", "blue", "(""!!"" will be replaced by gagged player names)"
  ColourNote "white", "blue", "Number of times gag trigger matched = " & _
      GetTriggerInfo ("gags", 21)

End Sub
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="gaghelp"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Arana   (20 posts)  [Biography] bio
Date Reply #1 on Thu 26 Aug 2010 04:27 AM (UTC)

Amended on Thu 26 Aug 2010 05:06 AM (UTC) by Arana

Message
i have a problem with this plugin , i see it is the same that comes with any of the latest versions, will try a different one posted around (lua) to see if it is something in the script or something on the plugin processing

it actually doesnt work in my mushclient (4.58)

i even modified the regexp part to no avail
here is what i changed (even tho it was not working even as it came originally)
in Sub OnShowGags i added )to see what the regexp outcome was):
Colournote "white", "maroon", Replace (GetVariable ("regexp"), "!!",ArrayExportKeys ("gags", "|"))


in variables i changed:
<variables>
  <variable name="regexp">^(.*)(!!) (.*?)$</variable>
</variables>


the plugin creates the gag list, updates the gagsetmatch as supposed to do, it just wont fire!!

gaginfo:
Number of gagged players = 2
Gagging regular expression = ^(.*)(!!) (.*?)$
("!!" will be replaced by gagged player names)
Number of times gag trigger matched = 0

gagshow:
You have gagged: knuckles, yeadan
^(.*)(knuckles|yeadan) (.*?)$

with this regexp i want to remove everyline of the output whenever one of those names appear, works well if i use a trigger i created myself but doesnt fire using the plugin.

if you need any information or any info you need to help me please ask, i am trying to make this work for blind users since the mud we use has a lot of spamming coming from clerics in some safe rooms. Of course they can just manually gag using a trigger but i want them to be able to use this plugin instead since they can have more control of it.

if i create a trigger with that exact regexp it works


thank you for your help


UPDATE:
while figuring this up, i installed other two gag plugins, one that has zmud style gag (or so it says http://gammon.com.au/forum/?id=6609) and it works fine, and another that uses lua http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2 also working fine

i just dont see WHERE in this one is the trigger actually created i see a maketriger sub, but i dont see the trigger ever actually being created.

EnableTrigger "gags", ArraySize ("gags") <> 0

but i dont have a GAGS trigger in my trigger lists for my world, i also see that the plugin file has it inside
<triggers>
  <trigger
   custom_colour="1"
   enabled="n"
   match="will be replaced when you gag someone"
   name="gags"
   omit_from_output="y"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>

but even when installing it it does not create a gags trigger for me
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 26 Aug 2010 07:42 AM (UTC)
Message
Arana said:

i just dont see WHERE in this one is the trigger actually created i see a maketriger sub, but i dont see the trigger ever actually being created.


The trigger is in the plugin already, it just modifies what it matches on.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #3 on Thu 26 Aug 2010 08:47 AM (UTC)
Message
And stuff in plugins won't clutter the world's dialog boxes. You won't see them in dialog boxes. I believe the Debug.Summary() function enumerates them however.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Thu 26 Aug 2010 08:53 AM (UTC)
Message

Debug ("summary")

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #5 on Thu 26 Aug 2010 09:23 AM (UTC)
Message
Yea, that... :)
[Go to top] top

Posted by Arana   (20 posts)  [Biography] bio
Date Reply #6 on Thu 26 Aug 2010 03:07 PM (UTC)

Amended on Thu 26 Aug 2010 06:44 PM (UTC) by Arana

Message
i chekced the one in here http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2

it works for me and it does create a trigger in the dialog box (maybe because it uses a different method)
the thing is that even if this plugin does or does not create a trigger or has it included in itself, it just wont fire ,

how can i debug/troubleshoot what is going on?
i want to fix this so it works for us (my friend installed it and it just wont work for hi either)

where must i put this debug ("summary")?
i set script to lua as the page about summary says and tried it in immediate window, it comes with an error like this:

Run-time error
World: myworld
Immediate execution
[string "Immediate"]:1: attempt to call global 'debug' (a table value)
stack traceback:
[string "Immediate"]:1: in main chunk


also tried adding it to the onshowgag sub also errored

Considering that a manually created trigger with the same regexp does work.

thanks for your help
[Go to top] top

Posted by Arana   (20 posts)  [Biography] bio
Date Reply #7 on Thu 26 Aug 2010 06:48 PM (UTC)
Message
wlle just wanted to let you know that i know finally why it didnt work

as it comes it is case sensitive, thus it would match on 'enki tells you' but not on 'Enki tells you'

even if you specify Enki (capitalized) since the script turns it to lowercase when it adds it to the list, but it never considers that it may come capitalized from the mud, so just adding


ignore_case='y' to the trigger made it work as i wanted


<triggers>
  <trigger
   custom_colour="1"
   enabled="n"
   match="will be replaced when you gag someone"
   name="gags"
   omit_from_output="y"
   regexp="y"
   ignore_case='y'
   sequence="100"
  >
  </trigger>
</triggers>



[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Thu 26 Aug 2010 08:21 PM (UTC)
Message
Arana said:

where must i put this debug ("summary")?
i set script to lua as the page about summary says and tried it in immediate window, it comes with an error like this:

attempt to call global 'debug' (a table value)


First, you need a recent version, like 4.55 onwards.

http://gammon.com.au/forum/bbshowpost.php?bbtopic_id=1

Second, the code was:


Debug ("summary")

not:

debug ("summary")


Lua is case-sensitive. Debug is a function added to MUSHclient, debug (lower-case) is one of the Lua libraries (and is a table, hence the error message).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Arana   (20 posts)  [Biography] bio
Date Reply #9 on Thu 26 Aug 2010 09:33 PM (UTC)
Message
Arana said:


... in my mushclient (4.58)




thank you it was the Capital.

btw since that plugin is included in recent versions of mush it might be good idea to include the ignore case option in it.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Thu 26 Aug 2010 11:13 PM (UTC)
Message
Do you mean the word "debug"? I can't change that, both words exist in the Lua script space.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Arana   (20 posts)  [Biography] bio
Date Reply #11 on Fri 27 Aug 2010 06:38 PM (UTC)
Message
oh no, i meant the :

ignore_case='y'

in the trigger, that was what was giving us the headeches after all
[Go to top] 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.


33,331 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]