Telegram.pm 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package Cpanel::iContact::Provider::Schema::Telegram;
  2. use strict;
  3. use warnings;
  4. # Name is always uc(MODULE)
  5. =encoding utf-8
  6. =head1 NAME
  7. Cpanel::iContact::Provider::Schema::Telegram - Schema for the Telegram iContact module
  8. =head1 SYNOPSIS
  9. use Cpanel::iContact::Provider::Schema::Telegram;
  10. my $settings = Cpanel::iContact::Provider::Schema::Telegram::get_settings();
  11. my $config = Cpanel::iContact::Provider::Schema::Telegram::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. <strong>Telegram Bot Token:</strong><br>
  34. Token created for authenticating as the bot you created for sending cPanel & WHM Notifications to users in Telegram.
  35. <br>In order to create a token for your bot, please message the <a href="https://core.telegram.org/bots#6-botfather">BotFather</a> in Telegram and it will make one for you.
  36. HALP
  37. my $halp = <<HELP;
  38. <strong>Telegram Destinations:</strong><br>
  39. The group(s)/user(s) you wish your Telegram bot to notify, separated by comma.<br>
  40. Public chat rooms can be mentioned by their '\@' name, but individual users, groups or private chat rooms <i>must</i> be referenced by numeric ID.<br>
  41. Getting these numeric IDs can be a rather involved process, so I have created a video tutorial for doing so <a href="https://troglodyne.net">here</a>.<br><br>
  42. <i>Example</i>: \@bogusPublicChannel,123456789
  43. HELP
  44. return {
  45. 'CONTACTTELEGRAM' => {
  46. 'name' => 'Telegram Destinations',
  47. 'shadow' => 0,
  48. 'type' => 'text',
  49. 'checkval' => sub {
  50. my $value = shift();
  51. $value =~ s/^\s+|\s+$//g; # Trim
  52. return $value if $value eq q{};
  53. return $value;
  54. },
  55. 'label' => 'Telegram Destinations',
  56. 'help' => $halp,
  57. },
  58. 'TELEGRAMBOTTOKEN' => {
  59. 'name' => 'Telegram Bot Token',
  60. 'label' => 'Telegram Bot Token',
  61. 'help' => $help,
  62. 'shadow' => 1,
  63. 'type' => 'password',
  64. 'checkval' => sub {
  65. my $value = shift();
  66. $value =~ s/^\s+|\s+$//g; # Trim
  67. return $value if $value eq q{};
  68. return $value;
  69. },
  70. },
  71. };
  72. }
  73. =head2 get_config
  74. Provide configuration for the module.
  75. =over 2
  76. =item Input
  77. =over 3
  78. None
  79. =back
  80. =item Output
  81. =over 3
  82. A hash ref containing the following key values:
  83. default_level: The iContact default contact level (All)
  84. display_name: The name displayed on the Contact Manager page in WHM.
  85. =back
  86. =back
  87. =cut
  88. sub get_config {
  89. return {
  90. 'default_level' => 'All',
  91. 'display_name' => 'Telegram',
  92. 'icon' =>
  93. 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22620%22%20height%3D%22620%22%20viewBox%3D%220%200%20620%20620%22%3E%3ClinearGradient%20id%3D%22a%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%22311.167%22%20y1%3D%22603.333%22%20x2%3D%22311.167%22%20y2%3D%2219%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%231D93D2%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%2338B0E3%22%2F%3E%3C%2FlinearGradient%3E%3Ccircle%20fill%3D%22url%28%23a%29%22%20stroke%3D%22%23FFF%22%20stroke-width%3D%2228%22%20stroke-miterlimit%3D%2210%22%20cx%3D%22311.167%22%20cy%3D%22311.167%22%20r%3D%22292.167%22%2F%3E%3Cpath%20fill%3D%22%23C8DAEA%22%20d%3D%22M220.76%20338.848l35.362%2097.88s4.42%209.157%209.157%209.157%2075.146-73.252%2075.146-73.252l78.304-151.24-196.707%2092.197-1.264%2025.258z%22%2F%3E%3Cpath%20fill%3D%22%23A9C6D8%22%20d%3D%22M267.646%20363.95l-6.788%2072.146s-2.842%2022.102%2019.26%200%2043.257-39.152%2043.257-39.152%22%2F%3E%3Cpath%20fill%3D%22%23FFF%22%20d%3D%22M221.398%20342.34l-72.734-23.7s-8.683-3.526-5.894-11.525c.575-1.65%201.736-3.052%205.21-5.473%2016.12-11.234%20298.324-112.667%20298.324-112.667s7.97-2.683%2012.677-.898c2.153.816%203.527%201.737%204.685%205.104.42%201.226.663%203.83.63%206.42-.022%201.87-.252%203.6-.42%206.316-1.72%2027.732-53.145%20234.705-53.145%20234.705s-3.076%2012.113-14.103%2012.525c-4.02.15-8.9-.664-14.734-5.683-21.635-18.612-96.42-68.87-112.944-79.924-.93-.622-1.198-1.433-1.355-2.222-.233-1.165%201.034-2.61%201.034-2.61s130.217-115.75%20133.68-127.895c.268-.94-.74-1.405-2.105-1-8.65%203.183-158.58%2097.858-175.126%20108.313-.968.61-3.682.217-3.682.217z%22%2F%3E%3C%2Fsvg%3E',
  94. };
  95. }
  96. 1;