-
Notifications
You must be signed in to change notification settings - Fork 2
/
manual_faye_message_trigger.rb
45 lines (34 loc) · 1.04 KB
/
manual_faye_message_trigger.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
#Requires
require "net/http"
require "json"
#Configure channel and message here
#mensaje = '> Manualmente enviado por FAYE'
canal = 'admin'
#end of config xD
#mensaje_real = "$('#irc_area').append(\"#{mensaje}\");"
# Procedure stuff
FAYE_TOKEN = 'miauhash'
FAYE_CHANNEL_PREFIX = '/messagebox/'
FAYE_DEFAULT_CHANNEL = 'lobby'
FAYE_SERVER_PORT = 9292
FAYE_MOUNT_POINT = '/faye'
FAYE_SERVER_URL = "http://localhost:#{FAYE_SERVER_PORT}#{FAYE_MOUNT_POINT}"
uri = URI.parse(FAYE_SERVER_URL)
###################33 OVERRIDE!!!!!
canal = FAYE_DEFAULT_CHANNEL
canal = 'device_1' ################3 OVERRIDE
channel = "#{FAYE_CHANNEL_PREFIX}#{canal}"
#end
#Init
puts 'Initiating..'
puts "Posting to #{FAYE_SERVER_URL}"
puts " in channel #{channel}"
mensaje = ''
while mensaje != "exit\n"
mensaje = $stdin.gets
message = {:channel => channel, :data => {:message => mensaje, :what => 'lol'}, :ext => {:auth_token => FAYE_TOKEN}}
response = Net::HTTP.post_form(uri, :message => message.to_json)
puts "Server responded with> #{response}"
end
puts 'Done'
#END xD