Coder Social home page Coder Social logo

redmine_telegram_email's Introduction

Telegram messages plugin for Redmine

For Russian speakers README.RUS.md

Plugin updated to redmine 4.1, need some tests, if you have troubles please create issue

This plugin send messages as email, only to the Telegram. So you can disable email and use Telegram only, or use both.

Installation

From your Redmine plugins directory, clone this repository as redmine_telegram_email (note the underscore!):

git clone https://github.com/aekondratiev/redmine_telegram_email redmine_telegram_email

You will also need the httpclient dependency, which can be installed by running

bundle install

from the plugin directory.

Start migration command

bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Restart Redmine, and you should see the plugin show up in the Plugins page.

Using

Set bot token into settings

First of all go into http://example.com/settings/plugin/redmine_telegram_email and set some settings, important is Telegram BOT Token

Custom field

Creating custom fields

Create two user custom fields: http://example.com/custom_fields/new?utf8=✓&type=UserCustomField named Telegram Channel (text) and Telegram disable email (boolean, default no, checkboxes). FIELDS NAMES ARE CASE SENSITIVE

Custom field

Custom field

The channel can be entered per user settings http://example.com/my/account for every user who wants to get notifications, in Telegram Channel field, for ex: 11111111 (not phone number, but chat id).

To disable email and use only Telegram - check Telegram disable email

And you can control Telegram messages by Email notifications dropdown.

Custom field

To get Telegram Channel id you must create bot with BotFather, then get bot token and run bot.py from this folder, send any symbols to bot and it return your Telegram Channel id.

Update plugin

Go to plugin girectory and pull last version

git pull origin master

Then start migration database to new version

bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Last step - restart Redmine.

Now you can use last version.

Uninstall

From Redmine plugin directory run command

bundle exec rake redmine:plugins:migrate NAME=redmine_telegram_email VERSION=0 RAILS_ENV=production

After that restart Redmine.

For more information, see http://www.redmine.org/projects/redmine/wiki/Plugins.

redmine_telegram_email's People

Contributors

aekondratiev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

redmine_telegram_email's Issues

Disable notification

Telegram has a option in their api to disable the notification sound. In other words: the message appears in the chat history but not on the welcome screen and didn't make a sound. That's great for logging purposes.
The option is quite simple: disable_notification=true must be added to the post data.

In my opinion it would be great if users could select to disable the notification, or even better if they could select it depending on the priority. Something like if priority < 3 disable sound.

Good idea?

not work

Есть ли возможность заставить данный плагин (redmine_telegram_email) работать через socks5 прокси? В связи с блокировками telegram доступ в данный момент на api.telegram.org отсутствует.

notification not sent

Hi,

I'm trying the plugin by a docker-redmine but without success.
Trying the plugin I got the log:

TELEGRAM EMAIL TOKEN EMPTY, PLEASE SET IT IN PLUGIN SETTINGS
telegram_url https://api.telegram.org/bot/sendMessage
SPEAK TO TELEGRAM ...

But in the settings the token is not empty. Why?

telegram.ext.dispatcher - ERROR - An uncaught error was raised while handling the error.

Добрый день! Подскажите, в чём может быть проблема? Как я понимаю, в новых версиях телеграм бота изменили синтаксис или вообще что-то убрали, но.. в общем, прошу помощи, как заставить это работать :)

root@avp-redmine:/opt/redmine/plugins/redmine_telegram_email# python3 bot.py
2022-03-01 12:31:59,570 - apscheduler.scheduler - INFO - Scheduler started
2022-03-01 12:49:39,150 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while handling the error.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/dispatcher.py", line 555, in process_update
handler.handle_update(update, self, check, context)
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/handler.py", line 198, in handle_update
return self.callback(update, context)
File "bot.py", line 30, in start
update.message.reply_text('Set this number ' + str(update.message.chat_id) + ' to your redmine account /my/account into Telegram Channel')
AttributeError: 'CallbackContext' object has no attribute 'message'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/dispatcher.py", line 567, in process_update
self.dispatch_error(update, exc)
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/dispatcher.py", line 810, in dispatch_error
callback(update, context)
TypeError: error() missing 1 required positional argument: 'error'

Environment:
Redmine version 4.2.3.stable
Ruby version 2.7.0-p0 (2019-12-25) [x86_64-linux-gnu]
Rails version 5.2.6
Environment production
Database adapter PostgreSQL
Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Mailer delivery smtp
SCM:
Git 2.25.1
Filesystem
Redmine plugins:
redmine_telegram_email 0.3
redmine_theme_changer 0.4.0

root@avp-redmine:/opt/redmine# python3 -m telegram
python-telegram-bot 13.11
Bot API 5.7
certifi 2019.11.28
Python 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]

Не работает.

