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 +5 -5
- data/README.md +2 -0
- data/lib/boppers/cli.rb +15 -0
- data/lib/boppers/version.rb +1 -1
- data/setup/telegram.rb +39 -17
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3b39066d054834c66ba916b57228d1239a2cc4915b26f4d89d6d10c725ab9e8d
|
4
|
+
data.tar.gz: ade59801762cdd4c474a630c7875577b2ccba8811bc7e4f7b029398323a03a51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/boppers/cli.rb
CHANGED
@@ -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
|
data/lib/boppers/version.rb
CHANGED
data/setup/telegram.rb
CHANGED
@@ -1,20 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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.
|
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:
|
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.
|
244
|
+
rubygems_version: 2.7.3
|
245
245
|
signing_key:
|
246
246
|
specification_version: 4
|
247
247
|
summary: A simple bot framework for individuals.
|