-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsnapr_runner.rb
79 lines (64 loc) · 1.66 KB
/
snapr_runner.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'lolcommits'
require 'catpix'
require 'io/console'
require_relative "snapr_message"
require_relative 'snapr_receiver'
require_relative 'snapr_sender'
# HACK LOLCOMMITS: We have to provide lolcommits with a debug method
def debug(s)
end
# HACK CATPIX inject a way into catpix to get the image
module Catpix
@@raw_img = ""
def self.raw_img
@@raw_img
end
# HACK: override the puts method that is used to output the image row by row
# and keep the ressult in @@raw_image
def self.puts(s)
@@raw_img += s + "\n"
$stdout.puts s
end
end
class SnaprRunner
def self.capture_image
end
def self.watch
SnaprReceiver.run
end
def self.send(msg, user = "")
#
# use LOLCommits to take a webcam photo and generate an image
#
# save images to current folder
lolcommits_configuration = Lolcommits::Configuration.new(loldir: "./")
lolcommits_options = {
capture_delay: 0,
capture_stealth: false,
capture_animate: 0,
config: lolcommits_configuration,
message: msg,
sha: user
}
# run lolcommits
runner = Lolcommits::Runner.new(lolcommits_options)
runner.run
filename = runner.main_image
#
# use catpix to load the image as ASCII
#
# load the image with CatPix
Catpix::print_image filename,
:limit_x => 0,
:limit_y => 0.8,
:center_x => true,
:center_y => true,
:bg => "black",
:bg_fill => true
# Broadcast the image on the network
puts "Sending Image '#{filename}'..."
msg = SnaprMessage.new(Catpix.raw_img)
SnaprSender.send(msg)
puts "Done. Support https://youthoffthestreets.com.au"
end
end