Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro-export/import #15

Open
cburschka opened this issue May 15, 2015 · 1 comment
Open

Macro-export/import #15

cburschka opened this issue May 15, 2015 · 1 comment

Comments

@cburschka
Copy link
Collaborator

As discussed.

Something like this added custom.js

chat.commands.importMacros = function (arg) {
  if (arg.trim()) config.settings.macros = JSON.parse(arg);
}
chat.commands.exportMacros = function () { 
  ui.messageAddInfo(JSON.stringify(config.settings.macros));
}
@cburschka
Copy link
Collaborator Author

Or with more control:

chat.commands.importMacros = function (arg) {
  arg = JSON.parse(arg);
  for (var cmd in arg) config.settings.macros[cmd] = arg[cmd];
  chat.saveSettings();
  ui.messageAddInfo('Macros saved.');
};
chat.commands.exportMacros = function (arg) {
  arg = arg.trim();
  var commands = {};
  if (!arg) commands = config.settings.macros;
  arg = arg.split(/\s+/);
  console.log(arg);
  for (var i in arg)
    if (arg[i] in config.settings.macros)
      commands[arg[i]] = config.settings.macros[arg[i]];
  ui.messageAddInfo('<code>' + JSON.stringify(commands) + '</code>');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant