Rocket.Chat Canned Responses App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.7 KiB

5 years ago
  1. //
  2. // Copyright (c) 2019, Mr. Gecko's Media (James Coleman)
  3. // All rights reserved.
  4. //
  5. // Redistribution and use in source and binary forms, with or without modification,
  6. // are permitted provided that the following conditions are met:
  7. //
  8. // 1. Redistributions of source code must retain the above copyright notice, this
  9. // list of conditions and the following disclaimer.
  10. //
  11. // 2. Redistributions in binary form must reproduce the above copyright notice,
  12. // this list of conditions and the following disclaimer in the documentation
  13. // and/or other materials provided with the distribution.
  14. //
  15. // 3. Neither the name of the copyright holder nor the names of its contributors
  16. // may be used to endorse or promote products derived from this software without
  17. // specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  25. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. // POSSIBILITY OF SUCH DAMAGE.
  29. //
  30. import {
  31. IAppAccessors,
  32. IConfigurationExtend,
  33. IEnvironmentRead,
  34. ILogger,
  35. } from '@rocket.chat/apps-engine/definition/accessors';
  36. import { App } from '@rocket.chat/apps-engine/definition/App';
  37. import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
  38. import { SettingType } from '@rocket.chat/apps-engine/definition/settings';
  39. import { CannedResponsesSlashCommand } from './slashcommands';
  40. export class CannedResponsesApp extends App {
  41. constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
  42. super(info, logger, accessors);
  43. }
  44. public async extendConfiguration(configuration: IConfigurationExtend, environmentRead: IEnvironmentRead): Promise<void> {
  45. configuration.slashCommands.provideSlashCommand(new CannedResponsesSlashCommand(this));
  46. configuration.settings.provideSetting({
  47. id: 'canned_responses_api_url',
  48. type: SettingType.STRING,
  49. packageValue: '',
  50. required: true,
  51. public: false,
  52. i18nLabel: 'canned_responses_api_url',
  53. i18nDescription: 'canned_responses_api_url_description',
  54. });
  55. }
  56. }