boppers 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 77306f9f179e0f4e7fe5cc73db627c7029b3dcf4
4
- data.tar.gz: 86ec66cb44941b313083fc0c1049fb24b8d12261
2
+ SHA256:
3
+ metadata.gz: 3b39066d054834c66ba916b57228d1239a2cc4915b26f4d89d6d10c725ab9e8d
4
+ data.tar.gz: ade59801762cdd4c474a630c7875577b2ccba8811bc7e4f7b029398323a03a51
5
5
  SHA512:
6
- metadata.gz: 628e66d5e17e3161de9178b30e9ea554b9499ccd35789f3c80f2c26a919f89e97875b24371b3ebd2d44a1287aefc7bb37e8cce8c316e72a4261cb6071f25c503
7
- data.tar.gz: 567b790974604ffaaeb7ec2735db15765b537790368ff9739d8ef031a69d0769f5bf2a4255f53bd85d37d7f4e9d45ae7627626908473ce8d28d0fd23c51f7587
6
+ metadata.gz: 7b8987fb52a03b5d5e3c61e6966f0c5eb6ca273d7da43cba81d16188059b07768c9cda5d74478cb36dded7216ac257c02dffec12cc2d7b1ccd9d90ddeb31f0be
7
+ data.tar.gz: ec1b3109599004b3363c0da994eb0372809bf3d7f2429e8dc134861f82fc46b86a515c7fe3bab41e5380fba2d9f612dd17f725ecb3283804a093acf28c3bd6ae
data/README.md CHANGED
@@ -237,6 +237,8 @@ Boppers.configure do |config|
237
237
  end
238
238
  ```
239
239
 
240
+ You can run `boppers setup telegram`, which will basically guide like those steps above. No tokens will be saved locally or remotely in any form.
241
+
240
242
  #### Twitter
241
243
 
242
244
  1. Create an user for your bot.
@@ -63,5 +63,20 @@ module Boppers
63
63
  generator.destination_root = base_path
64
64
  generator.invoke_all
65
65
  end
66
+
67
+ desc "setup NAME", "Discover how to set up notifiers."
68
+
69
+ def setup(name)
70
+ file = File.expand_path("../../setup/#{name}.rb", __dir__)
71
+
72
+ unless File.file?(file)
73
+ message = "ERROR: invalid setup name."
74
+ shell.error shell.set_color(message, :red)
75
+ exit 1
76
+ end
77
+
78
+ require file
79
+ Setup.call(shell)
80
+ end
66
81
  end
67
82
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Boppers
4
- VERSION = "0.0.9"
4
+ VERSION = "0.0.10"
5
5
  end
@@ -1,20 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "aitch"
4
-
5
- $stdout << "What's your Telegram bot token? "
6
- bot_token = gets.chomp
7
-
8
- response = Aitch.get("https://api.telegram.org/bot#{bot_token}/getUpdates")
9
- payload = response
10
- .data["result"]
11
- .sort_by {|result| result["update_id"] }
12
- .last
13
-
14
- if payload
15
- channel_id = payload.dig("message", "chat", "id")
16
- puts "The channel id is #{channel_id}"
17
- else
18
- puts "No messages found."
19
- exit 1
3
+ module Setup
4
+ def self.call(shell)
5
+ require "aitch"
6
+
7
+ $stdout << "== Configuring a Telegram notifier\n\n"
8
+ $stdout << "1. Create a new bot. Visit https://telegram.me/botfather.\n"
9
+ $stdout << "2. Send a message to your bot.\n\n"
10
+ $stdout << "Hit ENTER to continue..."
11
+
12
+ $stdin.gets
13
+
14
+ $stdout << "\n"
15
+
16
+ $stdout << "What's your Telegram bot token? "
17
+ bot_token = $stdin.gets.chomp
18
+
19
+ response = Aitch.get("https://api.telegram.org/bot#{bot_token}/getUpdates")
20
+
21
+ unless response.ok?
22
+ message = "ERROR: Invalid bot token"
23
+ shell.error shell.set_color(message, :red)
24
+ exit 1
25
+ end
26
+
27
+ payload = response
28
+ .data["result"]
29
+ .sort_by {|result| result["update_id"] }
30
+ .last
31
+
32
+ unless payload
33
+ message = "ERROR: No messages found."
34
+ shell.error shell.set_color(message, :red)
35
+ exit 1
36
+ end
37
+
38
+ channel_id = payload.dig("message", "chat", "id")
39
+ message = "SUCCESS: The channel id is #{channel_id}"
40
+ shell.say shell.set_color(message, :green)
41
+ end
20
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boppers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  requirements: []
243
243
  rubyforge_project:
244
- rubygems_version: 2.6.13
244
+ rubygems_version: 2.7.3
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: A simple bot framework for individuals.