fbomb 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +93 -0
- data/README.md +130 -0
- data/Rakefile +41 -9
- data/bin/fbomb +226 -31
- data/fbomb.gemspec +51 -8
- data/images/planet/1dEzGbz.jpg +0 -0
- data/images/planet/3aASzbv.jpg +0 -0
- data/images/planet/BCfEwgl.jpg +0 -0
- data/images/planet/EPbgqjy.jpg +0 -0
- data/images/planet/FoiDgwc.jpg +0 -0
- data/images/planet/HJiUPV2.jpg +0 -0
- data/images/planet/KOcvGjw.jpg +0 -0
- data/images/planet/L5n5lPK.jpg +0 -0
- data/images/planet/MaGKipv.jpg +0 -0
- data/images/planet/QVRALtz.jpg +0 -0
- data/images/planet/W3fWkTZ.jpg +0 -0
- data/images/planet/about.md +1 -0
- data/images/planet/nWqdkF7.jpg +0 -0
- data/images/planet/w41sv1T.jpg +0 -0
- data/images/planet/xySa4GD.jpg +0 -0
- data/images/planet/yzw8pOQ.jpg +0 -0
- data/lib/fbomb.rb +99 -19
- data/lib/fbomb/campfire.rb +39 -11
- data/lib/fbomb/command.rb +52 -15
- data/lib/fbomb/commands/builtin.rb +720 -9
- data/lib/fbomb/commands/system.rb +52 -10
- data/lib/fbomb/flowdock.rb +307 -0
- data/lib/fbomb/util.rb +65 -0
- data/lib/fbomb/uuid.rb +312 -0
- data/notes/ara.txt +54 -0
- metadata +229 -113
- data/README +0 -20
@@ -1,4 +1,194 @@
|
|
1
1
|
FBomb {
|
2
|
+
##
|
3
|
+
#
|
4
|
+
command(:hai){
|
5
|
+
help 'say hai'
|
6
|
+
|
7
|
+
call do |*args|
|
8
|
+
speak('hai')
|
9
|
+
end
|
10
|
+
}
|
11
|
+
|
12
|
+
##
|
13
|
+
#
|
14
|
+
command(:speak){
|
15
|
+
help 'say *args'
|
16
|
+
|
17
|
+
call do |*args|
|
18
|
+
speak(args.map{|arg| arg.to_s}.join(' '))
|
19
|
+
end
|
20
|
+
}
|
21
|
+
|
22
|
+
##
|
23
|
+
#
|
24
|
+
command(:paste){
|
25
|
+
help 'paste *args'
|
26
|
+
|
27
|
+
call do |*args|
|
28
|
+
paste(args.map{|arg| arg.to_s}.join(' '))
|
29
|
+
end
|
30
|
+
}
|
31
|
+
|
32
|
+
##
|
33
|
+
#
|
34
|
+
command(:cheat){
|
35
|
+
help 'some useful cheat sheats'
|
36
|
+
|
37
|
+
index = <<-__
|
38
|
+
http://www.emoji-cheat-sheet.com/
|
39
|
+
__
|
40
|
+
|
41
|
+
call do |*args|
|
42
|
+
paste(index)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
##
|
47
|
+
#
|
48
|
+
# FIXME
|
49
|
+
command(:foaas){
|
50
|
+
help "Fuck Off As A Service - http://foaas.com/"
|
51
|
+
|
52
|
+
index = <<-__
|
53
|
+
/off/:name/:from
|
54
|
+
/you/:name/:from
|
55
|
+
/this/:from
|
56
|
+
/that/:from
|
57
|
+
/everything/:from
|
58
|
+
/everyone/:from
|
59
|
+
/donut/:name/:from
|
60
|
+
/shakespeare/:name/:from
|
61
|
+
/linus/:name/:from
|
62
|
+
/king/:name/:from
|
63
|
+
/pink/:from
|
64
|
+
/life/:from
|
65
|
+
/chainsaw/:name/:from
|
66
|
+
/:thing/:from
|
67
|
+
/thanks/:from
|
68
|
+
/flying/:from
|
69
|
+
/fascinating/:from
|
70
|
+
__
|
71
|
+
|
72
|
+
call do |*args|
|
73
|
+
op = args.shift.to_s.downcase.strip
|
74
|
+
|
75
|
+
case op
|
76
|
+
when '', 'help'
|
77
|
+
paste(index)
|
78
|
+
else
|
79
|
+
url = ['http://foaas.com', op, *args].join('/')
|
80
|
+
fuck_off = `curl --silent -H 'Accept: text/plain' #{ url.inspect }`
|
81
|
+
speak(fuck_off)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
}
|
85
|
+
|
86
|
+
|
87
|
+
=begin
|
88
|
+
|
89
|
+
/off/:name/:from
|
90
|
+
/you/:name/:from
|
91
|
+
/this/:from
|
92
|
+
/that/:from
|
93
|
+
/everything/:from
|
94
|
+
/everyone/:from
|
95
|
+
/donut/:name/:from
|
96
|
+
/shakespeare/:name/:from
|
97
|
+
/linus/:name/:from
|
98
|
+
/king/:name/:from
|
99
|
+
/pink/:from
|
100
|
+
/life/:from
|
101
|
+
/chainsaw/:name/:from
|
102
|
+
/:thing/:from
|
103
|
+
/thanks/:from
|
104
|
+
/flying/:from
|
105
|
+
/fascinating/:from
|
106
|
+
|
107
|
+
=end
|
108
|
+
|
109
|
+
|
110
|
+
##
|
111
|
+
#
|
112
|
+
command(:planet) {
|
113
|
+
help "With me you will take off. http://imgur.com/a/Ilw2G."
|
114
|
+
|
115
|
+
call do |*args|
|
116
|
+
basenames = %w[
|
117
|
+
1dEzGbz.jpg
|
118
|
+
3aASzbv.jpg
|
119
|
+
BCfEwgl.jpg
|
120
|
+
EPbgqjy.jpg
|
121
|
+
FoiDgwc.jpg
|
122
|
+
HJiUPV2.jpg
|
123
|
+
KOcvGjw.jpg
|
124
|
+
L5n5lPK.jpg
|
125
|
+
MaGKipv.jpg
|
126
|
+
nWqdkF7.jpg
|
127
|
+
QVRALtz.jpg
|
128
|
+
W3fWkTZ.jpg
|
129
|
+
w41sv1T.jpg
|
130
|
+
xySa4GD.jpg
|
131
|
+
yzw8pOQ.jpg
|
132
|
+
]
|
133
|
+
|
134
|
+
basename = basenames.sort_by{ rand }.first
|
135
|
+
url = File.join('https://raw.github.com/ahoward/fbomb/master/images/planet', basename)
|
136
|
+
speak(url)
|
137
|
+
end
|
138
|
+
}
|
139
|
+
|
140
|
+
##
|
141
|
+
#
|
142
|
+
command(:chuckle) {
|
143
|
+
help "Ha ha, very funny."
|
144
|
+
setup{ require "google-search" }
|
145
|
+
|
146
|
+
call do |*args|
|
147
|
+
uris = []
|
148
|
+
images = Google::Search::Image.new(:query => 'funny safety signs', :image_size => :medium)
|
149
|
+
images.each { |result| uris << result.uri }
|
150
|
+
speak(uris.sort_by { rand }.first)
|
151
|
+
end
|
152
|
+
}
|
153
|
+
|
154
|
+
##
|
155
|
+
#
|
156
|
+
# FIXME
|
157
|
+
command(:elevator){
|
158
|
+
help "Give me the pitch."
|
159
|
+
|
160
|
+
call do |*args|
|
161
|
+
message = [
|
162
|
+
"We're %s %s.",
|
163
|
+
"I said \"%s %s\" and the flow got really quiet.",
|
164
|
+
"We are going after a billion-dollar market with %s %s.",
|
165
|
+
"If you can't sell %s %s, you can't sell anything.",
|
166
|
+
"I've got it! \"Sometimes you feel like a nut, sometimes you're %s %s.\""
|
167
|
+
].sort_by { rand }.first
|
168
|
+
|
169
|
+
description = `curl --silent 'http://itsthisforthat.com/api.php?text'`
|
170
|
+
re = %r|So, Basically, It's Like A (.*)\.|
|
171
|
+
description.tap do |string|
|
172
|
+
string.sub!(/^So, Basically, It's Like A /, '').
|
173
|
+
string.chomp!(".")
|
174
|
+
end
|
175
|
+
|
176
|
+
article = description[0] =~ /^[aeiou]/i ? 'an' : 'a'
|
177
|
+
|
178
|
+
speak(format(message, article, description))
|
179
|
+
end
|
180
|
+
}
|
181
|
+
##
|
182
|
+
#
|
183
|
+
command(:reload){
|
184
|
+
help 'reload fbomb commands'
|
185
|
+
|
186
|
+
call do |*args|
|
187
|
+
FBomb::Command.table = FBomb::Command::Table.new
|
188
|
+
FBomb::Command.load(Command.command_paths)
|
189
|
+
speak('YOU MUST BE OVER 18 TO ENTER THIS SITE')
|
190
|
+
end
|
191
|
+
}
|
2
192
|
|
3
193
|
##
|
4
194
|
#
|
@@ -9,12 +199,16 @@ FBomb {
|
|
9
199
|
|
10
200
|
call do |*args|
|
11
201
|
args.each do |arg|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
202
|
+
if arg.strip == 'orange'
|
203
|
+
speak('nothing rhymes with orange dumbass')
|
204
|
+
else
|
205
|
+
word = CGI.escape(arg.strip)
|
206
|
+
url = "http://www.zachblume.com/apis/rhyme.php?format=xml&word=#{ word }"
|
207
|
+
data = `curl --silent #{ url.inspect }`
|
208
|
+
words = data.scan(%r|<word>([^<]*)</word>|).flatten
|
209
|
+
msg = words.join(" ")
|
210
|
+
speak(msg)
|
211
|
+
end
|
18
212
|
end
|
19
213
|
end
|
20
214
|
}
|
@@ -34,7 +228,11 @@ FBomb {
|
|
34
228
|
command(:fukung) {
|
35
229
|
call do |*args|
|
36
230
|
tags = args.join(' ').strip.downcase
|
37
|
-
|
231
|
+
if tags.empty?
|
232
|
+
msg = Array(Fukung.random).sort_by{ rand }.first(3).join("\n")
|
233
|
+
else
|
234
|
+
msg = Fukung.tag(tags).sort_by{ rand }.first(3).join("\n")
|
235
|
+
end
|
38
236
|
speak(msg) unless msg.strip.empty?
|
39
237
|
end
|
40
238
|
}
|
@@ -51,8 +249,17 @@ FBomb {
|
|
51
249
|
when /image|img|i/i
|
52
250
|
args.shift
|
53
251
|
query = args.join(' ')
|
54
|
-
|
55
|
-
|
252
|
+
@cache ||= []
|
253
|
+
images = Google::Search::Image.new(:query => query, :image_size => :small)
|
254
|
+
if images.any?
|
255
|
+
images.each do |result|
|
256
|
+
next if @cache.include? result.id
|
257
|
+
@cache << result.id
|
258
|
+
msg = "#{ result.uri }\n"
|
259
|
+
break
|
260
|
+
end
|
261
|
+
else
|
262
|
+
msg = "No results for: #{query}"
|
56
263
|
end
|
57
264
|
else
|
58
265
|
query = args.join(' ')
|
@@ -64,6 +271,33 @@ FBomb {
|
|
64
271
|
end
|
65
272
|
}
|
66
273
|
|
274
|
+
##
|
275
|
+
#
|
276
|
+
command(:fail){
|
277
|
+
setup{ require "nokogiri"}
|
278
|
+
|
279
|
+
call do |*args|
|
280
|
+
msg = ""
|
281
|
+
query = CGI.escape(args.join(' ').strip)
|
282
|
+
url = "http://failblog.org/?s=#{query}"
|
283
|
+
data = `curl --silent #{ url.inspect }`
|
284
|
+
doc = Nokogiri::HTML(data)
|
285
|
+
images = doc.search('div.entry img').collect{|i| i.get_attribute('src')}
|
286
|
+
@cache ||= []
|
287
|
+
if images.any?
|
288
|
+
images.each do |result|
|
289
|
+
next if @cache.include? result
|
290
|
+
@cache << result
|
291
|
+
msg = "#{ result }\n"
|
292
|
+
break
|
293
|
+
end
|
294
|
+
else
|
295
|
+
msg = "No results for: #{query}"
|
296
|
+
end
|
297
|
+
speak(msg) unless msg.empty?
|
298
|
+
end
|
299
|
+
}
|
300
|
+
|
67
301
|
##
|
68
302
|
#
|
69
303
|
command(:gist) {
|
@@ -86,5 +320,482 @@ FBomb {
|
|
86
320
|
end
|
87
321
|
}
|
88
322
|
|
323
|
+
##
|
324
|
+
#
|
325
|
+
# FIXME
|
326
|
+
command(:xkcd) {
|
327
|
+
call do |*args|
|
328
|
+
id = args.shift || rand(1000)
|
329
|
+
url = "http://xkcd.com/#{ id }/"
|
330
|
+
html = `curl --silent #{ url.inspect }`
|
331
|
+
doc = Nokogiri::HTML(html)
|
332
|
+
links = []
|
333
|
+
doc.xpath('//h3').each do |node|
|
334
|
+
text = node.text
|
335
|
+
case text
|
336
|
+
when %r'Permanent link to this comic:', %r'hotlinking/embedding'
|
337
|
+
link = text.split(':').last
|
338
|
+
link = "http:#{ link }" unless link['://']
|
339
|
+
links << link
|
340
|
+
end
|
341
|
+
end
|
342
|
+
links.each do |link|
|
343
|
+
speak(link)
|
344
|
+
end
|
345
|
+
end
|
346
|
+
}
|
347
|
+
|
348
|
+
##
|
349
|
+
#
|
350
|
+
# FIXME
|
351
|
+
command(:goodfuckingdesignadvice) {
|
352
|
+
call do |*args|
|
353
|
+
url = "http://goodfuckingdesignadvice.com/index.php"
|
354
|
+
html = `curl --location --silent #{ url.inspect }`
|
355
|
+
doc = Nokogiri::HTML(html)
|
356
|
+
msg = nil
|
357
|
+
doc.xpath('//div').each do |node|
|
358
|
+
if node['class'] =~ /advice/
|
359
|
+
text = node.text
|
360
|
+
msg = text
|
361
|
+
end
|
362
|
+
end
|
363
|
+
speak(msg) if msg
|
364
|
+
end
|
365
|
+
}
|
366
|
+
|
367
|
+
##
|
368
|
+
#
|
369
|
+
command(:designquote) {
|
370
|
+
call do |*args|
|
371
|
+
url = "http://quotesondesign.com"
|
372
|
+
cmd = "curl --location --silent #{ url.inspect }"
|
373
|
+
html = `#{ cmd }`
|
374
|
+
id = rand(10)
|
375
|
+
doc = Nokogiri::HTML(html)
|
376
|
+
msg = nil
|
377
|
+
doc.xpath('//div').each do |node|
|
378
|
+
if node['id'] =~ /post-/
|
379
|
+
text = node.text
|
380
|
+
break(msg = text)
|
381
|
+
end
|
382
|
+
end
|
383
|
+
if msg
|
384
|
+
msg = msg.gsub(%r'\[\s+permalink\s+\]', '').gsub(%r'\[\s+Tweet\s+This\s+\]', '').strip
|
385
|
+
msg = Unidecoder.decode(msg)
|
386
|
+
speak(msg)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
}
|
390
|
+
|
391
|
+
##
|
392
|
+
#
|
393
|
+
command(:quote) {
|
394
|
+
call do |*args|
|
395
|
+
url = "http://iheartquotes.com/api/v1/random?format=html&max_lines=4&max_characters=420"
|
396
|
+
html = `curl --location --silent #{ url.inspect }`
|
397
|
+
doc = Nokogiri::HTML(html)
|
398
|
+
msg = nil
|
399
|
+
#<a target="_parent" href='http://iheartquotes.com/fortune/show/victory_uber_allies_'>Victory uber allies!</a>
|
400
|
+
doc.xpath('//div[@class="rbcontent"]/a').each do |node|
|
401
|
+
text = node.text
|
402
|
+
msg = text
|
403
|
+
end
|
404
|
+
speak(msg) if msg
|
405
|
+
end
|
406
|
+
}
|
407
|
+
|
408
|
+
##
|
409
|
+
#
|
410
|
+
command(:peeps){
|
411
|
+
call do |*args|
|
412
|
+
msgs = []
|
413
|
+
flow.users.each do |user|
|
414
|
+
name = user['name']
|
415
|
+
email = user['email']
|
416
|
+
avatar = user['avatar']
|
417
|
+
speak(avatar.gsub(%r|/+$|, '') + '.jpg')
|
418
|
+
speak("#{ name } // #{ email }")
|
419
|
+
end
|
420
|
+
end
|
421
|
+
}
|
422
|
+
|
423
|
+
##
|
424
|
+
#
|
425
|
+
command(:rawk){
|
426
|
+
call do |*args|
|
427
|
+
urls = %w(
|
428
|
+
http://s3.amazonaws.com/drawohara.com.images/angus1.gif
|
429
|
+
http://img.maniadb.com/images/artist/117/117027.jpg
|
430
|
+
http://images.starpulse.com/Photos/pv/Van%20Halen-7.JPG
|
431
|
+
)
|
432
|
+
speak(urls[rand(urls.size)])
|
433
|
+
end
|
434
|
+
}
|
435
|
+
|
436
|
+
command(:certified) {
|
437
|
+
call do |*args|
|
438
|
+
urls = %w(
|
439
|
+
http://blog.pravesh.me/files/2012/08/worksonmymachine.jpg
|
440
|
+
http://4.bp.blogspot.com/_CywCAU4HORs/S-HYtX4vOkI/AAAAAAAAAHw/Hzi5PYZOkrg/s320/ItWorksOnMyMachine.jpg
|
441
|
+
http://people.scs.carleton.ca/~mvvelzen/pH/works-on-my-machine-stamped.png
|
442
|
+
http://cdn.memegenerator.net/instances/400x/24722869.jpg
|
443
|
+
http://sd.keepcalm-o-matic.co.uk/i/keep-calm-it-works-on-my-machine.png
|
444
|
+
)
|
445
|
+
speak(urls[rand(urls.size)])
|
446
|
+
end
|
447
|
+
}
|
448
|
+
|
449
|
+
##
|
450
|
+
#
|
451
|
+
command(:meat){
|
452
|
+
call do |*args|
|
453
|
+
url = 'http://baconipsum.com/api/?type=meat-and-filler¶s=1'
|
454
|
+
data = `curl --silent #{ url.inspect }`
|
455
|
+
data.gsub!(/[\["\]]/, '')
|
456
|
+
speak(data)
|
457
|
+
end
|
458
|
+
}
|
459
|
+
|
460
|
+
##
|
461
|
+
#
|
462
|
+
command(:shaka){
|
463
|
+
call do |*args|
|
464
|
+
speak('http://s3.amazonaws.com/drawohara.com.images/shaka.jpg')
|
465
|
+
end
|
466
|
+
}
|
467
|
+
|
468
|
+
##
|
469
|
+
#
|
470
|
+
command(:unicorn){
|
471
|
+
setup{ require "google-search" }
|
472
|
+
|
473
|
+
urls = [
|
474
|
+
'http://dbprng00ikc2j.cloudfront.net/work/image/390379/d14s2l/20101223063430-exterface_unicorn_03.jpg',
|
475
|
+
'http://fc04.deviantart.net/fs51/f/2009/281/a/7/White_Unicorn_My_Little_Pony_by_Barkingmadd.jpg',
|
476
|
+
'http://th54.photobucket.com/albums/g119/jasonjmore/th_UnicornPeeingRainbow.jpg',
|
477
|
+
'http://th242.photobucket.com/albums/ff99/1010496/th_unicornpr0n.gif'
|
478
|
+
]
|
479
|
+
|
480
|
+
call do |*args|
|
481
|
+
if args.first == 'bomb'
|
482
|
+
n = Integer(args[1] || [3, rand(10)].max)
|
483
|
+
images = Google::Search::Image.new(:query => 'unicorn', :image_size => :medium)
|
484
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
485
|
+
n.times{ speak(msg = images.pop) }
|
486
|
+
else
|
487
|
+
speak(urls.sample)
|
488
|
+
end
|
489
|
+
end
|
490
|
+
}
|
491
|
+
|
492
|
+
##
|
493
|
+
#
|
494
|
+
command(:steve){
|
495
|
+
setup{ require "google-search" }
|
496
|
+
|
497
|
+
call do |*args|
|
498
|
+
|
499
|
+
images = Google::Search::Image.new(:query => 'french+club', :image_size => :medium)
|
500
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
501
|
+
speak(msg = "Livraison spéciale pour Chaps Bailey!")
|
502
|
+
speak(msg = images.sample)
|
503
|
+
end
|
504
|
+
}
|
505
|
+
|
506
|
+
##
|
507
|
+
#
|
508
|
+
command(:yak){
|
509
|
+
setup{ require "google-search" }
|
510
|
+
|
511
|
+
call do |*args|
|
512
|
+
|
513
|
+
images = Google::Search::Image.new(:query => 'shaved+yak', :image_size => :medium)
|
514
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
515
|
+
speak(msg = "Sometimes you just need a really close shave...")
|
516
|
+
speak(msg = images.sample)
|
517
|
+
end
|
518
|
+
}
|
519
|
+
|
520
|
+
##
|
521
|
+
#
|
522
|
+
command(:endoftheworld){
|
523
|
+
setup{ require "google-search" }
|
524
|
+
|
525
|
+
call do |*args|
|
526
|
+
|
527
|
+
images = Google::Search::Image.new(:query => 'end+of+the+world+2012', :image_size => :large)
|
528
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
529
|
+
speak(msg = "It's the end of the world as we know it...")
|
530
|
+
speak(msg = images.sample)
|
531
|
+
end
|
532
|
+
}
|
533
|
+
|
534
|
+
##
|
535
|
+
#
|
536
|
+
command(:cookingwithgas) {
|
537
|
+
call do |*args|
|
538
|
+
images = Google::Search::Image.new(:query => 'cooking+with+gas+explosion', :image_size => :large)
|
539
|
+
images = images.map { |result| result.uri}.uniq.sort_by { rand }
|
540
|
+
speak(msg = ":boom: Now we are cooking with gas! :boom:")
|
541
|
+
speak(msg = images.sample)
|
542
|
+
end
|
543
|
+
}
|
544
|
+
|
545
|
+
##
|
546
|
+
#
|
547
|
+
command(:hug){
|
548
|
+
setup{ require "google-search" }
|
549
|
+
|
550
|
+
call do |*args|
|
551
|
+
|
552
|
+
images = Google::Search::Image.new(:query => 'fridayhug', :image_size => :medium)
|
553
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
554
|
+
speak(msg = "Sometimes you just need a hug...")
|
555
|
+
speak(msg = images.sample)
|
556
|
+
end
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
##
|
561
|
+
#
|
562
|
+
command(:perfectlytimed){
|
563
|
+
setup{ require "google-search" }
|
564
|
+
|
565
|
+
call do |*args|
|
566
|
+
|
567
|
+
images = Google::Search::Image.new(:query => 'perfectly+timed+photos', :image_size => :large)
|
568
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
569
|
+
speak(msg = "Shazam!")
|
570
|
+
speak(msg = images.sample)
|
571
|
+
end
|
572
|
+
}
|
573
|
+
|
574
|
+
##
|
575
|
+
#
|
576
|
+
command(:octocat){
|
577
|
+
setup{ require "google-search" }
|
578
|
+
|
579
|
+
call do |*args|
|
580
|
+
|
581
|
+
images = Google::Search::Image.new(:query => 'octocat+github', :image_size => :large)
|
582
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
583
|
+
speak(msg = "Purrrrrrrr...")
|
584
|
+
speak(msg = images.sample)
|
585
|
+
end
|
586
|
+
}
|
587
|
+
|
588
|
+
##
|
589
|
+
#
|
590
|
+
command(:goodnews){
|
591
|
+
setup{ require "google-search" }
|
592
|
+
|
593
|
+
call do |*args|
|
594
|
+
images = Google::Search::Image.new(:query => 'good+news+everyone+futurama', :image_size => :large)
|
595
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
596
|
+
speak(msg = images.sample)
|
597
|
+
speak(msg = args.join(" "))
|
598
|
+
end
|
599
|
+
}
|
600
|
+
|
601
|
+
##
|
602
|
+
#
|
603
|
+
command(:ship_it){
|
604
|
+
setup{ require "google-search" }
|
605
|
+
|
606
|
+
call do |*args|
|
607
|
+
|
608
|
+
images = Google::Search::Image.new(:query => 'github+ship+it+squirrel', :image_size => :large)
|
609
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
610
|
+
speak(msg = ":shipit: Ship it already!")
|
611
|
+
speak(msg = "#{images.sample}#.png")
|
612
|
+
end
|
613
|
+
}
|
614
|
+
|
615
|
+
##
|
616
|
+
#
|
617
|
+
command(:confession) {
|
618
|
+
call do |*args|
|
619
|
+
url = "http://dj4confessions.wordpress.com/"
|
620
|
+
html = `curl --location --silent #{ url.inspect }`
|
621
|
+
doc = Nokogiri::HTML(html)
|
622
|
+
articles = doc.xpath("//article")
|
623
|
+
# articles = doc.xpath("//*[contains(concat(' ', @class, ' '), ' hentry ')]")
|
624
|
+
latest = articles.to_a
|
625
|
+
r = rand(14)
|
626
|
+
article = latest[r]
|
627
|
+
addressee = ":pray: " + article.css('header h1').text.strip.upcase
|
628
|
+
confession = article.css('.entry-content p').text.strip
|
629
|
+
getimgsrc = article.css('.entry-content img').collect{|i| i.get_attribute('src')}
|
630
|
+
image = getimgsrc.first
|
631
|
+
speak(image) if image
|
632
|
+
speak(addressee) if addressee
|
633
|
+
speak(confession) if confession
|
634
|
+
end
|
635
|
+
}
|
636
|
+
|
637
|
+
##
|
638
|
+
#
|
639
|
+
command(:quote) {
|
640
|
+
call do |*args|
|
641
|
+
url = "http://iheartquotes.com/api/v1/random?format=html&max_lines=4&max_characters=420"
|
642
|
+
html = `curl --location --silent #{ url.inspect }`
|
643
|
+
doc = Nokogiri::HTML(html)
|
644
|
+
msg = nil
|
645
|
+
#<a target="_parent" href='http://iheartquotes.com/fortune/show/victory_uber_allies_'>Victory uber allies!</a>
|
646
|
+
doc.xpath('//div[@class="rbcontent"]/a').each do |node|
|
647
|
+
text = node.text
|
648
|
+
msg = text
|
649
|
+
end
|
650
|
+
speak(msg) if msg
|
651
|
+
end
|
652
|
+
}
|
653
|
+
|
654
|
+
##
|
655
|
+
#
|
656
|
+
command(:peter){
|
657
|
+
setup{ require "google-search" }
|
658
|
+
|
659
|
+
call do |*args|
|
660
|
+
|
661
|
+
images = Google::Search::Image.new(:query => 'cheetara', :image_size => :medium)
|
662
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
663
|
+
speak(msg = "<3 <3 <3 first crush OMG!!1!")
|
664
|
+
speak(msg = images.sample)
|
665
|
+
end
|
666
|
+
}
|
667
|
+
|
668
|
+
##
|
669
|
+
#
|
670
|
+
command(:movime){
|
671
|
+
setup{ require "google-search" }
|
672
|
+
|
673
|
+
call do |*args|
|
674
|
+
|
675
|
+
images = Google::Search::Image.new(:query => 'bovine', :image_size => :medium)
|
676
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
677
|
+
speak(msg = "Rhymes with Bovine")
|
678
|
+
speak(msg = images.sample)
|
679
|
+
end
|
680
|
+
}
|
681
|
+
|
682
|
+
##
|
683
|
+
#
|
684
|
+
command(:ecard){
|
685
|
+
setup{ require "google-search" }
|
686
|
+
|
687
|
+
call do |*args|
|
688
|
+
|
689
|
+
images = Google::Search::Image.new(:query => 'ecard+site:someecards.com', :image_size => :large)
|
690
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
691
|
+
speak(msg = "I was just thinking of you and...")
|
692
|
+
speak(msg = images.sample)
|
693
|
+
end
|
694
|
+
}
|
695
|
+
|
696
|
+
##
|
697
|
+
#
|
698
|
+
command(:yoda){
|
699
|
+
call do |*args|
|
700
|
+
phrase = args.join(' ').strip
|
701
|
+
url = 'http://www.yodaspeak.co.uk/index.php'
|
702
|
+
error = nil
|
703
|
+
|
704
|
+
if phrase.empty?
|
705
|
+
phrase = most_recent_comment
|
706
|
+
end
|
707
|
+
|
708
|
+
if phrase
|
709
|
+
agent = Mechanize.new
|
710
|
+
agent.open_timeout = 240
|
711
|
+
agent.read_timeout = 240
|
712
|
+
|
713
|
+
catch(:done) do
|
714
|
+
2.times do
|
715
|
+
begin
|
716
|
+
page = agent.get(url)
|
717
|
+
|
718
|
+
form = page.forms.detect{|form| form.fields.detect{|field| field.name == 'YodaMe'}}
|
719
|
+
|
720
|
+
form['YodaMe'] = phrase
|
721
|
+
|
722
|
+
result = form.submit
|
723
|
+
|
724
|
+
yoda_speak = result.search('textarea[name=YodaSpeak]').first.text
|
725
|
+
|
726
|
+
speak("Yoda: #{ yoda_speak }")
|
727
|
+
throw(:done)
|
728
|
+
rescue Object
|
729
|
+
next
|
730
|
+
end
|
731
|
+
end
|
732
|
+
end
|
733
|
+
end
|
734
|
+
end
|
735
|
+
}
|
736
|
+
|
737
|
+
##
|
738
|
+
#
|
739
|
+
command(:poop){
|
740
|
+
setup{ require "google-search" }
|
741
|
+
|
742
|
+
call do |*args|
|
743
|
+
images = Google::Search::Image.new(:query => 'poop', :image_size => :large)
|
744
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
745
|
+
speak(msg = ":poop: coffee anyone?")
|
746
|
+
speak(msg = images.sample)
|
747
|
+
end
|
748
|
+
}
|
749
|
+
|
750
|
+
command(:itshappening){
|
751
|
+
|
752
|
+
call do |*args|
|
753
|
+
speak(msg = "What's happening?")
|
754
|
+
speak(msg = "http://i.imgur.com/vwMin.gif")
|
755
|
+
end
|
756
|
+
}
|
757
|
+
|
758
|
+
command(:willis){
|
759
|
+
call do |*args|
|
760
|
+
speak(msg = "Whatchu talkin bout Willis?")
|
761
|
+
speak(msg = "http://media.tumblr.com/tumblr_lpzmqsohLJ1qi7mx3.gif")
|
762
|
+
end
|
763
|
+
}
|
764
|
+
|
765
|
+
command(:miles){
|
766
|
+
call do |*args|
|
767
|
+
images = Google::Search::Image.new(:query => 'miles matthias', :image_size => :large)
|
768
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
769
|
+
speak(msg = images.sample)
|
770
|
+
end
|
771
|
+
}
|
772
|
+
|
773
|
+
command(:lolcat){
|
774
|
+
call do |*args|
|
775
|
+
images = Google::Search::Image.new(:query => 'lolcat', :image_size => :large)
|
776
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
777
|
+
speak(msg = images.sample)
|
778
|
+
end
|
779
|
+
}
|
780
|
+
|
781
|
+
command(:harlemshake){
|
782
|
+
call do |*args|
|
783
|
+
images = Google::Search::Image.new(:query => 'harlem shake gif', :image_size => :large)
|
784
|
+
images = images.map{|result| result.uri}.uniq.sort_by{ rand }
|
785
|
+
speak(msg = images.sample)
|
786
|
+
end
|
787
|
+
}
|
788
|
+
|
789
|
+
command(:lunch){
|
790
|
+
help "Get lunch recommendations near the dojo4 office"
|
791
|
+
|
792
|
+
call do |*args|
|
793
|
+
restaurants = Google::Search::Local.new(:query => 'lunch near 2030 17th Street Boulder, CO 80302')
|
794
|
+
restaurants = restaurants.map{|result| result.title}.uniq.sort_by{ rand }
|
795
|
+
speak(msg = "Why not try...")
|
796
|
+
speak(msg = restaurants.sample)
|
797
|
+
speak(msg = " instead of crap.")
|
798
|
+
end
|
799
|
+
}
|
89
800
|
}
|
90
801
|
|