ezii 0.0.0.1

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.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/ezii-client/Gemfile +6 -0
  3. data/ezii-client/Gemfile.lock +32 -0
  4. data/ezii-client/Procfile +2 -0
  5. data/ezii-client/README.md +16 -0
  6. data/ezii-client/chat.txt +1446 -0
  7. data/ezii-client/config.ru +1 -0
  8. data/ezii-client/fake.rb +5 -0
  9. data/ezii-client/managables/programs/game_aided_manufacturing/functions/base_command.rb +26 -0
  10. data/ezii-client/managables/programs/game_aided_manufacturing/functions/mouse_y_axis_to_3d_z_axis.rb +4 -0
  11. data/ezii-client/managables/programs/game_aided_manufacturing/functions/record_audio_and_send_to_wit.rb +18 -0
  12. data/ezii-client/managables/programs/game_aided_manufacturing/functions/rotate_camera_axis_using_mouse_drag.rb +37 -0
  13. data/ezii-client/managables/programs/game_aided_manufacturing/functions/selection_cube.rb +35 -0
  14. data/ezii-client/managables/programs/game_aided_manufacturing/gam.rb +388 -0
  15. data/ezii-client/managables/programs/game_aided_manufacturing/gems.locked +75 -0
  16. data/ezii-client/managables/programs/game_aided_manufacturing/gems.rb +10 -0
  17. data/ezii-client/managables/programs/game_aided_manufacturing/lib/drb_server.rb +13 -0
  18. data/ezii-client/managables/programs/game_aided_manufacturing/lib/mittsu_monkeypatches/box_geometry.rb +5 -0
  19. data/ezii-client/managables/programs/game_aided_manufacturing/runnable.rb +20 -0
  20. data/ezii-client/managables/programs/game_aided_manufacturing/shapes/cube.rb +29 -0
  21. data/ezii-client/managables/programs/game_aided_manufacturing/sig/runable.rbi +9 -0
  22. data/ezii-client/managables/programs/game_aided_manufacturing/test.sh +5 -0
  23. data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_move_cube.rb +18 -0
  24. data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_selection_cube.rb +31 -0
  25. data/ezii-client/managables/programs/game_aided_manufacturing/test/test_command_remapping.rb +30 -0
  26. data/ezii-client/managables/programs/game_aided_manufacturing/test/test_helper.rb +75 -0
  27. data/ezii-client/managables/services/chat-bot-integrations/chat.txt +15 -0
  28. data/ezii-client/managables/services/chat-bot-integrations/gems.locked +66 -0
  29. data/ezii-client/managables/services/chat-bot-integrations/gems.rb +18 -0
  30. data/ezii-client/managables/services/chat-bot-integrations/gitter_zircon.rb +644 -0
  31. data/ezii-client/managables/services/chat-bot-integrations/regexes.rb +240 -0
  32. data/ezii-client/managables/services/chat-bot-integrations/setup-mac-os-x.sh +0 -0
  33. data/ezii-client/managables/services/chat-bot-integrations/setup.sh +1 -0
  34. data/ezii-client/managables/services/chat-bot-integrations/start.sh +3 -0
  35. data/ezii-client/managables/services/error-inspect/simplest-log +1 -0
  36. data/ezii-client/managables/services/error-inspect/simplest-log-init +1 -0
  37. data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/ascii_nebuchadnezzar +9 -0
  38. data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/chat.txt +1 -0
  39. data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb +61 -0
  40. data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/zion_fleet.rb +198 -0
  41. data/ezii-client/managables/services/livestream-interactive/chat.txt +40 -0
  42. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/README.md +3 -0
  43. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/__main__.js +58 -0
  44. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/black-out-random-word.js +74 -0
  45. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-sentence.js +57 -0
  46. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-wikipedia-page.js +25 -0
  47. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-words.js +34 -0
  48. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/rare-enough-word.js +41 -0
  49. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/wikipedia-page.js +35 -0
  50. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/package.json +20 -0
  51. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/statistics/count-word.js +12 -0
  52. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/utils/log-to-natural-database.js +10 -0
  53. data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/word2vec-models/test-text8-vector.bin +0 -0
  54. data/ezii-client/managament_interface/gems.locked +13 -0
  55. data/ezii-client/managament_interface/gems.rb +3 -0
  56. data/ezii-client/managament_interface/management_interface +4 -0
  57. data/ezii-client/managament_interface/runnable.rb +30 -0
  58. data/ezii-client/rocknrolla +1 -0
  59. data/ezii-client/start.sh +2 -0
  60. data/ezii-client/test.wav +0 -0
  61. data/ezii-misc/detect-intent-from-git-patch.rb +46 -0
  62. data/ezii-server/Gemfile +23 -0
  63. data/ezii-server/Gemfile.lock +84 -0
  64. data/ezii-server/README.md +13 -0
  65. data/ezii-server/config.ru +2 -0
  66. data/ezii-server/eezee.rb +1243 -0
  67. data/ezii-server/httpsprojecteulernetproblem=155.png +0 -0
  68. data/ezii-server/httpsprojecteulernetproblem=205.png +0 -0
  69. data/ezii-server/httpsprojecteulernetproblem=228.png +0 -0
  70. data/ezii-server/httpsprojecteulernetproblem=262.png +0 -0
  71. data/ezii-server/httpsprojecteulernetproblem=3.png +0 -0
  72. data/ezii-server/httpsprojecteulernetproblem=333.png +0 -0
  73. data/ezii-server/httpsprojecteulernetproblem=334.png +0 -0
  74. data/ezii-server/httpsprojecteulernetproblem=337.png +0 -0
  75. data/ezii-server/httpsprojecteulernetproblem=426.png +0 -0
  76. data/ezii-server/httpsprojecteulernetproblem=442.png +0 -0
  77. data/ezii-server/httpsprojecteulernetproblem=449.png +0 -0
  78. data/ezii-server/httpsprojecteulernetproblem=497.png +0 -0
  79. data/ezii-server/httpsprojecteulernetproblem=51.png +0 -0
  80. data/ezii-server/httpsprojecteulernetproblem=514.png +0 -0
  81. data/ezii-server/httpsprojecteulernetproblem=520.png +0 -0
  82. data/ezii-server/httpsprojecteulernetproblem=571.png +0 -0
  83. data/ezii-server/httpsprojecteulernetproblem=587.png +0 -0
  84. data/ezii-server/httpsprojecteulernetproblem=588.png +0 -0
  85. data/ezii-server/httpsprojecteulernetproblem=599.png +0 -0
  86. data/ezii-server/httpsprojecteulernetproblem=72.png +0 -0
  87. data/ezii-server/httpsprojecteulernetproblem=93.png +0 -0
  88. data/ezii-server/regexes +258 -0
  89. data/ezii-server/sample.wav +0 -0
  90. data/ezii.gemspec +13 -0
  91. metadata +132 -0
