energy_air 2017.1 → 2019.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/energy_air.gemspec +4 -3
- data/lib/energy_air.rb +0 -5
- data/lib/energy_air/bot.rb +71 -76
- data/lib/energy_air/version.rb +1 -1
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ea6a011fb71e4376e27a9cc2209bd25adc2bdcc9a38ecab7e548ad8576811251
|
4
|
+
data.tar.gz: 41dfc7e280c36862782036b9d76db4b6d0be5f6f16cee770e138f898bb764ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a620017f0f1c5a3e29303630ab45c173e2227411a76fba43f4982bf97f8c7c02fe9887f0d505f7846d32e5f8026e1e4f6b49239934c0b462d39ba668c860269c
|
7
|
+
data.tar.gz: '069a794e8b524b0f8e381b7d9e35109b86cc800eec5bd4b72554585b7d10e3634eedd93656f615d08f1b597167bafb574aa8af92fdb82f3cdacbfd5cc9bec981'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/energy_air.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Yves Siegrist"]
|
9
9
|
spec.email = ["Elektron1c97@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = "Automatically win energy air tickets without playing
|
11
|
+
spec.summary = "Automatically win energy air tickets without really playing."
|
12
12
|
spec.homepage = "https://github.com/siegy22/energy_air"
|
13
13
|
spec.license = "MIT"
|
14
14
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "capybara", "~>
|
22
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency "capybara", "~> 3"
|
22
|
+
spec.add_dependency 'selenium-webdriver', '~> 3'
|
23
|
+
spec.add_dependency 'webdrivers', '~> 4'
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.15"
|
25
26
|
spec.add_development_dependency "rake", "~> 12.0"
|
data/lib/energy_air.rb
CHANGED
data/lib/energy_air/bot.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "tempfile"
|
3
|
+
require "securerandom"
|
4
|
+
require "capybara"
|
5
|
+
require "capybara/dsl"
|
6
|
+
require 'webdrivers/chromedriver'
|
7
|
+
require "selenium/webdriver"
|
8
|
+
|
9
|
+
Capybara.run_server = false
|
10
|
+
Capybara.current_driver = :selenium_chrome
|
11
|
+
|
1
12
|
# coding: utf-8
|
2
13
|
module EnergyAir
|
3
14
|
class Bot
|
@@ -5,24 +16,31 @@ module EnergyAir
|
|
5
16
|
|
6
17
|
def initialize(tel_number)
|
7
18
|
@tel_number = tel_number
|
8
|
-
Capybara.run_server = false
|
9
|
-
Capybara.register_driver :chrome_poltergeist do |app|
|
10
|
-
chrome_poltergeist = Capybara::Poltergeist::Driver.new(app)
|
11
|
-
chrome_poltergeist.headers = {
|
12
|
-
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'
|
13
|
-
}
|
14
|
-
chrome_poltergeist.timeout = 100
|
15
|
-
chrome_poltergeist
|
16
|
-
end
|
17
|
-
Capybara.current_driver = :chrome_poltergeist
|
18
19
|
|
20
|
+
register
|
19
21
|
loop { run }
|
20
22
|
end
|
21
23
|
|
24
|
+
def register
|
25
|
+
visit 'https://game.energy.ch'
|
26
|
+
|
27
|
+
fill_in 'inlineFormInput', with: @tel_number
|
28
|
+
click_on 'Verifizieren'
|
29
|
+
check_for_error
|
30
|
+
|
31
|
+
print 'Activation code (received via SMS): '
|
32
|
+
activation_code = $stdin.gets.strip
|
33
|
+
activation_code.chars.each.with_index do |num, index|
|
34
|
+
fill_in (index + 1).to_s, with: num
|
35
|
+
end
|
36
|
+
sleep 5
|
37
|
+
click_on 'Verifizieren'
|
38
|
+
end
|
39
|
+
|
22
40
|
def run
|
23
41
|
visit 'https://game.energy.ch'
|
24
|
-
enter_tel_number
|
25
42
|
answer_question until finished?
|
43
|
+
return if all('h1', text: 'Leider verloren').any?
|
26
44
|
choose_random_bubble
|
27
45
|
if won?
|
28
46
|
print "√"
|
@@ -31,94 +49,71 @@ module EnergyAir
|
|
31
49
|
end
|
32
50
|
rescue StandardError => e
|
33
51
|
print "× (#{e})"
|
34
|
-
ensure
|
35
|
-
reset_browser
|
36
52
|
end
|
37
53
|
|
38
54
|
private
|
39
|
-
def enter_tel_number
|
40
|
-
find("input#mobile").set(@tel_number)
|
41
|
-
click_on("LOS GEHTS")
|
42
|
-
end
|
43
55
|
|
44
56
|
def answer_question
|
45
|
-
current_question = find(".question
|
57
|
+
current_question = find(".question-text").text
|
46
58
|
answer = QUESTIONS[current_question]
|
47
|
-
|
48
|
-
click_on("
|
59
|
+
find('label', text: answer).click
|
60
|
+
click_on("Weiter")
|
61
|
+
rescue Capybara::ElementNotFound
|
62
|
+
visit 'https://game.energy.ch'
|
49
63
|
end
|
50
64
|
|
51
65
|
def finished?
|
52
|
-
all(
|
66
|
+
all('.question-text').empty?
|
53
67
|
end
|
54
68
|
|
55
69
|
def choose_random_bubble
|
56
|
-
|
57
|
-
all("#wingame a").sample.click
|
70
|
+
all(".circle").sample.click
|
58
71
|
end
|
59
72
|
|
60
73
|
def lost?
|
61
|
-
|
74
|
+
all('img[src="https://cdn.energy.ch/game-web/images/eair/bubble-lose.png"]').any?
|
62
75
|
end
|
63
76
|
|
64
77
|
def won?
|
65
78
|
!lost?
|
66
79
|
end
|
67
80
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
81
|
+
def check_for_error
|
82
|
+
if all('.error-message').any?
|
83
|
+
warn "An error message appeared: #{find('.error-message').text}\nExiting.."
|
84
|
+
exit
|
85
|
+
end
|
71
86
|
end
|
72
87
|
|
73
88
|
QUESTIONS = {
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"
|
82
|
-
"
|
83
|
-
"
|
84
|
-
"
|
85
|
-
"Welche
|
86
|
-
"
|
87
|
-
"Wie
|
88
|
-
"Wie viele
|
89
|
-
"
|
90
|
-
"
|
91
|
-
"
|
92
|
-
"
|
93
|
-
"
|
94
|
-
"
|
95
|
-
"
|
96
|
-
"
|
97
|
-
"
|
98
|
-
"Wie viele
|
99
|
-
"
|
100
|
-
"
|
101
|
-
"
|
102
|
-
|
103
|
-
"Welches Stadion ist das grösste der Schweiz?" => 1,
|
104
|
-
"Welcher Act stand schon einmal auf der Energy Air Bühne?" => 1,
|
105
|
-
"Wie lautet der offizielle Energy Air Hashtag?" => 3,
|
106
|
-
"Welcher Künstler stand NOCH NIE auf der Energy Air Bühne?" => 1,
|
107
|
-
"Wie hiess die Energy Air Hymne 2015?" => 1,
|
108
|
-
"Von welchem vergangenen Energy Air Act ist der Song «Angelina»?" => 1,
|
109
|
-
"Welcher Act performte in einem Karton-Hippie-Bus?" => 3,
|
110
|
-
"Wie heissen zwei andere grosse Events von Energy?" => 1,
|
111
|
-
"In welchem Jahr stand OneRepublic auf der Bühne des Energy Air?" => 1,
|
112
|
-
"Welche deutsche Sängerin stand letztes Jahr auf der Energy Air Bühne?" => 1,
|
113
|
-
"Wie viel kostet ein Energy Air Ticket?" => 1,
|
114
|
-
"Von wem wird das Energy Air durchgeführt?" => 1,
|
115
|
-
"Wie oft pro Jahr findet das Energy Air statt?" => 3,
|
116
|
-
"Wie viele Tickets werden für das Energy Air verlost?" => 1,
|
117
|
-
"Wo kann man Energy Air Tickets kaufen?" => 3,
|
118
|
-
"Welche Farben dominieren das Energy Air Logo?" => 1,
|
119
|
-
"Welcher Pop-Sänger stand in diesem Jahr schon auf der Bühne des Stade de Suisse?" => 1,
|
120
|
-
"Wann ist die offizielle Türöffnung beim Energy Air?" => 1,
|
121
|
-
"Wann fand das Energy Air letztes Jahr statt?" => 1
|
122
|
-
}
|
89
|
+
"Was passiert, wenn es am Eventtag regnet?" => "Energy Air findet trotzdem statt",
|
90
|
+
"Energy Air Tickets kann man…" => "gewinnen",
|
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
|
123
118
|
end
|
124
119
|
end
|
data/lib/energy_air/version.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: '
|
4
|
+
version: '2019.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yves Siegrist
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: selenium-webdriver
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webdrivers
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,9 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
122
|
- !ruby/object:Gem::Version
|
109
123
|
version: '0'
|
110
124
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.6.11
|
125
|
+
rubygems_version: 3.0.4
|
113
126
|
signing_key:
|
114
127
|
specification_version: 4
|
115
|
-
summary: Automatically win energy air tickets without playing
|
128
|
+
summary: Automatically win energy air tickets without really playing.
|
116
129
|
test_files: []
|