IRC.pm 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package Cpanel::iContact::Provider::Schema::IRC;
  2. use strict;
  3. use warnings;
  4. sub get_settings {
  5. my $help1 = <<HALP;
  6. <p>The IRC <em>channel</em> you wish to send cPanel & WHM notifications <em>to</em>.<br />
  7. Multiple channels currently are not supported.<br />
  8. Example: "#YOLO"</p>
  9. HALP
  10. my $help2 = <<HALP;
  11. <p>The IRC <em>nickname</em> you wish for cPanel & WHM notifications to use.<br />
  12. Example: "cPSaurus"</p>
  13. HALP
  14. my $help3 =<<HALP;
  15. <p>Whether or not the IRC server your Notification User is registered at supports SSL/TLS.<br />
  16. If set improperly, this will cause sending notifications to fail (some IRC servers <em>require</em> SSL/TLS, some <em>don't support it</em>).
  17. </p>
  18. HALP
  19. my $help4 =<<HALP;
  20. <p>The IRC Server Address<br />
  21. The domain or IP your IRC server is active on.
  22. </p>
  23. HALP
  24. my $help5 =<<HALP;
  25. <p>The IRC Server Port<br />
  26. The port your IRC server is active on. Defaults to 6667.
  27. </p>
  28. HALP
  29. return {
  30. 'CONTACTIRC' => {
  31. 'shadow' => 1,
  32. 'type' => 'text',
  33. 'checkval' => sub {
  34. my $value = shift;
  35. my @chans = split( ",", $value );
  36. @chans = grep { index( $_, '#' ) != -1 } @chans;
  37. return join( ",", @chans );
  38. },
  39. 'label' => 'IRC Notification Destinations',
  40. 'help' => $help1,
  41. },
  42. 'IRCNICK' => {
  43. 'shadow' => 1,
  44. 'type' => 'text',
  45. 'checkval' => sub {
  46. my $value = shift();
  47. $value =~ s/^\s+|\s+$//g; # Trim
  48. # TODO get full list of "invalid characters". RFC doesn't specify.
  49. die "IRC nicknames can't contain spaces!" if index( $value, " ") != -1;
  50. return $value;
  51. },
  52. 'label' => 'IRC Notification Bot Nickname',
  53. 'help' => $help2,
  54. },
  55. 'IRCUSESSL' => {
  56. 'type' => 'binary',
  57. 'label' => 'IRC: Use SSL/TLS?',
  58. 'help' => $help3,
  59. },
  60. 'IRCSERVER' => {
  61. 'type' => 'text',
  62. 'label' => 'IRC Server Address',
  63. 'help' => $help4,
  64. },
  65. 'IRCPORT' => {
  66. 'type' => 'text',
  67. 'label' => 'IRC Server Port',
  68. 'help' => $help5,
  69. },
  70. };
  71. }
  72. sub get_config {
  73. my $svg = "%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2048%2048%22%3E%3Cdefs%3E%3ClinearGradient%20gradientUnits%3D%22userSpaceOnUse%22%20x2%3D%2247%22%20x1%3D%220%22%3E%3Cstop%20stop-color%3D%22%23a9a3d4%22%2F%3E%3Cstop%20offset%3D%22.47%22%20stop-color%3D%22%2387baff%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%2389ec85%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%220%22%20y1%3D%22556.24%22%20x2%3D%220%22%20y2%3D%22510.24%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%232e5378%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23387898%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%22421.9%22%20y1%3D%22540.44%22%20x2%3D%22422.52%22%20y2%3D%22522.5%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%231584d8%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%231cb2ff%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cg%20transform%3D%22matrix%281.04866%200%200%201.04866-511.61-528.36%29%22%20stroke-width%3D%221.317%22%3E%3Crect%20y%3D%22510.24%22%20x%3D%22296.96%22%20height%3D%2246%22%20width%3D%2246%22%20fill%3D%22url%28%230%29%22%20rx%3D%2223%22%20stroke-width%3D%222.164%22%20transform%3D%22matrix%28.99507%200%200%20.99507%20192.37-3.883%29%22%2F%3E%3Cpath%20d%3D%22m423.44%20523.59l-1.172%204.7h3.223l1.184-4.7h2.698l-1.184%204.7h3.381v2.6h-4.03l-.842%203.345h3.467v2.625h-4.102l-1.172%204.675h-2.698l1.172-4.675h-3.223l-1.172%204.675h-2.722l1.172-4.675h-3.406v-2.625h4l.854-3.345h-3.455v-2.6h4.126l1.172-4.7h2.722m1.379%207.3h-3.223l-.854%203.345h3.223l.854-3.345%22%20fill%3D%22%23fff%22%20fill-opacity%3D%22.85%22%20transform%3D%22matrix%281.33747%200%200%201.33747-54.714-185.56%29%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E";
  74. return {
  75. 'default_level' => 'All',
  76. 'display_name' => 'IRC',
  77. 'icon_name' => 'IRC',
  78. 'icon' => "data:image/svg+xml,$svg",
  79. };
  80. }
  81. 1;