Попытались установить плагин на Redmine в контейнере:
Environment:
Redmine version 4.2.0.stable
Ruby version 2.6.6-p146 (2020-03-31) [x86_64-linux-gnu]
Rails version 5.2.5
Environment production
Database adapter Mysql2
Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Mailer delivery smtp
SCM:
Subversion 1.13.0
Mercurial 5.3.1
Cvs 1.12.13
Bazaar 3.0.2
Git 2.31.1
Filesystem
Redmine plugins:
easy_gantt 1.12
easy_mindmup 1.0
easy_wbs 1.5
redmine_agile 1.6.0
redmine_checklists 3.1.18
redmine_omniauth_google 0.0.1

При вводе команды:
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
получаем ошибку:
Exception `ActiveSupport::EncryptedFile::MissingContentError' at /home/redmine/data/tmp/bundle/ruby/2.6.0/gems/activesupport-5.2.5/lib/active_support/encrypted_file.rb:44 - Missing encrypted content file in /home/redmine/redmine/config/credentials.yml.enc.

Однако после всего этого Redmine запускается и модуть видится. Вбиваем все настройки, добавляем поля. При создании новой задачи бот молчит. Кнопка "Отключить оповещение по email" тоже не работает.

Не могу запустить скрипт bot.py

При попытке запуска bot.py получаю ошибку

c:\redmine_telegram_email>python bot.py
Traceback (most recent call last):
  File "c:\redmine_telegram_email\bot.py", line 17, in <module>
    from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
ModuleNotFoundError: No module named 'telegram'

Support for Redmine 4.0

Hi there,

I was wondering if there's any plan of upgrading support for Redmine 4.0

There seems to be some changes on how Redmine 4 processes emails for once: http://www.redmine.org/issues/26791, unfortunately I don't know enough of Ruby/Rails to fix it...

Also there's the problem of the deprecation of alias_method_chain which could be solved with something like:

diff --git a/lib/telegram_mailer_patch.rb b/lib/telegram_mailer_patch.rb
index afd3275..b51553b 100644
--- a/lib/telegram_mailer_patch.rb
+++ b/lib/telegram_mailer_patch.rb
@@ -10,8 +10,10 @@ module TelegramMailerPatch
     base.send(:include, InstanceMethods)

     base.class_eval do
-      alias_method_chain :issue_add, :telegram
-      alias_method_chain :issue_edit, :telegram
+       alias_method :issue_add_without_telegram, :issue_add
+       alias_method :issue_add, :issue_add_with_telegram
+       alias_method :issue_edit_without_telegram, :issue_edit
+       alias_method :issue_edit, :issue_edit_with_telegram
     end
   end

With the above path applied Errors change to:

Processing by IssuesController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"***********", "form_update_triggered_by"=>"", "issue"=>{"is_private"=>"0", "project_id"=>"97", "author_id"=>"10", "tracker_id"=>"9", "subject"=>"asdvdfavs", "description"=>"sadfssac", "status_id"=>"1", "priority_id"=>"2", "assigned_to_id"=>"10", "parent_issue_id"=>"", "start_date"=>"2018-12-10", "due_date"=>"", "estimated_hours"=>"", "done_ratio"=>"0", "custom_field_values"=>{"8"=>"Desconocido"}, "tag_list"=>"", "notes"=>"fxv b", "private_notes"=>"0", "lock_version"=>"2"}, "was_default_status"=>"1", "time_entry"=>{"hours"=>"", "activity_id"=>"", "comments"=>""}, "last_journal_id"=>"3887", "commit"=>"Aceptar", "next_issue_id"=>"1047", "issue_position"=>"1", "issue_count"=>"4", "id"=>"1048"}
  Current user: fede (id=10)
[ActiveJob] [ActionMailer::DeliveryJob] [a8a3f83f-b656-4802-acc0-c7ed27803adf] Performing ActionMailer::DeliveryJob (Job ID: a8a3f83f-b656-4802-acc0-c7ed27803adf) from Async(mailers) with arguments: "Mailer", "issue_edit", "deliver_now", #<GlobalID:0x0000564344519db0 @uri=#<URI::GID gid://redmine-app/User/10>>, #<GlobalID:0x0000564344518fc8 @uri=#<URI::GID gid://redmine-app/Journal/3888>>
[ActiveJob] [ActionMailer::DeliveryJob] [a8a3f83f-b656-4802-acc0-c7ed27803adf] Error performing ActionMailer::DeliveryJob (Job ID: a8a3f83f-b656-4802-acc0-c7ed27803adf) from Async(mailers) in 83.34ms: NoMethodError (undefined method `journalized' for #<User:0x0000564344528d88>):
/var/lib/gems/2.5.0/gems/activemodel-5.2.2/lib/active_model/attribute_methods.rb:430:in `method_missing'
/home/redmine/redmine-4.0.0/plugins/redmine_telegram_email/lib/telegram_mailer_patch.rb:134:in `issue_edit_with_telegram'
/var/lib/gems/2.5.0/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:194:in `process_action'
/var/lib/gems/2.5.0/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'
/var/lib/gems/2.5.0/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:41:in `process_action'
/var/lib/gems/2.5.0/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:134:in `process'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/rescuable.rb:25:in `block in process'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/rescuable.rb:17:in `handle_exceptions'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/rescuable.rb:24:in `process'
/var/lib/gems/2.5.0/gems/actionview-5.2.2/lib/action_view/rendering.rb:32:in `process'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/base.rb:607:in `block in process'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `block in instrument'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `instrument'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/base.rb:606:in `process'
/home/redmine/redmine-4.0.0/app/models/mailer.rb:46:in `process'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/message_delivery.rb:123:in `block in processed_mailer'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/message_delivery.rb:122:in `tap'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/message_delivery.rb:122:in `processed_mailer'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/message_delivery.rb:113:in `deliver_now'
/var/lib/gems/2.5.0/gems/actionmailer-5.2.2/lib/action_mailer/delivery_job.rb:16:in `perform'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:39:in `block in perform_now'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/var/lib/gems/2.5.0/gems/i18n-0.7.0/lib/i18n.rb:257:in `with_locale'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/translation.rb:9:in `block (2 levels) in <module:Translation>'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `instance_exec'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:26:in `block (4 levels) in <module:Logging>'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `block in instrument'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `instrument'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:25:in `block (3 levels) in <module:Logging>'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:46:in `block in tag_logger'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `block in tagged'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:28:in `tagged'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `tagged'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:46:in `tag_logger'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:22:in `block (2 levels) in <module:Logging>'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `instance_exec'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:136:in `run_callbacks'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:38:in `perform_now'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:24:in `block in execute'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/railtie.rb:28:in `block (4 levels) in <class:Railtie>'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/execution_wrapper.rb:87:in `wrap'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/reloader.rb:73:in `block in wrap'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/execution_wrapper.rb:87:in `wrap'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/reloader.rb:72:in `wrap'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/railtie.rb:27:in `block (3 levels) in <class:Railtie>'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `instance_exec'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/lib/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:136:in `run_callbacks'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:22:in `execute'
/var/lib/gems/2.5.0/gems/activejob-5.2.2/lib/active_job/queue_adapters/async_adapter.rb:70:in `perform'
/var/lib/gems/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
/var/lib/gems/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
/var/lib/gems/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
/var/lib/gems/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
/var/lib/gems/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
/var/lib/gems/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: a8a3f83f-b656-4802-acc0-c7ed27803adf) to Async(mailers) with arguments: 
"Mailer", "issue_edit", "deliver_now", #<GlobalID:0x000056434453cb80 @uri=#<URI::GID gid://redmine-app/User/10>>, #<GlobalID:0x000056434453c018 @uri=#<URI::GID gid://redmine-app/Journal/3888>>

