Slack.pm 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package Cpanel::iContact::Provider::Schema::Slack;
  2. use strict;
  3. use warnings;
  4. # Name is always uc(MODULE)
  5. =encoding utf-8
  6. =head1 NAME
  7. Cpanel::iContact::Provider::Schema::Slack - Schema for the HipChat iContact module
  8. =head1 SYNOPSIS
  9. use Cpanel::iContact::Provider::Schema::Slack;
  10. my $settings = Cpanel::iContact::Provider::Schema::Slack::get_settings();
  11. my $config = Cpanel::iContact::Provider::Schema::Slack::get_config();
  12. =head1 DESCRIPTION
  13. Provide settings and configuration for the HipChat iContact module.
  14. =cut
  15. =head2 get_settings
  16. Provide config data for TweakSettings that will be saved in
  17. /etc/wwwacct.conf.shadow
  18. =over 2
  19. =item Input
  20. =over 3
  21. None
  22. =back
  23. =item Output
  24. =over 3
  25. A hashref that can be injected into Whostmgr::TweakSettings::Basic's %Conf
  26. with the additional help and label keys that are used in the display of the
  27. tweak settings.
  28. =back
  29. =back
  30. =cut
  31. sub get_settings {
  32. my $help = <<HALP;
  33. Slack Incoming Webhook URL(s): URL created for sending notifications to the destination(s) you configured for the cPanel & WHM Notifications app in Slack, separated by commas.
  34. <br />In order to create an incoming webhook for the channel(s)/user(s) you wish to notify, please go to 'Browse apps > Custom Integrations > Incoming WebHooks > New configuration'
  35. in Slack's 'App Directory' for your team.
  36. HALP
  37. my $help2 = <<HELP;
  38. Slack: Use concise notifications (Subject Only) -- If true, will discard the message body before send in order to make the message a bit more compact.
  39. In the future this may provide a link back to WHM in order to display the full notification.
  40. HELP
  41. return {
  42. 'CONTACTSLACK' => {
  43. 'name' => 'Slack',
  44. 'shadow' => 1,
  45. 'type' => 'text',
  46. 'checkval' => sub {
  47. my $value = shift();
  48. $value =~ s/^\s+|\s+$//g; # Trim
  49. return $value if $value eq q{};
  50. my @urls = split m{\s*,\s*}, $value;
  51. return join( ',', grep ( m{^https?://}, @urls ) );
  52. },
  53. 'label' => 'Slack Incoming Webhook URL(s)',
  54. 'help' => $help,
  55. },
  56. 'SLACKCOMPACT' => {
  57. 'type' => 'binary',
  58. 'label' => 'Slack: Use concise notifications (Subject Only)',
  59. 'help' => $help2,
  60. },
  61. };
  62. }
  63. =head2 get_config
  64. Provide configuration for the module.
  65. =over 2
  66. =item Input
  67. =over 3
  68. None
  69. =back
  70. =item Output
  71. =over 3
  72. A hash ref containing the following key values:
  73. default_level: The iContact default contact level (All)
  74. display_name: The name displayed on the Contact Manager page in WHM.
  75. =back
  76. =back
  77. =cut
  78. sub get_config {
  79. return {
  80. 'default_level' => 'All',
  81. 'display_name' => 'Slack',
  82. 'icon' =>
  83. 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20id%3D%22Layer_1%22%20viewBox%3D%220%200%20121.94154%20121.84154%22%20width%3D%22121.942%22%20height%3D%22121.842%22%3E%3Cstyle%20id%3D%22style3%22%3E.st0%7Bfill%3A%23ECB32D%3B%7D%20.st1%7Bfill%3A%2363C1A0%3B%7D%20.st2%7Bfill%3A%23E01A59%3B%7D%20.st3%7Bfill%3A%23331433%3B%7D%20.st4%7Bfill%3A%23D62027%3B%7D%20.st5%7Bfill%3A%2389D3DF%3B%7D%20.st6%7Bfill%3A%23258B74%3B%7D%20.st7%7Bfill%3A%23819C3C%3B%7D%3C%2Fstyle%3E%3Cg%20id%3D%22g5%22%3E%3Cg%20id%3D%22g7%22%3E%3Cpath%20class%3D%22st0%22%20d%3D%22M79.03%207.51c-1.9-5.7-8-8.8-13.7-7-5.7%201.9-8.8%208-7%2013.7l28.1%2086.4c1.9%205.3%207.7%208.3%2013.2%206.7%205.8-1.7%209.3-7.8%207.4-13.4%200-.2-28-86.4-28-86.4z%22%20id%3D%22path9%22%20fill%3D%22%23ecb32d%22%2F%3E%3Cpath%20class%3D%22st1%22%20d%3D%22M35.53%2021.61c-1.9-5.7-8-8.8-13.7-7-5.7%201.9-8.8%208-7%2013.7l28.1%2086.4c1.9%205.3%207.7%208.3%2013.2%206.7%205.8-1.7%209.3-7.8%207.4-13.4%200-.2-28-86.4-28-86.4z%22%20id%3D%22path11%22%20fill%3D%22%2363c1a0%22%2F%3E%3Cpath%20class%3D%22st2%22%20d%3D%22M114.43%2079.01c5.7-1.9%208.8-8%207-13.7-1.9-5.7-8-8.8-13.7-7l-86.5%2028.2c-5.3%201.9-8.3%207.7-6.7%2013.2%201.7%205.8%207.8%209.3%2013.4%207.4.2%200%2086.5-28.1%2086.5-28.1z%22%20id%3D%22path13%22%20fill%3D%22%23e01a59%22%2F%3E%3Cpath%20class%3D%22st3%22%20d%3D%22M39.23%20103.51c5.6-1.8%2012.9-4.2%2020.7-6.7-1.8-5.6-4.2-12.9-6.7-20.7l-20.7%206.7%206.7%2020.7z%22%20id%3D%22path15%22%20fill%3D%22%23331433%22%2F%3E%3Cpath%20class%3D%22st4%22%20d%3D%22M82.83%2089.31c7.8-2.5%2015.1-4.9%2020.7-6.7-1.8-5.6-4.2-12.9-6.7-20.7l-20.7%206.7%206.7%2020.7z%22%20id%3D%22path17%22%20fill%3D%22%23d62027%22%2F%3E%3Cpath%20class%3D%22st5%22%20d%3D%22M100.23%2035.51c5.7-1.9%208.8-8%207-13.7-1.9-5.7-8-8.8-13.7-7l-86.4%2028.1c-5.3%201.9-8.3%207.7-6.7%2013.2%201.7%205.8%207.8%209.3%2013.4%207.4.2%200%2086.4-28%2086.4-28z%22%20id%3D%22path19%22%20fill%3D%22%2389d3df%22%2F%3E%3Cpath%20class%3D%22st6%22%20d%3D%22M25.13%2059.91c5.6-1.8%2012.9-4.2%2020.7-6.7-2.5-7.8-4.9-15.1-6.7-20.7l-20.7%206.7%206.7%2020.7z%22%20id%3D%22path21%22%20fill%3D%22%23258b74%22%2F%3E%3Cpath%20class%3D%22st7%22%20d%3D%22M68.63%2045.81c7.8-2.5%2015.1-4.9%2020.7-6.7-2.5-7.8-4.9-15.1-6.7-20.7l-20.7%206.7%206.7%2020.7z%22%20id%3D%22path23%22%20fill%3D%22%23819c3c%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E'
  84. };
  85. }
  86. 1;