Discord.pm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package Cpanel::iContact::Provider::Schema::Discord;
  2. use strict;
  3. use warnings;
  4. # Name is always uc(MODULE)
  5. =encoding utf-8
  6. =head1 NAME
  7. Cpanel::iContact::Provider::Schema::Discord - Schema for the HipChat iContact module
  8. =head1 SYNOPSIS
  9. use Cpanel::iContact::Provider::Schema::Discord;
  10. my $settings = Cpanel::iContact::Provider::Schema::Discord::get_settings();
  11. my $config = Cpanel::iContact::Provider::Schema::Discord::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. Discord Incoming Webhook URL(s): URL created for sending notifications to the destination(s) you configured for the cPanel & WHM Notifications app in Discord, 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 'Edit Channel > Incoming WebHooks' and add one.
  35. in Discord's 'App Directory' for your team.
  36. HALP
  37. return {
  38. 'CONTACTDISCORD' => {
  39. 'name' => 'Discord',
  40. 'shadow' => 1,
  41. 'type' => 'text',
  42. 'checkval' => sub {
  43. my $value = shift();
  44. $value =~ s/^\s+|\s+$//g; # Trim
  45. return $value if $value eq q{};
  46. my @urls = split m{\s*,\s*}, $value;
  47. return join( ',', grep ( m{^https?://}, @urls ) );
  48. },
  49. 'label' => 'Discord Incoming Webhook URL(s)',
  50. 'help' => $help,
  51. }
  52. };
  53. }
  54. =head2 get_config
  55. Provide configuration for the module.
  56. =over 2
  57. =item Input
  58. =over 3
  59. None
  60. =back
  61. =item Output
  62. =over 3
  63. A hash ref containing the following key values:
  64. default_level: The iContact default contact level (All)
  65. display_name: The name displayed on the Contact Manager page in WHM.
  66. =back
  67. =back
  68. =cut
  69. sub get_config {
  70. return {
  71. 'default_level' => 'All',
  72. 'display_name' => 'Discord',
  73. 'icon' =>
  74. 'data:image/svg+xml,%3Csvg%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20245%20240%22%3E%3Cstyle%3E.st0%7Bfill%3A%237289DA%3B%7D%3C%2Fstyle%3E%3Cpath%20class%3D%22st0%22%20d%3D%22M104.4%20103.9c-5.7%200-10.2%205-10.2%2011.1s4.6%2011.1%2010.2%2011.1c5.7%200%2010.2-5%2010.2-11.1.1-6.1-4.5-11.1-10.2-11.1zM140.9%20103.9c-5.7%200-10.2%205-10.2%2011.1s4.6%2011.1%2010.2%2011.1c5.7%200%2010.2-5%2010.2-11.1s-4.5-11.1-10.2-11.1z%22%2F%3E%3Cpath%20class%3D%22st0%22%20d%3D%22M189.5%2020h-134C44.2%2020%2035%2029.2%2035%2040.6v135.2c0%2011.4%209.2%2020.6%2020.5%2020.6h113.4l-5.3-18.5%2012.8%2011.9%2012.1%2011.2%2021.5%2019V40.6c0-11.4-9.2-20.6-20.5-20.6zm-38.6%20130.6s-3.6-4.3-6.6-8.1c13.1-3.7%2018.1-11.9%2018.1-11.9-4.1%202.7-8%204.6-11.5%205.9-5%202.1-9.8%203.5-14.5%204.3-9.6%201.8-18.4%201.3-25.9-.1-5.7-1.1-10.6-2.7-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.3-1.8-1-2.8-1.7-2.8-1.7s4.8%208%2017.5%2011.8c-3%203.8-6.7%208.3-6.7%208.3-22.1-.7-30.5-15.2-30.5-15.2%200-32.2%2014.4-58.3%2014.4-58.3%2014.4-10.8%2028.1-10.5%2028.1-10.5l1%201.2c-18%205.2-26.3%2013.1-26.3%2013.1s2.2-1.2%205.9-2.9c10.7-4.7%2019.2-6%2022.7-6.3.6-.1%201.1-.2%201.7-.2%206.1-.8%2013-1%2020.2-.2%209.5%201.1%2019.7%203.9%2030.1%209.6%200%200-7.9-7.5-24.9-12.7l1.4-1.6s13.7-.3%2028.1%2010.5c0%200%2014.4%2026.1%2014.4%2058.3%200%200-8.5%2014.5-30.6%2015.2z%22%2F%3E%3C%2Fsvg%3E'
  75. };
  76. }
  77. 1;