-
Notifications
You must be signed in to change notification settings - Fork 12
/
init.rb
50 lines (40 loc) · 1.58 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
log_dir = Rails.root.join('log/redmine_bots')
tmp_dir = Rails.root.join('tmp/redmine_bots')
FileUtils.mkdir_p(log_dir) unless Dir.exist?(log_dir)
FileUtils.mkdir_p(tmp_dir) unless Dir.exist?(tmp_dir)
require 'telegram/bot'
register_after_redmine_initialize_proc =
if Redmine::VERSION::MAJOR >= 5
Rails.application.config.public_method(:after_initialize)
else
reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
reloader.public_method(:to_prepare)
end
register_after_redmine_initialize_proc.call do
paths = '/lib/redmine_bots/telegram/{patches/*_patch,hooks/*_hook}.rb'
Dir.glob(File.dirname(__FILE__) + paths).each do |file|
require_dependency file
end
end
Rails.application.config.eager_load_paths += Dir.glob("#{Rails.application.config.root}/plugins/redmine_bots/{lib,app/workers,app/models,app/controllers,lib/redmine_bots/telegram/{patches/*_patch,hooks/*_hook}}")
Sidekiq::Logging.logger = Logger.new(Rails.root.join('log', 'sidekiq.log'))
Redmine::Plugin.register :redmine_bots do
name 'Redmine Bots'
url 'https://github.com/southbridgeio/redmine_bots'
description 'This is a platform for building Redmine bots'
version '0.5.2'
author 'Southbridge'
author_url 'https://github.com/southbridgeio'
settings(
default: {
'slack_oauth_token' => '',
'slack_bot_oauth_token' => '',
'slack_client_id' => '',
'slack_client_secret' => '',
'slack_verification_token' => '',
},
partial: 'settings/redmine_bots'
)
permission :view_telegram_account_info, {}
end
RedmineBots::Telegram.init