energy_air 2019.0 → 2019.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/README.md +7 -2
- data/Rakefile +5 -5
- data/energy_air.gemspec +13 -13
- data/exe/energy_air +9 -11
- data/lib/energy_air/bot.rb +27 -48
- data/lib/energy_air/questions.rb +34 -0
- data/lib/energy_air/version.rb +1 -1
- data/lib/energy_air.rb +2 -2
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e5df1f1d6c2d3c6249f21948772647adba4471002be9d1b60f2fa1533168ab6
|
4
|
+
data.tar.gz: 9aab2804d53e6ca085331c0744a56e53aa1b4beb94f53732876cb6f043dbd762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8532502b437ab91e128d628b97cec92ec19d422a7f320035f923882eed8d235f0769092ea7e50365094a958a9fc746b2e4ab3860e051a49448a0ef092673f9e7
|
7
|
+
data.tar.gz: 6447845a644dce2ff5ed1136ee39764592045afacb2bcc2508f58647f220978ac68ef57d808ee4cf63377fcd7eacf3561469724bc321d5209fcd2db2ded13c42
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
# EnergyAir
|
2
2
|
|
3
3
|
Tiny ruby bot to win [energy air](https://energy.ch/air) tickets.
|
4
|
+
Tested on OS X and windows.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
7
8
|
Install it:
|
8
|
-
(Make sure that you have
|
9
|
+
(Make sure that you have google chrome installed)
|
9
10
|
|
10
11
|
$ gem install energy_air
|
11
12
|
|
12
13
|
## Usage
|
13
14
|
|
14
|
-
$ energy_air <telephone_number>
|
15
|
+
$ energy_air <telephone_number> (e.g. 791234567)
|
16
|
+
|
17
|
+
You can also add `--visual` to have chrome popup and show what's going on (useful for debugging).
|
18
|
+
|
19
|
+
$ energy_air <telephone_number> --visual
|
15
20
|
|
16
21
|
## Contributing
|
17
22
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
7
|
t.test_files = FileList['test/**/*_test.rb']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :
|
10
|
+
task default: :test
|
data/energy_air.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
require_relative 'lib/energy_air/version'
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
4
|
+
spec.name = 'energy_air'
|
7
5
|
spec.version = EnergyAir::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
6
|
+
spec.authors = ['Yves Siegrist']
|
7
|
+
spec.email = ['Elektron1c97@gmail.com']
|
10
8
|
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
9
|
+
spec.summary = 'Automatically win energy air tickets without really playing.'
|
10
|
+
spec.homepage = 'https://github.com/siegy22/energy_air'
|
11
|
+
spec.license = 'MIT'
|
14
12
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
13
|
f.match(%r{^(test|spec|features)/})
|
16
14
|
end
|
17
|
-
spec.bindir =
|
15
|
+
spec.bindir = 'exe'
|
18
16
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
17
|
+
spec.require_paths = ['lib']
|
20
18
|
|
21
|
-
spec.add_dependency
|
19
|
+
spec.add_dependency 'capybara', '~> 3'
|
22
20
|
spec.add_dependency 'selenium-webdriver', '~> 3'
|
23
21
|
spec.add_dependency 'webdrivers', '~> 4'
|
24
22
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
24
|
+
spec.add_development_dependency 'minitest', '~> 5'
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.74'
|
27
27
|
end
|
data/exe/energy_air
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
3
|
-
|
4
2
|
tel_number = ARGV[0]
|
5
3
|
if tel_number.nil? || tel_number.empty?
|
6
|
-
puts
|
7
|
-
Please provide your telephone number to earn the tickets (don't use spaces):
|
8
|
-
$ energy_air
|
9
|
-
MSG
|
4
|
+
puts <<~MSG
|
5
|
+
Please provide your telephone number to earn the tickets (don't use spaces):
|
6
|
+
$ energy_air 791234567
|
7
|
+
MSG
|
10
8
|
exit
|
11
9
|
end
|
12
10
|
|
13
|
-
require
|
14
|
-
require
|
11
|
+
require 'bundler/setup'
|
12
|
+
require 'energy_air'
|
15
13
|
|
16
|
-
puts
|
14
|
+
puts '==== Energy Air Quiz bot ===='
|
17
15
|
puts "Version: #{EnergyAir::VERSION}"
|
18
|
-
puts
|
16
|
+
puts 'Use Ctrl-C to stop'
|
19
17
|
puts "'.' means: Quiz played without winning a ticket."
|
20
18
|
puts "'√' means: Quiz played and won a ticket!"
|
21
19
|
puts "'×' means: There was an unknown error (skipped)"
|
22
20
|
|
23
|
-
EnergyAir::Bot.new(tel_number)
|
21
|
+
EnergyAir::Bot.new(tel_number, visual: ARGV.include?('--visual'))
|
data/lib/energy_air/bot.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require "securerandom"
|
4
|
-
require "capybara"
|
5
|
-
require "capybara/dsl"
|
1
|
+
require 'capybara'
|
2
|
+
require 'capybara/dsl'
|
6
3
|
require 'webdrivers/chromedriver'
|
7
|
-
require
|
4
|
+
require 'selenium/webdriver'
|
5
|
+
require 'energy_air/questions'
|
8
6
|
|
9
7
|
Capybara.run_server = false
|
10
|
-
Capybara.current_driver = :selenium_chrome
|
11
8
|
|
12
9
|
# coding: utf-8
|
13
10
|
module EnergyAir
|
14
11
|
class Bot
|
12
|
+
class UnknownQuestionError < StandardError; end
|
13
|
+
|
15
14
|
include Capybara::DSL
|
16
15
|
|
17
|
-
def initialize(tel_number)
|
16
|
+
def initialize(tel_number, visual: false)
|
17
|
+
Capybara.current_driver = visual ? :selenium_chrome : :selenium_chrome_headless
|
18
18
|
@tel_number = tel_number
|
19
19
|
|
20
20
|
register
|
@@ -40,12 +40,17 @@ module EnergyAir
|
|
40
40
|
def run
|
41
41
|
visit 'https://game.energy.ch'
|
42
42
|
answer_question until finished?
|
43
|
-
|
43
|
+
|
44
|
+
return register if reconfirmation_needed?
|
45
|
+
return if lost?
|
46
|
+
|
44
47
|
choose_random_bubble
|
48
|
+
|
45
49
|
if won?
|
46
|
-
print "
|
50
|
+
print "√\a"
|
51
|
+
sleep
|
47
52
|
else
|
48
|
-
print
|
53
|
+
print '.'
|
49
54
|
end
|
50
55
|
rescue StandardError => e
|
51
56
|
print "× (#{e})"
|
@@ -54,12 +59,13 @@ module EnergyAir
|
|
54
59
|
private
|
55
60
|
|
56
61
|
def answer_question
|
57
|
-
current_question = find(
|
58
|
-
answer = QUESTIONS
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
current_question = find('.question-text').text
|
63
|
+
answer = EnergyAir::QUESTIONS.fetch(current_question) do
|
64
|
+
raise UnknownQuestionError, "Cannot find an answer to the question: #{current_question}"
|
65
|
+
end
|
66
|
+
|
67
|
+
2.times { find('label', text: answer).click }
|
68
|
+
click_on 'Weiter'
|
63
69
|
end
|
64
70
|
|
65
71
|
def finished?
|
@@ -67,7 +73,7 @@ module EnergyAir
|
|
67
73
|
end
|
68
74
|
|
69
75
|
def choose_random_bubble
|
70
|
-
all(
|
76
|
+
all('.circle').sample.click
|
71
77
|
end
|
72
78
|
|
73
79
|
def lost?
|
@@ -85,35 +91,8 @@ module EnergyAir
|
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
"Energy Air ist der einzige Energy Event, …" => "...der unter freiem Himmel stattfindet.",
|
92
|
-
"Wie viele Mitarbeiter sind am Energy Air im Einsatz?" => "1300",
|
93
|
-
"Wie reiste Kygo im Jahr 2015 ans Energy Air?" => "Im Privatjet",
|
94
|
-
"Wie breit ist die Energy Air Bühne?" => "70 Meter",
|
95
|
-
"Wie viele Energy Air Tickets werden verlost?" => "40’000",
|
96
|
-
"Auf welcher Social-Media-Plattform kann man keine Energy Air Tickets gewinnen?" => "Twitter",
|
97
|
-
"Wann beginnt das Energy Air 2019?" => "Um 17 Uhr",
|
98
|
-
"Die wievielte Energy Air Ausgabe findet dieses Jahr statt?" => "Die fünfte",
|
99
|
-
"Was verlangte Nena am Energy Air 2016?" => "Eine komplett weisse Garderobe",
|
100
|
-
"Welche DJ-Acts standen 2018 auf der Bühne des Energy Air?" => "Averdeck",
|
101
|
-
"Wie schwer ist die Energy Air Bühne?" => "1000 Tonnen",
|
102
|
-
"Wie viele Acts waren beim letzten Energy Air dabei?" => "15",
|
103
|
-
"Wie viele Konfetti-Kanonen gibt es am Energy Air?" => "40",
|
104
|
-
"Welcher dieser Acts hatte einen Auftritt am Energy Air 2018?" => "DJ Antoine",
|
105
|
-
"Wann fand das Energy Air zum ersten Mal statt?" => "2014",
|
106
|
-
"Wann findet das Energy Air 2019 statt?" => "7. September 2019",
|
107
|
-
"Wo erfährst du immer die neusten Infos rund um das Energy Air?" => "im Radio, auf der Website und über Social Media",
|
108
|
-
"Welche amerikanische Band trat am Energy Air 2016 auf?" => "One Republic",
|
109
|
-
"Wo findet das Energy Air statt?" => "Stade de Suisse, Bern",
|
110
|
-
"Auf welchem Weg kann man KEINE Energy Air Tickets gewinnen?" => "E-Mail",
|
111
|
-
"Wer war der letzte Act am Energy Air 2018?" => "Lo & Leduc",
|
112
|
-
"Mit welchem dieser Tickets geniesst du die beste Sicht zur Energy Air Bühne?" => "Sitzplatz",
|
113
|
-
"Wie viele Spotlights gibt es am Energy Air?" => "250",
|
114
|
-
"Wen nahm Knackeboul am Energy Air 2014 mit backstage?" => "Sein Mami",
|
115
|
-
"Welche Fussballmannschaft ist im Stade de Suisse zuhause?" => "BSC Young Boys",
|
116
|
-
"Wer eröffnete das erste Energy Air?" => "Bastian Baker",
|
117
|
-
}.map { |k, v| [k.upcase, v] }.to_h.freeze
|
94
|
+
def reconfirmation_needed?
|
95
|
+
all('.title-verification').any?
|
96
|
+
end
|
118
97
|
end
|
119
98
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module EnergyAir
|
2
|
+
QUESTIONS = {
|
3
|
+
'Was passiert, wenn es am Eventtag regnet?' => 'Energy Air findet trotzdem statt',
|
4
|
+
'Energy Air Tickets kann man…' => 'gewinnen',
|
5
|
+
'Energy Air ist der einzige Energy Event, …' => '...der unter freiem Himmel stattfindet.',
|
6
|
+
'Wie viele Mitarbeiter sind am Energy Air im Einsatz?' => '1300',
|
7
|
+
'Wie reiste Kygo im Jahr 2015 ans Energy Air?' => 'Im Privatjet',
|
8
|
+
'Wie breit ist die Energy Air Bühne?' => '70 Meter',
|
9
|
+
'Wie viele Energy Air Tickets werden verlost?' => '40’000',
|
10
|
+
'Auf welcher Social-Media-Plattform kann man keine Energy Air Tickets gewinnen?' => 'Twitter',
|
11
|
+
'Wann beginnt das Energy Air 2019?' => 'Um 17 Uhr',
|
12
|
+
'Die wievielte Energy Air Ausgabe findet dieses Jahr statt?' => 'Die sechste',
|
13
|
+
'Was verlangte Nena am Energy Air 2016?' => 'Eine komplett weisse Garderobe',
|
14
|
+
'Welche DJ-Acts standen 2018 auf der Bühne des Energy Air?' => 'Averdeck',
|
15
|
+
'Wie schwer ist die Energy Air Bühne?' => '1000 Tonnen',
|
16
|
+
'Wie viele Acts waren beim letzten Energy Air dabei?' => '15',
|
17
|
+
'Wie viele Konfetti-Kanonen gibt es am Energy Air?' => '40',
|
18
|
+
'Welcher dieser Acts hatte einen Auftritt am Energy Air 2018?' => 'DJ Antoine',
|
19
|
+
'Wann fand das Energy Air zum ersten Mal statt?' => '2014',
|
20
|
+
'Wann findet das Energy Air 2019 statt?' => '7. September 2019',
|
21
|
+
# rubocop:disable Metrics/LineLength
|
22
|
+
'Wo erfährst du immer die neusten Infos rund um das Energy Air?' => 'im Radio, auf der Website und über Social Media',
|
23
|
+
# rubocop:enable Metrics/LineLength
|
24
|
+
'Welche amerikanische Band trat am Energy Air 2016 auf?' => 'One Republic',
|
25
|
+
'Wo findet das Energy Air statt?' => 'Stade de Suisse, Bern',
|
26
|
+
'Auf welchem Weg kann man KEINE Energy Air Tickets gewinnen?' => 'E-Mail',
|
27
|
+
'Wer war der letzte Act am Energy Air 2018?' => 'Lo & Leduc',
|
28
|
+
'Mit welchem dieser Tickets geniesst du die beste Sicht zur Energy Air Bühne?' => 'XTRA-Circle',
|
29
|
+
'Wie viele Spotlights gibt es am Energy Air?' => '250',
|
30
|
+
'Wen nahm Knackeboul am Energy Air 2014 mit backstage?' => 'Sein Mami',
|
31
|
+
'Welche Fussballmannschaft ist im Stade de Suisse zuhause?' => 'BSC Young Boys',
|
32
|
+
'Wer eröffnete das erste Energy Air?' => 'Bastian Baker'
|
33
|
+
}.map { |k, v| [k.upcase, v] }.to_h.freeze
|
34
|
+
end
|
data/lib/energy_air/version.rb
CHANGED
data/lib/energy_air.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: energy_air
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2019.
|
4
|
+
version: '2019.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yves Siegrist
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,20 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '12.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.74'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.74'
|
83
111
|
description:
|
84
112
|
email:
|
85
113
|
- Elektron1c97@gmail.com
|
@@ -89,6 +117,7 @@ extensions: []
|
|
89
117
|
extra_rdoc_files: []
|
90
118
|
files:
|
91
119
|
- ".gitignore"
|
120
|
+
- ".rubocop.yml"
|
92
121
|
- ".ruby-version"
|
93
122
|
- ".travis.yml"
|
94
123
|
- CODE_OF_CONDUCT.md
|
@@ -102,6 +131,7 @@ files:
|
|
102
131
|
- exe/energy_air
|
103
132
|
- lib/energy_air.rb
|
104
133
|
- lib/energy_air/bot.rb
|
134
|
+
- lib/energy_air/questions.rb
|
105
135
|
- lib/energy_air/version.rb
|
106
136
|
homepage: https://github.com/siegy22/energy_air
|
107
137
|
licenses:
|