Regards

undefined local variable or method `token', `issue_add_with_telegram'

Completed 500 Internal Server Error in 301ms (ActiveRecord: 10.6ms)

NameError (undefined local variable or method `token' for #Mailer:0x002b24dba98cd0):
plugins/redmine_telegram_email/lib/telegram_mailer_patch.rb

        if telegram_chat_id != 0
          Mailer.speak(msg, telegram_chat_id, attachment, token)

        end

bundle exec rake redmine:plugins:migrate RAILS_ENV=production ERROR

Environment:
Redmine version 4.1.1.stable
Ruby version 2.5.8-p224 (2020-03-31) [x86_64-linux]
Rails version 5.2.4.2
Environment production
Database adapter Mysql2

Exception LoadError' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:291 - cannot load such file -- config/initializers/session_store.rb Exception LoadError' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:261 - cannot load such file -- config/initializers/session_store.rb
Exception Errno::EEXIST' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/2.5.0/fileutils.rb:232 - File exists @ dir_s_mkdir - /redmine/redmine-4.1.1-7/apps/redmine/htdocs/public/plugin_assets/custom_users_as_assignees/images Exception Errno::EEXIST' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/2.5.0/fileutils.rb:232 - File exists @ dir_s_mkdir - /redmine/redmine-4.1.1-7/apps/redmine/htdocs/public/plugin_assets/custom_users_as_assignees/images
Exception Errno::EEXIST' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/2.5.0/fileutils.rb:232 - File exists @ dir_s_mkdir - /redmine/redmine-4.1.1-7/apps/redmine/htdocs/public/plugin_assets/customfield_checkbox_utility/javascripts Exception Errno::EEXIST' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/2.5.0/fileutils.rb:232 - File exists @ dir_s_mkdir - /redmine/redmine-4.1.1-7/apps/redmine/htdocs/public/plugin_assets/customfield_checkbox_utility/javascripts
Exception `Errno::EEXIST' at /redmine/redmine-4.1.1-7/ruby/lib/ruby/2.5.0/fileutils.rb:232 - File exists @ dir_s_mkdir - /redmine/redmine-4.1.1-7/apps/redmine/htdocs/public/plugin_assets/customfield_checkbox_utility/stylesheets

Messages not sent

Hi,

I'd like to use this plugin. If I understand correctly updates to issues are sent to Telegram instead of mail wich would be great as I am a huge Telegram fan.
Weither or not I place a check on the disable mail checkbox the mail is sent, but not the telegram.
When I use the redmine_telegram_global plugin messages arrive, but I think this plugin could be better as users can set their own chat id.

Thanks in advance for your response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.