Difference between revisions of "Script:GM Code"
From Roll20 Wiki
(Created page with "{{stub}}") |
|||
Line 1: | Line 1: | ||
− | {{ | + | {{deprecated|dev}} |
+ | {{script overview | ||
+ | |name=GMCode | ||
+ | |author={{user profile|268993|Tristan Beard}} | ||
+ | |version=1.0 | ||
+ | |lastmodified=2015-01-07}} | ||
+ | |||
+ | '''GMCode''' generates a unique code to authenticate the GM. The code may then be used to identify the GM for elevated privileges in other scripts. | ||
+ | <br clear="all"> | ||
+ | |||
+ | === Syntax === | ||
+ | {{syntaxbox top|GMCode|formal=true}} | ||
+ | {{API command|gmcodehelp}}<br> | ||
+ | {{API command|gencode}} {{API parameter|name=code|optional=true}}<br> | ||
+ | {{API command|clearcode}} {{API parameter|name=code|optional=true}}<br> | ||
+ | {{API command|custcode}} {{API parameter|name=code</em> {{API parameter|name=new code}}<em>|optional=true}} | ||
+ | {{Formal API command| | ||
+ | }} | ||
+ | {{syntaxbox end}} | ||
+ | |||
+ | {{param description top}} | ||
+ | {{param description|name=code|value=Optional if no GM code exists, required otherwise. The value of the generated code, which can be seen in the API console log.}} | ||
+ | {{param description|name=new code|value=Value to change the GM code to.}} | ||
+ | {{param description bottom}} | ||
+ | |||
+ | If no GM code exists, the ''code'' parameter is optional in all of the above commands, and the script will generate a new code if it is omitted (regardless of which command besides <code>!gmcodehelp</code> is used). | ||
+ | |||
+ | <code>!gencode</code> will regenerate the GM code, while <code>!clearcode</code> will wipe the code out and <code>!custcode</code> will set the code to a specified value. | ||
+ | |||
+ | === Example === | ||
+ | The GM code is useful for verifying that the user has GM permissions, as the only means to see the code is in the API console log, which is only accessible by a GM. The value of the GM code can be accessed with <code>state.gmcode</code>, which you can then compare against user input to verify identity, similar to a PIN. | ||
+ | <pre data-language="javascript"> | ||
+ | on('chat:message', function(msg) { | ||
+ | var parameters = msg.content.splitArgs(), | ||
+ | command = parameters.shift().substring(1).toLowerCase(); | ||
+ | |||
+ | if (msg.type === 'api' && command === 'mycommand') { | ||
+ | if (state.gmcode && parameters[0] === state.gmcode) { | ||
+ | // GM authenticated | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | </pre> |
Revision as of 22:54, 13 January 2015
This script has been deprecated due to changes currently on the Dev Server |
Version: 1.0
Last Modified: 2015-01-07
Code: GMCode
Dependencies: None
Conflicts: None
GMCode generates a unique code to authenticate the GM. The code may then be used to identify the GM for elevated privileges in other scripts.
Syntax
!gmcodehelp
!gencode [code]
!clearcode [code]
!custcode [code <new code>]Formally:
Parameter | Values |
---|---|
code | Optional if no GM code exists, required otherwise. The value of the generated code, which can be seen in the API console log. |
new code | Value to change the GM code to. |
If no GM code exists, the code parameter is optional in all of the above commands, and the script will generate a new code if it is omitted (regardless of which command besides !gmcodehelp
is used).
!gencode
will regenerate the GM code, while !clearcode
will wipe the code out and !custcode
will set the code to a specified value.
Example
The GM code is useful for verifying that the user has GM permissions, as the only means to see the code is in the API console log, which is only accessible by a GM. The value of the GM code can be accessed with state.gmcode
, which you can then compare against user input to verify identity, similar to a PIN.
on('chat:message', function(msg) { var parameters = msg.content.splitArgs(), command = parameters.shift().substring(1).toLowerCase(); if (msg.type === 'api' && command === 'mycommand') { if (state.gmcode && parameters[0] === state.gmcode) { // GM authenticated } } });