forked from southbridgeio/redmine_telegram_common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
50 lines (39 loc) · 1.61 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/telegram_common')
FileUtils.mkdir_p(log_dir) unless Dir.exist?(log_dir)
require 'telegram/bot'
# Rails 5.1/Rails 4
reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
reloader.to_prepare do
require_dependency 'telegram_common'
paths = '/lib/telegram_common/{patches/*_patch,hooks/*_hook}.rb'
Dir.glob(File.dirname(__FILE__) + paths).each do |file|
require_dependency file
end
Faraday::Adapter.register_middleware redmine_telegram_common: TelegramCommon::Bot::FaradayAdapter
Telegram::Bot.configure do |config|
config.adapter = :redmine_telegram_common
end
end
Rails.application.config.eager_load_paths += Dir.glob("#{Rails.application.config.root}/plugins/redmine_telegram_common/{lib,app/workers,app/models,app/controllers}")
Sidekiq::Logging.logger = Logger.new(Rails.root.join('log', 'sidekiq.log'))
Sidekiq::Cron::Job.create(name: 'Update telegram accounts info',
cron: '0 2 * * *',
class: 'TelegramAccountsRefreshWorker')
Redmine::Plugin.register :redmine_telegram_common do
name 'Redmine Telegram Common plugin'
description 'This is a plugin for other Redmine Telegram plugins'
version '0.7.2'
url 'https://github.com/centosadmin/redmine_telegram_common'
author 'Southbridge'
author_url 'https://github.com/centosadmin'
settings(default: {
'phone_number' => '',
'api_id' => '',
'api_hash' => '',
'bot_token' => '',
'bot_name' => '',
'bot_id' => '',
'robot_id' => ''
},
partial: 'settings/telegram_common')
end