mutx 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 118764c1c60f49248a4f6ddb167572d54ff1eb7f
4
- data.tar.gz: a94480b460dea0f8ba2a36b848f7c9d453ca4b71
3
+ metadata.gz: f41948713cc0c2ab88b659a0acfccef31685804f
4
+ data.tar.gz: 866f09627bb94a865d037880282c1f76128df502
5
5
  SHA512:
6
- metadata.gz: 5663219979ab0e0db8b490ab697b7307d6735ac8f2fa959859cdd8eed71fcc766ee365ce1fd78de6c0050b4bba70e27466db13e0799d79f79b122caee00f8762
7
- data.tar.gz: cbe7581c528c9d7be6620e1d6bee23eca47a3196656e7295e55ef144ca03189e1282cfcf2201dbec799ecf2aa787352e6d00253dae17bfb2e3fae14174ac5519
6
+ metadata.gz: e58c8804ca6e125362a4005b59a78f83e9d4e1a5b2ce66da2911ebbae23ee3b7e1241081fa7cf40c3f5e5a4f660b1c47d07916afb0fde9a07dcf90bfeaaa4cbd
7
+ data.tar.gz: 8b556913a4cf8e004a6578fe75c461d24f312952904ac360dbf91027c7d2acf1d11c388744af51aabb83f9a3f30c63d0c8479f36b91e683ead1e6aa210eaa0fd
@@ -46,7 +46,8 @@
46
46
  "password" : null,
47
47
  "recipients" : "your@email.com",
48
48
  "smtp_enable_start_tls_auto" : true,
49
- "attach_report" : false
49
+ "attach_report" : false,
50
+ "telegram_token" => null
50
51
  },
51
52
 
52
53
  "footer_text" : "The text to display on footer",
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'telegramsender'
3
-
4
2
  module Mutx
5
3
  module Workers
6
4
  class Notificator
@@ -12,7 +10,7 @@ module Mutx
12
10
  end
13
11
 
14
12
  def telegram(group_id, message: '')
15
- TelegramSender.send_message(group_id, message)
13
+ Support::TelegramSender.send_message(group_id, message)
16
14
  end
17
15
 
18
16
  def email(mail_to, subject: '', body: '', attachment: nil)
data/lib/mutx/routes.rb CHANGED
@@ -52,7 +52,10 @@ module Mutx
52
52
  on "pull" do
53
53
  #Check for updates on the branch and make a pull if its outdated
54
54
  ##Mutx::Support::Git.pull unless Mutx::Support::Git.up_to_date?
55
- Mutx::Support::Bundle.new.bundle_update if Mutx::Support::ChangeInspector.is_there_a_change?
55
+ data_json = JSON.parse req.body.read
56
+ Mutx::Support::ChangeInspector.is_there_a_change?
57
+ Mutx::Support::Log.debug "#{data_json}" if Mutx::Support::Log
58
+ Mutx::Support::Bundle.new.bundle_update if data_json["repository"]["language"].eql? "Ruby"
56
59
  res.status = 200
57
60
  res.write "status 200"
58
61
  end
@@ -26,6 +26,7 @@ module Mutx
26
26
  =end
27
27
  def bundle_update
28
28
  Mutx::Support::Console.execute "bundle update"
29
+ Mutx::Support::Log.debug "BUNDLE UPDATE MADE VIA WEBHOOK" if Mutx::Support::Log
29
30
  end# bundle_update
30
31
 
31
32
  end
@@ -168,6 +168,10 @@ module Mutx
168
168
  @@input['notification']['smtp_enable_start_tls_auto']
169
169
  end
170
170
 
171
+ def self.telegram_token
172
+ @@input['notification']['telegram_token']
173
+ end
174
+
171
175
  def self.notification?
172
176
  self.notification_username and self.notification_password and self.use_gmail?
173
177
  end
@@ -0,0 +1,40 @@
1
+ require 'telegram/bot'
2
+
3
+ module Mutx
4
+ module Support
5
+ class TelegramSender
6
+
7
+ def initialize token=nil, chat_id
8
+ @token = token || Configuration.telegram_token
9
+ @chat_id = chat_id
10
+ end
11
+
12
+ # Send a message to the given group
13
+ # @param [Fixnum] chat_id = the id of the telegram group
14
+ # @param [String] message = the message to be sent
15
+ # @param [String] type of message [Markdown, HTML]
16
+ def send_message message
17
+ Telegram::Bot::Client.run(@token) do |bot|
18
+ bot.api.send_message(chat_id: @chat_id, text: message)
19
+ end
20
+ end
21
+
22
+ # Send a message to the given group
23
+ # @param [Fixnum] chat_id = the id of the telegram group
24
+ # @param [String] message = the message to be sent
25
+ # @param [String] type of message [Markdown, HTML]
26
+ def self.send_message chat_id, message, parse_mode=nil
27
+ Telegram::Bot::Client.run(Configuration.telegram_token) do |bot|
28
+ bot.api.send_message(chat_id: chat_id, text: message, parse_mode:parse_mode)
29
+ end
30
+ end
31
+
32
+ def self.run_client
33
+ Telegram::Bot::Client.run(Configuration.telegram_token) do |bot|
34
+ yield bot
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
data/lib/mutx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mutx
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Rodriguez
@@ -514,6 +514,7 @@ files:
514
514
  - lib/mutx/support/query_string.rb
515
515
  - lib/mutx/support/request.rb
516
516
  - lib/mutx/support/risk.rb
517
+ - lib/mutx/support/telegram_sender.rb
517
518
  - lib/mutx/support/time_helper.rb
518
519
  - lib/mutx/support/update.rb
519
520
  - lib/mutx/tasks/.DS_Store