Commit 1908a7ed authored by nazarf's avatar nazarf

add send miners status

parent eab742ef
......@@ -32,6 +32,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "httparty"
gem 'whenever', require: false
gem "google_drive"
gem 'telegram_bot', '~> 0.0.4'
group :development do
gem 'web-console', '~> 2.0'
......
......@@ -44,6 +44,10 @@ GEM
arel (6.0.4)
autoprefixer-rails (10.4.13.0)
execjs (~> 2)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bcrypt (3.1.18)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
......@@ -80,6 +84,8 @@ GEM
chronic (0.10.2)
ckeditor (5.1.1)
orm_adapter (~> 0.5.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
......@@ -92,6 +98,8 @@ GEM
crass (1.0.6)
debug_inspector (1.1.0)
declarative (0.0.20)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.9.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
......@@ -102,6 +110,7 @@ GEM
devise (>= 4.9.0)
digest (3.1.1)
erubis (2.7.0)
excon (0.100.0)
execjs (2.8.1)
faraday (1.10.3)
faraday-em_http (~> 1.0)
......@@ -176,6 +185,7 @@ GEM
httpclient (2.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
io-wait (0.3.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
......@@ -318,6 +328,9 @@ GEM
net-ssh (>= 2.8.0)
ssrf_filter (1.0.8)
strscan (3.0.6)
telegram_bot (0.0.8)
excon (>= 0.30.0)
virtus (>= 1.0.0)
temple (0.10.0)
thor (1.2.1)
thread_safe (0.3.6)
......@@ -337,6 +350,10 @@ GEM
uber (0.1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
virtus (2.0.0)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
warden (1.2.7)
rack (>= 1.0)
web-console (2.3.0)
......@@ -382,6 +399,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simple_form
telegram_bot (~> 0.0.4)
turbolinks
twitter-bootstrap-rails
tzinfo-data
......
......@@ -2,3 +2,4 @@ set :output, 'log/cron.log'
# every("*/5 * * * *", roles: [:app]) { rake "miners:check_miners" }
every("*/5 * * * *", roles: [:app]) { rake "miners:check_safex_active_miner" }
every("0 2 * * *", roles: [:app]) { rake "miners:miners_status_notification" }
\ No newline at end of file
......@@ -134,3 +134,29 @@ namespace :miners do
end
end
end
task miners_status_notification: :environment do
require 'logger'
require 'telegram_bot'
TELEGRAM_BOT_TOKEN = "5829604433:AAG5CeFBygU1lvV5oeeDyT_v0CqzjAWCNlY"
CHAT_ID = "-1001516309000"
bot = TelegramBot.new(token: TELEGRAM_BOT_TOKEN, logger: Logger.new(STDOUT))
channel = TelegramBot::Channel.new(id: CHAT_ID)
message = TelegramBot::OutMessage.new
message.chat = channel
miss_miner = Miner.where(status: Miner::STATUSES[0])
restart_miner = Miner.where(status: Miner::STATUSES[1])
active_miner = Miner.where(status: Miner::STATUSES[2])
message.text = "Date: #{DateTime.now.strftime("%d.%m.%Y %H:%M")}\n
Total: #{Miner.count}\n
Active: #{active_miner.count}\n
Restart: #{restart_miner.count}\n
Miss: #{miss_miner.count}\n
#{miss_miner.map(&:name).join(', ')}
"
message.send_with(bot)
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment