Difference between revisions of "Script:GM Code"
From Roll20 Wiki
m |
(→Syntax) |
||
Line 16: | Line 16: | ||
{{API command|custcode}} {{API parameter|name=code</em> {{API parameter|name=new code}}<em>|optional=true}} | {{API command|custcode}} {{API parameter|name=code</em> {{API parameter|name=new code}}<em>|optional=true}} | ||
{{Formal API command| | {{Formal API command| | ||
+ | {{token|S}} {{rarr}} gmcodehelp<br> | ||
+ | {{token|S}} {{rarr}} gencode {{token|optional code|-}} | ||
+ | {{token|S}} {{rarr}} clearcode {{token|optional code|-}} | ||
+ | {{token|S}} {{rarr}} custcode {{token|code change|-}} | ||
+ | {{token|code change}} {{rarr}} {{epsilon}} | ||
+ | {{token|code change}} {{rarr}} {{token|code}} {{token|code|-}} | ||
+ | {{token|optional code}} {{rarr}} {{epsilon}} | ||
+ | {{token|optional code}} {{rarr}} {{token|code|-}} | ||
+ | {{token|code}} {{rarr}} {{integer}} | ||
}} | }} | ||
{{syntaxbox end}} | {{syntaxbox end}} |
Revision as of 22:58, 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:
S
→ gmcodehelp
S
→ gencodeoptional code
S
→ clearcodeoptional code
S
→ custcodecode change
code change
→ ε
code change
→code
code
optional code
→ ε
optional code
→code
code
→ integer
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 } } });