// Github: https://github.com/shdwjk/Roll20API/blob/master/Emas/Emas.js // By: The Aaron, Arcane Scriptomancer // Contact: https://app.roll20.net/users/104025/the-aaron const Emas = (() => { 'use strict'; const version = '0.8.3', lastUpdate = 1532274889, ch = function (c) { var entities = { '<' : 'lt', '>' : 'gt', "'" : '#39', '@' : '#64', '{' : '#123', '|' : '#124', '}' : '#125', '[' : '#91', ']' : '#93', '"' : 'quot', '-' : 'mdash', ' ' : 'nbsp' }; if(_.has(entities,c) ){ return ('&'+entities[c]+';'); } return ''; }, checkInstall = function() { log('-=> Emas v'+version+' <=- ['+(new Date(lastUpdate*1000))+']'); }, showHelp = function(who) { sendChat('', '/w "'+who+'" ' +'
' +'
' +'Emas v'+version +'
' +'
' +'

Emas provides the !emas command, which looks like /emas but ' +'works for everyone, as well as the !as command, which looks like ' +'/as but works for everyone. !w, !r, !gr as ' +'well.

' +'
' +'Commands' +'
' +'!emas '+ch('<')+'message'+ch('>')+'' +'
' +'

Sends a message in the same manner as /emas does for GMs.

' +'
    ' +'
  • ' +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to output as part of the emote.' +'
  • ' +'
' +'
' +'
' +'
' +'!as '+ch('<')+'target'+ch('>')+' '+ch('<')+'message'+ch('>')+'' +'
' +'

Sends a message in the same manner as /as does for GMs.

' +'
    ' +'
  • ' +''+ch('<')+'target'+ch('>')+' '+ch('-')+' The person to speak as.' +'
  • ' +'
  • ' +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to output as part of the emote.' +'
  • ' +'
' +'
' +'
' +'
' +'!w '+ch('<')+'target'+ch('>')+' '+ch('<')+'message'+ch('>')+'' +'
' +'

Sends a message in the same manner as /w does.

' +'
    ' +'
  • ' +''+ch('<')+'target'+ch('>')+' '+ch('-')+' The target of the whisper.' +'
  • ' +'
  • ' +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to whisper.' +'
  • ' +'
' +'
' +'
' +'
' +'!r '+ch('<')+'expression'+ch('>')+'' +'
' +'

Sends a expression in the same manner as /r does.

' +'
    ' +'
  • ' +''+ch('<')+'expression'+ch('>')+' '+ch('-')+' The dice expression to output.' +'
  • ' +'
' +'
' +'
' +'
' +'!gr '+ch('<')+'expression'+ch('>')+'' +'
' +'

Sends a message in the same manner as /gr does.

' +'
    ' +'
  • ' +''+ch('<')+'expression'+ch('>')+' '+ch('-')+' The dice expression to whisper to the GM (blindly).' +'
  • ' +'
' +'
' +'
' +'
' +'!desc '+ch('<')+'message'+ch('>')+'' +'
' +'

Sends a message in the same manner as /desc does.

' +'
    ' +'
  • ' +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to output as part of the description.' +'
  • ' +'
' +'
' +'
' +'
' ); }, handleInput = function(msg_orig) { const msg = _.clone(msg_orig); if (msg.type !== "api") { return; } if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ m['$[['+k+']]']="[["+v.expression+"]]"; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } const args = msg.content.split(/\s+/); const who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); switch(args.shift()) { case '!emas': if(1 === args.length) { showHelp(who); } else { sendChat(args[0],`/emas ${args.join(' ')}`); } break; case '!as': if(1 === args.length) { showHelp(who); } else { sendChat(args[0],`/as ${args.join(' ')}`); } break; case '!w': if(1 === args.length) { showHelp(who); } else { sendChat(msg.who,`/w "${who}" ${args.slice(1).join(' ')}`); sendChat(msg.who,`/w ${args.join(' ')}`); } break; case '!r': if(1 === args.length) { showHelp(who); } else { sendChat('',`/r ${args.join(' ')}`); } break; case '!gr': if(1 === args.length) { showHelp(who); } else { sendChat('',`/gr ${args.join(' ')}`); } break; case '!desc': if(1 === args.length) { showHelp(who); } else { sendChat('',`/desc ${args.join(' ')}`); } break; } }, registerEventHandlers = function() { on('chat:message', handleInput); }; return { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; })(); on("ready",function(){ 'use strict'; Emas.CheckInstall(); Emas.RegisterEventHandlers(); });