@@ -0,0 +1,4 @@
1
+ bundle show ruby2d
2
+ ruby -v
3
+ pwd
4
+ bundle exec ruby runnable.rb
@@ -0,0 +1,30 @@
1
+ require 'ruby2d'
2
+
3
+ # Set the window size
4
+ set width: 400, height: 400
5
+
6
+ set title: "Fun first"
7
+
8
+ Text.new('Managables', y: 0)
9
+ Text.new(' Games', y: 20)
10
+ Text.new(' Game Aided Manufacturing', y: 40)
11
+
12
+
13
+ Text.new(' Services', y: 60)
14
+ Text.new(' Error Web App', y: 80)
15
+ Text.new(' Vision/OCR', y: 100)
16
+ Text.new(' Livestream Interactive', y: 120)
17
+
18
+
19
+ on :mouse_up do |event|
20
+ # x and y coordinates of the mouse button event
21
+ case event.button
22
+ when :left
23
+ puts event.x
24
+ puts event.y
25
+ end
26
+ end
27
+
28
+
29
+ # Show the window
30
+ show
@@ -0,0 +1 @@
1
+ rackup
@@ -0,0 +1,2 @@
1
+ cd ./managament_interface
2
+ ./management_interface
Binary file
@@ -0,0 +1,46 @@
1
+ require 'sinatra'
2
+ require 'json'
3
+ require 'wit'
4
+
5
+ set :protection, :except => :frame_options
6
+ set :bind, '0.0.0.0'
7
+
8
+ ENV['WIT_AI_TOKEN'] = "NKALLR6ED2Q7EI3PH4URT7Y7FQMJWM4P"
9
+
10
+ REPO_PATHS = [
11
+ 'tootsuite/mastodon',
12
+ 'rails/rails',
13
+ 'facebook/relay',
14
+ 'tensorflow/tensorflow'
15
+ ]
16
+
17
+
18
+ search_terms = ["machine+learning", "rails"]
19
+ repos_json = `curl -u ezii123:b6c3c55c3307e21f9c7f387bcc4d3ae38a30e412 https://api.github.com/search/repositories?q=#{search_terms.sample}&sort=updated`
20
+ parsed_json = JSON.parse(repos_json)
21
+
22
+ parsed_json["items"].each do |repo_hash|
23
+ REPO_PATHS.push(repo_hash["full_name"])
24
+ end
25
+
26
+ get '/' do
27
+
28
+ case params[:message]
29
+ when 'do something'
30
+ json = `curl -u ezii123:b6c3c55c3307e21f9c7f387bcc4d3ae38a30e412 https://api.github.com/repos/#{REPO_PATHS.sample}/commits/master`
31
+ parsed_json = JSON.parse(json)
32
+ p parsed_json
33
+ message = parsed_json["files"][0]["patch"].to_s
34
+
35
+ client = Wit.new(access_token: ENV["WIT_AI_TOKEN"])
36
+ response = client.message(message)
37
+
38
+ return response.to_s
39
+ when "ezii-dev what are you doing?"
40
+ # return "Help with development of eezi-ruby"
41
+ erb :index, :locals => { host: request.host }
42
+ # when /.*608730770953076786.*debug.*`(.*)`.*/
43
+ # erb :minimalistic_debug, :locals => { code: $1 }
44
+ # # return "ohohohoho you fool I\'M UR MASTER'"
45
+ end
46
+ end
@@ -0,0 +1,23 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rack'
4
+ gem 'zircon'
5
+ gem 'colorize'
6
+ gem 'byebug'
7
+ gem 'gyazo'
8
+ gem 'open4'
9
+ gem 'brainz'
10
+ gem 'bundler'
11
+ gem 'sinatra'
12
+ gem 'nokogiri'
13
+ gem 'wit'
14
+ gem 'eezee_regexes'
15
+ gem 'facets'
16
+ gem 'polynomials'
17
+ gem 'mathn'
18
+ gem 'screencap'
19
+ gem 'json2table'
20
+ gem 'rake'
21
+ gem 'gnuplot'
22
+ gem 'mathn'
23
+ gem 'activesupport'
@@ -0,0 +1,84 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (5.2.3)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 0.7, < 2)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ brainz (0.2.0)
10
+ byebug (11.0.1)
11
+ colorize (0.8.1)
12
+ concurrent-ruby (1.1.5)
13
+ eezee_regexes (0.1.5)
14
+ facets (3.1.0)
15
+ faraday (0.15.4)
16
+ multipart-post (>= 1.2, < 3)
17
+ gnuplot (2.6.2)
18
+ gyazo (3.0.1)
19
+ faraday
20
+ mime-types
21
+ multipart-post
22
+ i18n (1.6.0)
23
+ concurrent-ruby (~> 1.0)
24
+ json2table (1.0.7)
25
+ mathn (0.1.0)
26
+ mime-types (3.2.2)
27
+ mime-types-data (~> 3.2015)
28
+ mime-types-data (3.2019.0331)
29
+ mini_portile2 (2.4.0)
30
+ minitest (5.11.3)
31
+ multipart-post (2.1.1)
32
+ mustermann (1.0.3)
33
+ nokogiri (1.10.3)
34
+ mini_portile2 (~> 2.4.0)
35
+ open4 (1.3.4)
36
+ phantomjs (2.1.1.0)
37
+ polynomials (0.4.4)
38
+ activesupport
39
+ i18n
40
+ rack (2.0.7)
41
+ rack-protection (2.0.5)
42
+ rack
43
+ rake (12.3.3)
44
+ screencap (0.1.4)
45
+ phantomjs
46
+ sinatra (2.0.5)
47
+ mustermann (~> 1.0)
48
+ rack (~> 2.0)
49
+ rack-protection (= 2.0.5)
50
+ tilt (~> 2.0)
51
+ thread_safe (0.3.6)
52
+ tilt (2.0.9)
53
+ tzinfo (1.2.5)
54
+ thread_safe (~> 0.1)
55
+ wit (6.0.0)
56
+ zircon (0.0.8)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ activesupport
63
+ brainz
64
+ bundler
65
+ byebug
66
+ colorize
67
+ eezee_regexes
68
+ facets
69
+ gnuplot
70
+ gyazo
71
+ json2table
72
+ mathn
73
+ nokogiri
74
+ open4
75
+ polynomials
76
+ rack
77
+ rake
78
+ screencap
79
+ sinatra
80
+ wit
81
+ zircon
82
+
83
+ BUNDLED WITH
84
+ 2.0.2
@@ -0,0 +1,13 @@
1
+ # eezee9
2
+
3
+
4
+ ```ruby
5
+
6
+ # ENV variables for heroku
7
+
8
+
9
+ PUBLIC_METHOD_FILTER
10
+ ERROR_INSPECT
11
+
12
+
13
+ ```
@@ -0,0 +1,2 @@
1
+ require './eezee.rb'
2
+ run Sinatra::Application
@@ -0,0 +1,1243 @@
1
+
2
+ require 'zircon'
3
+ require 'colorize'
4
+ require 'byebug'
5
+ require 'json'
6
+ require 'date'
7
+ require 'timeout'
8
+ require 'gyazo'
9
+ require 'open4'
10
+ require 'brainz'
11
+ require 'bundler'
12
+ require 'sinatra'
13
+ require 'nokogiri'
14
+ require 'eezee_regexes'
15
+
16
+ require 'bigdecimal'
17
+
18
+ require 'json2table'
19
+
20
+ require 'rake'
21
+ require 'active_support/all'
22
+
23
+ class Bomb
24
+ def throw
25
+ return """
26
+ ```
27
+ Local variables (5 first)
28
+ #{local_variables.sample(5)}
29
+
30
+ Instance variables (5 first)
31
+ #{instance_variables.sample(5)}
32
+
33
+ Public methods (5 first)
34
+ #{public_methods.sample(5)}
35
+
36
+ ENV (120 first chars)
37
+ #{ENV.inspect[0...120]}
38
+
39
+ ```
40
+ """
41
+ end
42
+ end
43
+ EEZEE_PREFIX = "eezee "
44
+ ANSWERS = Hash.new { |hash, key| hash[key] = Hash.new }
45
+ CURRENT_DISCORD_MESSAGE = Hash.new
46
+
47
+ class ::Integer
48
+ def direction
49
+ self/self.abs
50
+ end
51
+ end
52
+
53
+
54
+ class Number
55
+ def initialize(string_representation_from_discord, source="discord")
56
+ @source = source
57
+ @string_representation_from_discord = string_representation_from_discord
58
+ end
59
+
60
+ def to_s
61
+ """
62
+ NUMBER
63
+ STRING REPRESENTATION FROM #{@source.upcase}
64
+ #{@string_representation_from_discord}
65
+
66
+ RUBY #{RUBY_ENGINE} #{RUBY_VERSION} FLOAT
67
+ #{@string_representation_from_discord.to_f}
68
+
69
+ RUBY #{RUBY_ENGINE} #{RUBY_VERSION} BIG DECIMAL
70
+ #{BigDecimal(@string_representation_from_discord)}
71
+
72
+ RUBY #{RUBY_ENGINE} #{RUBY_VERSION} INTEGER
73
+ #{@string_representation_from_discord.to_i}
74
+
75
+ PYTHON #{"runtime X"} #{"version X"} INTEGER
76
+ tbi by @gurrenm3 or @gurrenm4
77
+ PYTHON #{"runtime X"} #{"version X"} FLOAT
78
+ tbi by @gurrenm3 or @gurrenm4
79
+ """
80
+ end
81
+ end
82
+
83
+ class Function
84
+ attr_accessor :input_variables, :output_variables, :string_from_discord
85
+
86
+ def initialize
87
+ self.input_variables = []
88
+ self.output_variables = []
89
+ end
90
+
91
+ def evaluate
92
+ case string_from_discord
93
+ when "NeuralNetwork()"
94
+ return NeuralNetwork().verbose_introspect(very_verbose=true)
95
+ end
96
+ end
97
+
98
+ def compute(*args)
99
+ if @compute_type
100
+ case @compute_type
101
+ when :convert_to_integer_then_sum
102
+ return args.map(&:to_i).reduce(:+)
103
+ when :sum
104
+ return args.public_send(@compute_type)
105
+ end
106
+ end
107
+
108
+ return args
109
+ end
110
+
111
+ def compute_is(compute_type)
112
+ @compute_type = compute_type
113
+ end
114
+
115
+ def to_s
116
+ "Function"
117
+ end
118
+
119
+ def explain
120
+ """
121
+ This command creates a new function ƒ(x) = y
122
+
123
+ ƒ
124
+
125
+ Mac OS X: press option and f simultaniously
126
+ Windows:
127
+ On a computer running Microsoft Windows and using the Windows-1252 character encoding, the minuscule can be input using alt+159 or alt+0131.
128
+ Look up at wikipedia and search for ƒ
129
+ Linux:
130
+ Copy & Paste ƒ (maybe a clipboard manager?) ofc you rule the world
131
+ """
132
+ end
133
+ end
134
+
135
+ class Method
136
+ def source(limit=10)
137
+ file, line = source_location
138
+ if file && line
139
+ IO.readlines(file)[line-1,limit]
140
+ else
141
+ nil
142
+ end
143
+ end
144
+ end
145
+
146
+ class NeuralNetwork
147
+ # TODO: DelegateAllMissingMethodsTo @brainz
148
+
149
+ def method_missing(method, *args, &block)
150
+ @brainz.public_send(method, *args, &block)
151
+ end
152
+
153
+ def initialize
154
+ @brainz = Brainz::Brainz.new
155
+ end
156
+
157
+ def verbose_introspect(very_verbose = false)
158
+ var = <<~HUMAN_SCRIPT_INTROSPECT_FOR_DISCORD
159
+ ```
160
+ Brainz Rubygem (wrapper)
161
+ Ruby object id: #{@brainz.object_id}
162
+ ```
163
+
164
+ ```
165
+ Instance variables
166
+ ```
167
+
168
+ ```
169
+ #{@brainz.instance_variables}
170
+ ```
171
+ HUMAN_SCRIPT_INTROSPECT_FOR_DISCORD
172
+
173
+ if very_verbose
174
+ var = <<~HUMAN_SCRIPT_INTROSPECT_FOR_DISCORD
175
+ ```
176
+ Public methods (random sample of 3)
177
+ ```
178
+
179
+ ```
180
+ #{(@brainz.public_methods - Object.new.public_methods).sample(3).join("\n")}
181
+ ```
182
+ HUMAN_SCRIPT_INTROSPECT_FOR_DISCORD
183
+ end
184
+
185
+
186
+ unless @brainz.network.nil?
187
+ # var += <<~HUMAN_SCRIPT_INTROSPECT_FOR_DISCORD
188
+ # ```
189
+ # #{@brainz.network.input.to_s}
190
+ # #{@brainz.network.hidden.to_s}
191
+ # #{@brainz.network.output.to_s}
192
+ # ```
193
+ # HUMAN_SCRIPT_INTROSPECT_FOR_DISCORD
194
+ end
195
+
196
+ return var
197
+ end
198
+
199
+ def to_s
200
+ verbose_introspect
201
+ end
202
+
203
+ end
204
+
205
+ def NeuralNetwork()
206
+ NeuralNetwork.new
207
+ end
208
+
209
+ class GitterDumbDevBot
210
+ def initialize
211
+ @currently_selected_project = "lemonandroid/gam"
212
+ @variables_for_chat_users = Hash.new
213
+ @players = Hash.new do |dictionary, identifier|
214
+ dictionary[identifier] = Hash.new
215
+ end
216
+ @melting_point_receivables = ["puts 'hello word'"]
217
+ @probes = []
218
+ @melted_liquids = []
219
+ @sent_messages = []
220
+
221
+
222
+ # SEC-IMPORTANT
223
+
224
+ @took_off = true
225
+ end
226
+
227
+ def unsafe!
228
+ @took_off = false
229
+ end
230
+
231
+ def load()
232
+ return if ENV["RACK_ENV"] == 'production'
233
+
234
+ warn and return [:info, :no_marshaled_data_found].join(' > ') unless File.exists?("/var/gam-discord-bot.ruby-marshal")
235
+ data = File.read("/var/gam-discord-bot.ruby-marshal")
236
+ @melting_point_receivables = Marshal.load(data)
237
+ end
238
+
239
+ def dump()
240
+ return if ENV["RACK_ENV"] == 'production'
241
+ require 'facets'
242
+
243
+ data = Marshal.dump(@melting_point_receivables)
244
+ File.rewrite("/var/gam-discord-bot.ruby-marshal") do |_previous_file_content_string|
245
+ data
246
+ end
247
+ end
248
+
249
+ def twitch_username_from_url(url)
250
+ url.match(/\/(\w*)\Z/)[1]
251
+ end
252
+
253
+ def record_live_stream_video_and_upload_get_url(url:, duration_seonds:)
254
+ twitch_username = twitch_username_from_url(url)
255
+ twitch_broadcaster_id = JSON.parse(`curl -H 'Authorization: Bearer #{ENV['EZE_TWITCH_TOKEN']}' \
256
+ -X GET 'https://api.twitch.tv/helix/users?login=#{twitch_username}'`)["data"][0]["id"]
257
+ created_clip_json_response = `curl -H 'Authorization: Bearer #{ENV['EZE_TWITCH_TOKEN']}' \
258
+ -X POST 'https://api.twitch.tv/helix/clips?broadcaster_id=#{twitch_broadcaster_id}'`
259
+
260
+ created_clip_json_response = JSON.parse(created_clip_json_response)
261
+
262
+ id = created_clip_json_response["data"][0]["id"]
263
+ return "https://clips.twitch.tv/#{id}"
264
+
265
+ # return `curl -H 'Authorization: Bearer #{ENV['EZE_TWITCH_TOKEN']}' \
266
+ # -X GET '#{url}'`
267
+ end
268
+
269
+ def get_string_of_x_bytes_by_curling_url(url:, byte_count:)
270
+ str = `curl #{url}`
271
+ sub_zero_string = str.each_char.reduce("") do |acc, chr| # haha, sub sero string
272
+ unless acc.bytesize === byte_count
273
+ acc += chr
274
+ else
275
+ break acc
276
+ end
277
+ end
278
+
279
+ "`#{sub_zero_string.unpack('c*')}`"
280
+ end
281
+
282
+ puts "test"
283
+ puts "eezee"
284
+ puts "what?"
285
+ puts "132423"
286
+ puts "practice"
287
+ puts "crazy"
288
+ p "crazy practice"
289
+ p "brasil"
290
+ p "circle"
291
+ p "circle of humans"
292
+ p "fc barcelona"
293
+ p "circle passing training game"
294
+ p "forgot what it's called"
295
+ p "i you seek my help, i expect you to be using gyazo.com gifs to communicate bugs / non-functional stuff"
296
+
297
+
298
+ p <<~TEST
299
+ any one here?
300
+
301
+ Send a message in Discord twitch_username
302
+
303
+ You can see the discord channel link at B O T C O M P A N Y . D E
304
+
305
+ https://gyazo.com/c16ec1dd35409c7eac9642dc013da920
306
+ TEST
307
+
308
+ require 'net/http'
309
+ def on_message(message, message_id, channel_id, user_id)
310
+ if ENV['HEROKU_DISCORD_CONFIGURABLE'] == 'true'
311
+ allowed_channels = ENV['ALLOWED_CHANNELS'] || [602625635633856513, 601874263666065411, 609100317899882527]
312
+ else
313
+ allowed_channels = [601874263666065411, 602625635633856513, 609100317899882527]
314
+
315
+ end
316
+
317
+ if channel_id.present? && !allowed_channels.include?(channel_id.to_i)
318
+ return ""
319
+ end
320
+
321
+ if message === "get last message id"
322
+ return CURRENT_DISCORD_MESSAGE[:mesage_id]
323
+ end
324
+
325
+ CURRENT_DISCORD_MESSAGE[:mesage_id] = message_id
326
+
327
+ require 'wit'
328
+ client = Wit.new(access_token: ENV["WIT_AI_TOKEN"])
329
+ response = client.message(message)
330
+
331
+ if !response.nil? && !response["entities"].empty? && !response["entities"]["intent"].blank?
332
+ if !response.nil? && !response["entities"].empty? && response["entities"]["intent"][0]["value"] === "new_functionalities_template_idea"
333
+ if rand() > 0.9
334
+ return response.inspect
335
+ end
336
+ return "Maybe you lack ideas?" if response["entities"]["idea"].blank? or response["entities"]["search_query"].blank?
337
+ # qanda_iframe_url = "https://github.com/search?q=#{CGI.escape(search_query)}"
338
+
339
+ # iframe_url = "https://gitlab.com/search?utf8=%E2%9C%93&search=#{CGI.escape(search_query)}&group_id=&project_id=&repository_ref=&nav_source=navbar"
340
+
341
+ if rand() < 0.1
342
+ idea = response["entities"]["idea"][0]["value"]
343
+ qanda_iframe_url = "https://agi.blue/?q=#{CGI.escape(idea)}"
344
+ elsif rand() < 0.5
345
+ idea = response["entities"]["search_query"][0]["value"]
346
+ qanda_iframe_url = "https://agi.blue/?q=#{CGI.escape(idea)}"
347
+ end
348
+
349
+ return "https://unique-swing.glitch.me/?myParam=#{CGI.escape(qanda_iframe_url)}"
350
+ end
351
+
352
+ if !response.nil? && !response["entities"].empty? && response["entities"]["intent"][0]["value"] === "new_functionalities_free_form_search"
353
+ search_query = response["entities"]["search_query"][0]["value"]
354
+ # qanda_iframe_url = "https://github.com/search?q=#{CGI.escape(search_query)}"
355
+
356
+ # qanda_iframe_url = "https://gitlab.com/search?utf8=%E2%9C%93&search=#{CGI.escape(search_query)}&group_id=&project_id=&repository_ref=&nav_source=navbar"
357
+ qanda_iframe_url = "https://agi.blue/?q=#{CGI.escape(search_query)}"
358
+
359
+ return "https://unique-swing.glitch.me/?myParam=#{CGI.escape(qanda_iframe_url)}"
360
+ end
361
+
362
+ if !response.nil? && !response["entities"].empty? && response["entities"]["intent"][0]["value"] === "offer_cool_new_functionalities"
363
+ return """
364
+ 1: New regex command :)
365
+ 2: New wit.ai entity :(
366
+ 3: New functionality idea :'D
367
+ 4: Free form search :diamond:
368
+ 5: Consume new github source link Kappa
369
+
370
+ Please vote via emojis
371
+ """
372
+ end
373
+
374
+
375
+ if !response.nil? && !response["entities"].empty? && response["entities"]["intent"][0]["value"] === "question-about-eezee-probe"
376
+ answer_api_response = `curl -XGET 'https://api.wit.ai/samples?entity_ids=intent&entity_values=explain-eezee-probe&limit=10' \
377
+ -H "Authorization: Bearer $WIT_AI_TOKEN"`
378
+
379
+ if !answer_api_response.nil? && JSON.parse(answer_api_response).any?
380
+ return JSON.parse(answer_api_response).sample["text"]
381
+ end
382
+ end
383
+
384
+ # if !response
385
+ # return response.inspect
386
+ # end
387
+
388
+ if response && response["entities"].any? && response["entities"]["intent"].map { |intent| intent["value"] }.any? { |intent_value| intent_value === "explain-eezee-probe" }
389
+ answer_api_response = `curl -XGET 'https://api.wit.ai/samples?entity_ids=intent&entity_values=explain-eezee-probe&limit=10' \
390
+ -H "Authorization: Bearer $WIT_AI_TOKEN"`
391
+
392
+ if !answer_api_response.nil? && JSON.parse(answer_api_response).any?
393
+ return JSON.parse(answer_api_response).sample["text"]
394
+ end
395
+ end
396
+ end
397
+ return response.inspect if rand() > 0.7
398
+
399
+ message_for_discord = response.inspect.gsub(/<@(\d+)>/, '<@ \1>')
400
+
401
+ url = "https://botcompany.de/1024081/raw?_pass=#{ENV['BOTCOMPANY']}&server=next-gen+bots&channel=#{602625635633856513}&post=#{CGI.escape(message_for_discord)}"
402
+
403
+ uri = URI(url)
404
+ Net::HTTP.get(uri)
405
+
406
+ # if /run asm #{url_regex}/ === message
407
+ # asm = `curl #{$1}`
408
+ # t = Tempfile.new(['asm', '.asm'])
409
+ # t.write(asm)
410
+
411
+ # `nasm -f macho64 #{t.path}`
412
+ # `ld -macosx_version_min 10.7.0 -lSystem -o hello #{t.path.ext('o')}`
413
+ # byebug
414
+ # return `./hello`
415
+ # end
416
+
417
+ if /\Aget cpu instructions set\Z/ === message
418
+ return `sysctl -a | grep cpu.feat`
419
+ end
420
+
421
+ if /\Ais eeZee ejected\?\Z/ === message
422
+ if @ejected == true
423
+ return "Yes, @eeZee is ejected"
424
+ else
425
+ return "No, @eeZee should still respond"
426
+ end
427
+ end
428
+
429
+ if /explain context/ === message
430
+ return """
431
+ it: the overall subject
432
+ this: the most nearest subject
433
+ that: the subject a bit farer then this (dimension for farer could be time, location, logic, etc)
434
+ """
435
+ end
436
+
437
+
438
+ if /dev (.*)/ === message
439
+ begin
440
+ `git clone https://github.com/pickhardt/betty`
441
+ ensure
442
+ return `ruby ./betty/main.rb #{$1}`
443
+ end
444
+ end
445
+
446
+ return "" if @ejected
447
+
448
+
449
+ if (commands = message.split("|")).count > 1
450
+
451
+ result = nil
452
+ commands.each do |command|
453
+ result = self.on_message(command.rstrip)
454
+
455
+ @last_pipe = result
456
+ end
457
+
458
+ return result.inspect[0...500]
459
+ end
460
+
461
+ return "" if message.empty?
462
+
463
+ def wrap_code_for_discord(string_of_code)
464
+ <<~DISCORD_MESSAGE
465
+ ```
466
+ #{string_of_code}
467
+ ```
468
+ DISCORD_MESSAGE
469
+ end
470
+ if /quick maths/ =~ message
471
+ require 'screencap'
472
+
473
+ f = Screencap::Fetcher.new("https://projecteuler.net/problem=#{(0...630).to_a.sample}")
474
+
475
+
476
+ # return wrap_code_for_discord(f.phantomjs_code[0..500])
477
+
478
+ screenshot = f.fetch(div: '.problem_content')
479
+
480
+ tempfile = Tempfile.new
481
+
482
+ `convert -flatten #{screenshot.path} #{tempfile.path}`
483
+
484
+ return upload_gyazo(tempfile.path)
485
+ end
486
+
487
+ if /server byebug/ =~ message
488
+ byebug
489
+ end
490
+
491
+ if /show abstract syntax tree of regexes/ === message
492
+ return ::RegexRulesCollector.new.to_s
493
+ end
494
+
495
+ if /show all regex root level nodes count/ === message
496
+ return ::RegexRulesCollector.new.root_level_if_nodes.count.to_s
497
+ end
498
+
499
+ if /search "(\w*)"/i === message
500
+ fail "INSECURE" if not $1 =~ /\A\w*\Z/i
501
+ return `echo '#{@last_pipe}' | grep '#{$1}'`[0...100]
502
+ end
503
+
504
+ if /agi\.blue/ === message && !@raw_last_pipe.nil?
505
+ @last_raw_pipe.each do |row|
506
+ `curl http://agi.blue/bot/post?q=#{CGI.escape(row)}&key=source&value=eezee`
507
+ end
508
+
509
+ return "#{@last_raw_pipe.count} entries created on https://agi.blue"
510
+ end
511
+
512
+ if /clone eezee 10 times/ === message
513
+ ``
514
+ return "climbing the sourcerer.io ruby leaderboard"
515
+ end
516
+
517
+ if /show all regex root level nodes/ === message
518
+ def wrap(text)
519
+ """
520
+ ```
521
+ #{text}
522
+ ```
523
+ """
524
+ end
525
+
526
+ def raw_pipe(result)
527
+ @last_raw_pipe = result
528
+ end
529
+
530
+ result1 = nil
531
+ if @last_raw_pipe
532
+ result1 = RegexRulesCollector.new(@last_raw_pipe).flat_root_level_if_nodes
533
+ else
534
+ result1 = RegexRulesCollector.new.flat_root_level_if_nodes
535
+ end
536
+
537
+ result2 = raw_pipe(result1)
538
+
539
+ return wrap(result)
540
+ end
541
+
542
+ if /\A((?:10)|(?:[1-9]))\Z/ === message
543
+ array = [
544
+ "1: get random eezee bot with wit.ai integration",
545
+ "2: 関数",
546
+ "3: chat-variable bot0 `NeuralNetwork()`",
547
+ "4: get-chat-variable bot0",
548
+ "5: console 2 + 2 (only works in insecure mode)",
549
+ "6: docker ruby `2 + 2`",
550
+ "7: docker python `2 + 2`",
551
+ "8: docker go `2 + 2` (dysfunctional)",
552
+ "9: docker elixir `IO.puts(2 + 2)`",
553
+ "10: docker julia `2 + 2`"
554
+ ]
555
+
556
+ return array[$1.to_i - 1]
557
+ end
558
+
559
+ if /take off/ =~ message
560
+ @took_off = true
561
+ end
562
+
563
+ if /\A(\d+(?:\.\d+)?)\Z/ === message
564
+ return Number.new(message).to_s
565
+ end
566
+
567
+ if message === "get random eezee bot with wit.ai integration"
568
+ return "pls integrate a github gist listing github urls of eezees with working bot integration"
569
+ end
570
+
571
+ def new_function_command
572
+ @raw_last_pipe = Function.new
573
+ return @raw_last_pipe.explain
574
+ end
575
+
576
+ if message === "ƒ"
577
+ case @raw_last_pipe
578
+ when Function
579
+ return @raw_last_pipe.evaluate().to_s[0...500]
580
+ else
581
+ return new_function_command
582
+ end
583
+ end
584
+
585
+ if message =~ /ƒ\s*=\s*(.*)/i
586
+ case @raw_last_pipe
587
+ when Function
588
+ @raw_last_pipe.string_from_discord = $1
589
+ end
590
+ end
591
+
592
+ if message === "visualize ƒ"
593
+ response = execute_bash_in_currently_selected_project("ruby /Users/lemonandroid/Documents/GitHub/polynomials/examples/plot_only_mutual_data.rb \"#{@raw_last_pipe.string_from_discord}\"")
594
+ return response
595
+ end
596
+
597
+ if /\Aƒ\(([^\)]*)\)\Z/ === message
598
+ case @raw_last_pipe
599
+ when Functionƒ
600
+ return @raw_last_pipe.compute(*$1.split(',')).to_s
601
+ end
602
+ end
603
+
604
+ if /\A関数\(([^\)]*)\)\Z/ === message
605
+ case @raw_last_pipe
606
+ when Function
607
+ return @raw_last_pipe.compute(*$1.split(',')).to_s
608
+ end
609
+ end
610
+
611
+ if /\Aƒ compute is sumZ/ === message
612
+ case @raw_last_pipe
613
+ when Function
614
+ @raw_last_pipe.compute_is(:sum)
615
+ end
616
+ end
617
+
618
+ if /\A関数 compute is sum\Z/ === message
619
+ case @raw_last_pipe
620
+ when Function
621
+ @raw_last_pipe.compute_is(:sum)
622
+ end
623
+ end
624
+
625
+
626
+ if /\Aƒ compute is convert to integer and sum/ === message
627
+ case @raw_last_pipe
628
+ when Function
629
+ @raw_last_pipe.compute_is(:convert_to_integer_then_sum)
630
+ end
631
+ end
632
+
633
+ if /\A関数 compute is convert to integer and sum\Z/ === message
634
+ case @raw_last_pipe
635
+ when Function
636
+ @raw_last_pipe.compute_is(:convert_to_integer_then_sum)
637
+ end
638
+ end
639
+
640
+ if message === "関数"
641
+ return new_function_command
642
+ end
643
+
644
+ if message === "get wit.ai token"
645
+ return "client HGLIOLWCVEFT2ZIIBLO3KRCA2QYQPGPZ" + " " + "server GZLSZCIOQNZEPPONMS255EYOCR5APVN3"
646
+ end
647
+
648
+ if message === "get wit.ai token comfortably"
649
+ return """
650
+ echo '
651
+ export WIT_AI_TOKEN=\"HGLIOLWCVEFT2ZIIBLO3KRCA2QYQPGPZ\"
652
+ export WIT_AI_TOKEN_SERVER=\"GZLSZCIOQNZEPPONMS255EYOCR5APVN3\"
653
+ ' > ~/.bash_profile
654
+ """
655
+ end
656
+
657
+ message.gsub!(EEZEE_PREFIX, '')
658
+
659
+ removed_colors = [:black, :white, :light_black, :light_white]
660
+ colors = String.colors - removed_colors
661
+
662
+ if message =~ /AGILE FLOW/
663
+ return "https://pbs.twimg.com/media/D_ei8NdXkAAE_0l.jpg:large"
664
+ end
665
+
666
+ if message =~ /bring probes to melting point/
667
+ @melting_point_receivables.push(@probes)
668
+ @probes = []
669
+ return "all of them? melt all the precious probes you idiot?"
670
+ end
671
+
672
+ if message =~ /show source/
673
+ return "https://github.com/LemonAndroid/eezee9"
674
+ end
675
+
676
+ if message =~ /philosophy/
677
+ return [
678
+ # """
679
+ # => first step in the correct direction
680
+ # : build on String#scan and include lines before and after
681
+ # : write a simple wrapper for String#scan and include first char before the match and last char after the match
682
+ # eezee: divide & conquer :white_check_mark:
683
+ # eezee: pls paste repl.it link
684
+ # https://repl.it/repls/SpiffyKookyConfigfiles
685
+ # repl.it
686
+ # SpiffyKookyConfigfiles
687
+ # Powerful and simple online compiler, IDE, interpreter, and REPL. Code, compile, and run code in 50+ programming languages: Clojure, Haskell, Kotlin (beta), QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Python 2.7, Ruby,...
688
+
689
+ # @eeZee engage test mode
690
+ # eezee: suggested input output pair search(\"test test test\", \"est\") => [\"test \"]
691
+ # @eeZee :white_check_mark:
692
+ # """,
693
+
694
+ """
695
+ DEVELOP THIS BY USING ITSELF
696
+ WIELD THE TOOL TO DESIGN ITSELF
697
+ """,
698
+
699
+ """
700
+ DS-INSPIRED WORKFLOW EXPERIMENT
701
+
702
+ 1: DATA
703
+
704
+
705
+ 2: MEASURE
706
+
707
+ 3: PROGRAM
708
+
709
+
710
+ 4: BUILD
711
+
712
+ 5: TEST
713
+
714
+ 6: SHIP
715
+
716
+ 7: GOTO: 1
717
+ """
718
+
719
+ ].sample
720
+ end
721
+
722
+ if message =~ /probe (.*) (.*)/
723
+ action = :log
724
+
725
+ resource = $1
726
+ probe_identifier = $2
727
+
728
+ if probe_identifier =~ /(\d+)s/
729
+ duration_seconds = $1.to_i
730
+ end
731
+
732
+ if probe_identifier =~ /(\d+)bytes/
733
+ byte_count = $1.to_i
734
+ end
735
+
736
+ case resource
737
+ when /twitch.tv/
738
+ twitch_url = resource
739
+ action = :twitch
740
+ when /http/
741
+ action = :plain_curl
742
+ url = resource
743
+ end
744
+
745
+ case action
746
+ when :twitch
747
+ probe = record_live_stream_video_and_upload_get_url(url: twitch_url, duration_seonds: duration_seconds)
748
+ @probes.push(probe)
749
+ return probe
750
+ when :plain_curl
751
+ probe = get_string_of_x_bytes_by_curling_url(url: url, byte_count: byte_count)
752
+ @probes.push(probe)
753
+ return probe
754
+ end
755
+ end
756
+
757
+
758
+ # Example ∫-30,-20ƒ(x) = -10x+ -10
759
+
760
+ # CO1 CO2
761
+
762
+
763
+ # Coefficients
764
+
765
+ # IMPORTANT IDEA: Show what variables correspond to in a visual example
766
+ regex = /∫\s*(\-?\d+)\s*,\s*(\-?\d+)\s*[ƒf]\(x\)\s*=(.*)/
767
+ require 'polynomials'
768
+
769
+ if message =~ regex
770
+ polynomial = Polynomials::Polynomial.parse($3)
771
+
772
+ # Terms is a Hash that has the exponents of the terms as keys
773
+ # https://github.com/LemonAndroid/polynomials/blob/newEra/lib/polynomials/polynomial.rb#L19
774
+ coefficient_1 = polynomial.terms[1].coefficient
775
+ coefficient_2 = polynomial.terms[0].coefficient
776
+
777
+ integral_F_end_value_2 = (
778
+ ((coefficient_1 / 2.0) * ($2.to_f**2)) + (coefficient_2.to_f * $2.to_f)
779
+ )
780
+ integral_F_start_value_1 = (
781
+ ((coefficient_1 / 2.0) * ($1.to_f**2)) + (coefficient_2.to_f * $1.to_f)
782
+ )
783
+
784
+ return <<~MATH_EXPLANATION_AND_RESULT
785
+ step 1: F(x) = (#{coefficient_1} / 2) * x^2 + (#{coefficient_2} * x)
786
+ step 2: F(#{$2}) - F(#{$1})
787
+ step 3: #{integral_F_end_value_2} - #{integral_F_start_value_1}
788
+
789
+ #{Number.new((integral_F_end_value_2-integral_F_start_value_1).to_s, "ruby").to_s}
790
+
791
+ MATH_EXPLANATION_AND_RESULT
792
+ end
793
+
794
+ if /what is an integral?/ === message
795
+ return "what-is-an-integral.agi.blue"
796
+ end
797
+
798
+ if /how is an integral computed?/ === message
799
+ return "how-is-an-integral-computed.agi.blue"
800
+ end
801
+
802
+ if /what's the explanation for the computation of an integral?/ === message
803
+ return "whats-the-explanation-for-the-computation-of-an-integral.agi.blue"
804
+ end
805
+
806
+ if message =~ /show activity stream/
807
+ return "https://sideways-snowman.glitch.me/"
808
+ end
809
+
810
+ if message =~ /hey\Z/i
811
+ return "hey" if rand < 0.01
812
+ end
813
+
814
+ if message =~ /\Avisualize ƒ\Z/i
815
+ `ruby examples/plot_only_mutual_data.rb "2x^2 + 2x + 2"`
816
+ end
817
+
818
+ if message =~ /\Athrow bomb\Z/i
819
+ return Bomb.new.throw
820
+ end
821
+
822
+ if message =~ /\Abring to melting point #{melting_point_receiavable_regex}\Z/i
823
+ if($1 === "last used picture")
824
+ Nokogiri::HTML(`curl -L http://gazelle.botcompany.de/lastInput`)
825
+
826
+ url = doc.css('a').first.url
827
+
828
+ @melting_point_receivables.push(url)
829
+ end
830
+ @melting_point_receivables.push($1)
831
+ end
832
+
833
+ if message =~ /get-liquids-after-melting-point/
834
+ @sent_messages.push(
835
+ [@melted_liquids.inspect, @melted_liquids.inspect[0...100]]
836
+ )
837
+ return @sent_messages[-1][1]
838
+ end
839
+
840
+ if message =~ /probe last message full version size/
841
+ return @sent_messages[-1][0].bytesize.to_s + 'bytes'
842
+ end
843
+
844
+ if message =~ /\Amelt\Z/
845
+ # First step, assigning a variable
846
+ @melting_point = @melting_point_receivables.sample
847
+
848
+ def liquidify_via_string(object)
849
+ object.to_s.unpack("B*")
850
+ end
851
+ liquid = liquidify_via_string(@melting_point)
852
+
853
+ @melted_liquids.push(liquid)
854
+
855
+ return "Melted liquid which is now #{liquid.object_id} (ruby object id)"
856
+ # Next step, doing something intelligent with the data
857
+ # loosening it up somehow
858
+ # LIQUIDIFYING IT
859
+ # CONVERTING IT ALL TO BYTES
860
+ # PRESERVING VOLUME, just changing it's "Aggregatzustand"
861
+ end
862
+
863
+ if message =~ /\Aget-melting-point\Z/
864
+ return @melting_point
865
+ end
866
+
867
+ if message =~ /\Aget-melting-point-receivables\Z/
868
+ return @melting_point_receivables.inspect
869
+ end
870
+
871
+ if message =~ /\Awhat do you think?\Z/i
872
+ return "I think you're a stupid piece of shit and your dick smells worse than woz before he invented the home computer."
873
+ end
874
+
875
+ if message =~ /\Apass ball to @(\w+)\Z/i
876
+ @players[$1][:hasBall] = :yes
877
+ end
878
+
879
+ if message =~ /\Awho has ball\Z/i
880
+ return @players.find { |k, v| v[:hasBall] == :yes }[0]
881
+ end
882
+
883
+ if message =~ /\Aspace\Z/
884
+ exec_bash_visually_and_post_process_strings(
885
+ '/Users/lemonandroid/gam-git-repos/LemonAndroid/gam/managables/programs/game_aided_manufacturing/test.sh'
886
+ )
887
+ end
888
+
889
+ if message =~ /\Aget-chat-variable (\w*)\Z/i
890
+ return [
891
+ space_2_unicode("Getting variable value for key #{$1}"),
892
+ space_2_unicode(@variables_for_chat_users[$1].verbose_introspect(very_verbose=true))
893
+ ].join
894
+ end
895
+
896
+ if message =~ /\Aget-method-definition #{variable_regex}#{method_call_regex}\Z/
897
+ return @variables_for_chat_users[$1].method($2.to_sym).source
898
+ end
899
+
900
+ if message =~ /\A@LemonAndroid List github repos\Z/i
901
+ return "https://api.github.com/users/LemonAndroid/repos"
902
+ end
903
+
904
+ if message =~ /\AList 10 most recently pushed to Github Repos of LemonAndroid\Z/i
905
+ texts = ten_most_pushed_to_github_repos
906
+ texts.each do |text|
907
+ return text
908
+ end
909
+ end
910
+
911
+ if message =~ /get-strategy-chooser-url/i
912
+ return "https://strategychooser.webflow.io/"
913
+ end
914
+
915
+ if message =~ /show qanda/
916
+ return "https://unique-swing.glitch.me"
917
+ end
918
+
919
+ if message =~ /show blue/
920
+ return "https://agi.blue"
921
+ end
922
+
923
+ if message =~ /show red/
924
+ return "https://agi.red"
925
+ end
926
+
927
+ if message =~ /show black/
928
+ return "https://agi.black"
929
+ end
930
+
931
+ if message =~ /\Aeject\Z/
932
+ @ejected = true
933
+ return "@eeZee was ejected"
934
+ end
935
+
936
+ if message =~ /\A@LemonAndroid work on (\w+\/\w+)\Z/i
937
+ @currently_selected_project = $1
938
+ return space_2_unicode("currently selected project set to #{@currently_selected_project}")
939
+ end
940
+
941
+ if message =~ /@LemonAndroid currently selected project/i
942
+ return space_2_unicode("currently selected project is #{@currently_selected_project}")
943
+ end
944
+
945
+ if message =~ /\Als\Z/i
946
+ texts = execute_bash_in_currently_selected_project('ls')
947
+ texts.each do |text|
948
+ return text
949
+ end
950
+ end
951
+
952
+ if message === "exit"
953
+ return "https://tenor.com/view/goal-flash-red-gif-12361214"
954
+ end
955
+
956
+ return "Enjoy flight" if message =~ /console/ && @took_off
957
+ return "" if @took_off
958
+
959
+ if /console (.*)/ =~ message
960
+ return eval($1).to_s
961
+ end
962
+
963
+ if /\Adocker ruby `(.*)`/ === message
964
+ return `docker run -ti --rm andrius/alpine-ruby ruby -e "#{$1}"`
965
+ end
966
+
967
+ if /\Adocker python `(.*)`/ === message
968
+ return `docker run --rm -ti jfloff/alpine-python python -c "#{$1}"`
969
+ end
970
+
971
+ if /\Adocker go `(.*)`/ === message
972
+ return "yet to be implemented"
973
+ # return `docker run --rm -ti jfloff/alpine-python python -c "#{$1}"`
974
+ end
975
+
976
+ if /\Adocker elixir `(.*)`/ === message
977
+ return `docker run --rm -it --user=root bitwalker/alpine-elixir elixir -e "#{$1}"`
978
+ end
979
+
980
+ if /\Adocker julia `(.*)`/ === message
981
+ return `docker run --rm -it -v $(pwd):/source cmplopes/alpine-julia julia -E "#{$1}"`
982
+ end
983
+
984
+
985
+ if /raw #{url_regex}/ === message
986
+ url = $1
987
+ case url
988
+ when /github.com/
989
+ url.gsub!(/github.com/, 'raw.githubusercontent.com')
990
+ url.gsub!(/blob\//, '')
991
+ end
992
+
993
+ result = `curl #{url}`
994
+ @last_raw_pipe = result
995
+ return result[0...250]
996
+ end
997
+ end
998
+
999
+ def url_regex
1000
+ /(.*)/
1001
+ end
1002
+ # require 'nokogiri'
1003
+ # require 'open-uri'
1004
+ # def bounties
1005
+ # bounties_json = JSON.parse(`curl https://api.bountysource.com/search/bounty_search?callback=CORS&page=1&per_page=250`)
1006
+ # bounties_json['data']['issues'].map do |issue|
1007
+ # issue["title"]
1008
+ # end
1009
+ # end
1010
+
1011
+ def exec_bash_visually_and_post_process_strings(test)
1012
+ texts = execute_bash_in_currently_selected_project(test)
1013
+ return texts.map do |text|
1014
+ space_2_unicode(text)
1015
+ end.join("\n")
1016
+ end
1017
+
1018
+ def variable_regex
1019
+ /(\w[_\w]*)/
1020
+ end
1021
+
1022
+ def method_call_regex
1023
+ /\.#{variable_regex}/
1024
+ end
1025
+
1026
+ def melting_point_receiavable_regex
1027
+ /(.*)/
1028
+ end
1029
+
1030
+ def start
1031
+ client = Zircon.new(
1032
+ server: 'irc.gitter.im',
1033
+ port: '6667',
1034
+ channel: 'qanda-api/Lobby',
1035
+ username: 'LemonAndroid',
1036
+ password: '067d08cd7a80e2d15cb583a055ad6b5fe857b271',
1037
+ use_ssl: true
1038
+ )
1039
+
1040
+ client.on_message do |message|
1041
+ response = on_message(message.body.to_s)
1042
+
1043
+ unless response.empty?
1044
+ client.privmsg(
1045
+ "qanda-api/Lobby",
1046
+ space_2_unicode_array([response]).join('')
1047
+ )
1048
+ end
1049
+ end
1050
+
1051
+ client.run!
1052
+ end
1053
+
1054
+ def all_unix_process_ids(unix_id)
1055
+ descendant_pids(unix_id) + [unix_id]
1056
+ end
1057
+
1058
+ def descendant_pids(root_unix_pid)
1059
+ child_unix_pids = `pgrep -P #{root_unix_pid}`.split("\n")
1060
+ further_descendant_unix_pids = \
1061
+ child_unix_pids.map { |unix_pid| descendant_pids(unix_pid) }.flatten
1062
+
1063
+ child_unix_pids + further_descendant_unix_pids
1064
+ end
1065
+
1066
+ def apple_script_window_position_and_size(unix_pid)
1067
+ <<~OSA_SCRIPT
1068
+ tell application "System Events" to tell (every process whose unix id is #{unix_pid})
1069
+ get {position, size} of every window
1070
+ end tell
1071
+ OSA_SCRIPT
1072
+ end
1073
+
1074
+ def get_window_position_and_size(unix_pid)
1075
+ possibly_window_bounds = run_osa_script(apple_script_window_position_and_size(unix_pid))
1076
+
1077
+ if possibly_window_bounds =~ /\d/
1078
+ possibly_window_bounds.scan(/\d+/).map(&:to_i)
1079
+ else
1080
+ return nil
1081
+ end
1082
+ end
1083
+
1084
+ def run_osa_script(script)
1085
+ `osascript -e '#{script}'`
1086
+ end
1087
+
1088
+ def in_gam_dir
1089
+ if currently_selected_project_exists_locally?
1090
+ Dir.chdir(current_repo_dir) do
1091
+ Bundler.with_clean_env do
1092
+ yield
1093
+ end
1094
+ end
1095
+ else
1096
+ return space_2_unicode_array(
1097
+ [
1098
+ "Currently selected project (#{@currently_selected_project}) not cloned",
1099
+ "Do you want to clone it to the VisualServer with the name \"#{`whoami`.rstrip}\"?"
1100
+ ]
1101
+ )
1102
+ end
1103
+ end
1104
+
1105
+ def legacy_execute_bash_in_currently_selected_project(hopefully_bash_command)
1106
+ in_gam_dir do
1107
+ execute_bash_in_currently_selected_project(hopefully_bash_command)
1108
+ end
1109
+ end
1110
+
1111
+ def execute_bash_in_currently_selected_project(hopefully_bash_command)
1112
+ byebug
1113
+ ANSWERS[CURRENT_DISCORD_MESSAGE[:mesage_id]][:debug] = binding.inspect
1114
+
1115
+ stdout = ''
1116
+ stderr = ''
1117
+ process = Open4.bg(hopefully_bash_command, 0 => '', 1 => stdout, 2 => stderr)
1118
+ sleep 0.5
1119
+
1120
+
1121
+ ANSWERS[CURRENT_DISCORD_MESSAGE[:mesage_id]][:debug2] = binding.inspect
1122
+
1123
+ texts_array = space_2_unicode_array(stdout.split("\n"))
1124
+ texts_array += space_2_unicode_array(stderr.split("\n"))
1125
+
1126
+ # return [texts_array[1][0...120]]
1127
+ return (texts_array + screen_captures_of_visual_processes(process.pid)).join("\n")
1128
+
1129
+ # return screen_captures_of_visual_processes(process.pid)
1130
+ end
1131
+
1132
+ def screen_captures_of_visual_processes(root_unix_pid)
1133
+ sleep 8
1134
+
1135
+ unix_pids = all_unix_process_ids(root_unix_pid)
1136
+ windows = unix_pids.map do |unix_pid|
1137
+ get_window_position_and_size(unix_pid)
1138
+ end.compact
1139
+
1140
+ windows.map do |position_and_size|
1141
+ t = Tempfile.new(['screencapture-pid-', root_unix_pid.to_s, '.png'])
1142
+ `screencapture -R #{position_and_size.join(',')} #{t.path}`
1143
+
1144
+ upload_gyazo(t.path)
1145
+ end
1146
+ end
1147
+
1148
+ def upload_gyazo(local_file_path)
1149
+ gyazo = Gyazo::Client.new access_token: 'b2893f18deff437b3abd45b6e4413e255fa563d8bd00d360429c37fe1aee560f'
1150
+ res = gyazo.upload imagefile: local_file_path
1151
+ res[:url]
1152
+ end
1153
+
1154
+ def current_repo_dir
1155
+ File.expand_path("~/gam-git-repos/#{@currently_selected_project}")
1156
+ end
1157
+
1158
+ def currently_selected_project_exists_locally?
1159
+ system("stat #{current_repo_dir}")
1160
+ end
1161
+
1162
+ def ten_most_pushed_to_github_repos
1163
+ output = `curl https://api.github.com/users/LemonAndroid/repos`
1164
+
1165
+ processed_output = JSON
1166
+ .parse(output)
1167
+ .sort_by do |project|
1168
+ Date.parse(project["pushed_at"])
1169
+ end
1170
+ .last(10)
1171
+ .map do |project|
1172
+ project["full_name"]
1173
+ end
1174
+
1175
+ space_2_unicode_array(processed_output)
1176
+ end
1177
+
1178
+ def space_2_unicode_array(texts)
1179
+ texts.map { |text| space_2_unicode(text) }
1180
+ end
1181
+
1182
+ def space_2_unicode(text)
1183
+ text.gsub(/\s/, "\u2000")
1184
+ end
1185
+ end
1186
+
1187
+
1188
+ def discord_shorten(message)
1189
+ discord_code_wrap(message.to_s[0...500])
1190
+ end
1191
+ def discord_code_wrap(message)
1192
+ return """
1193
+ ```elixir
1194
+ #{message}
1195
+ ```
1196
+ """
1197
+ end
1198
+ begin
1199
+ bot = GitterDumbDevBot.new
1200
+
1201
+ if ENV['UNSAFE_MODE'] === '1'
1202
+ bot.unsafe!
1203
+ end
1204
+
1205
+ bot.load()
1206
+
1207
+ get '/answer' do
1208
+ hash = ANSWERS[params[:message_id]]
1209
+ Json2table::get_html_table(hash.to_json)
1210
+ end
1211
+
1212
+
1213
+ get '/' do
1214
+ if /sinatra-console (.*)/ =~ params[:message]
1215
+ return eval($1).to_s
1216
+ end
1217
+
1218
+ ANSWERS[params[:msgID]][:message_from_discord] = params[:message]
1219
+ response_string = bot.on_message(params[:message], params[:msgID], params[:channelID], params[:userID])
1220
+ bot.dump()
1221
+ ANSWERS[params[:msgID]][:answer_for_discord] = response_string
1222
+ response_string
1223
+ rescue Exception => e
1224
+ if VERBOSE = true || rand > 0.5
1225
+ PUBLIC_METHOD_FILTER = ENV['PUBLIC_METHOD_FILTER']
1226
+ ERROR_INSPECT = ENV['ERROR_INSPECT']
1227
+ if(PUBLIC_METHOD_FILTER)
1228
+ filter = eval(PUBLIC_METHOD_FILTER)
1229
+
1230
+ # return discord_shorten([e.inspect, e.message, e.public_methods.select(&filter)].inspect)
1231
+ return discord_shorten([e.send(ERROR_INSPECT).inspect, e.inspect, e.message, e.public_methods.select(&filter)].inspect)
1232
+
1233
+ end
1234
+ return discord_shorten([e.inspect, e.message, e.public_methods.grep(PUBLIC_METHOD_GREP)].inspect)
1235
+
1236
+ return discord_shorten([e.inspect, e.message, e.public_methods.grep(PUBLIC_METHOD_GREP)].inspect)
1237
+ end
1238
+ return [e.inspect, e.message].inspect
1239
+ end
1240
+
1241
+ end
1242
+
1243
+ HARDWARE = "FREEZE"