Class: Lita::Handlers::Hello
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Hello
- Extended by:
- Lita::Handler::HTTPRouter
- Defined in:
- lib/lita/handlers/lita-hello.rb
Instance Method Summary collapse
- #example(request, response2) ⇒ Object
- #hyper(response) ⇒ Object
- #imagery(response) ⇒ Object
- #index(response) ⇒ Object
Instance Method Details
#example(request, response2) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lita/handlers/lita-hello.rb', line 11 def example(request,response2) `ruby /home/lita/test_lines.rb` `rsvg-convert /tmp/sq_linechart.svg -o /home/lita/robot/test.png` file=File.read("/home/lita/robot/test.png") response2["Content-Type"] = "image/png" response2.write(file) response2.finish p "/kkr#{$id}.png" end |
#hyper(response) ⇒ Object
58 59 60 |
# File 'lib/lita/handlers/lita-hello.rb', line 58 def hyper(response) response.reply("ihello") end |
#imagery(response) ⇒ Object
50 51 52 53 54 |
# File 'lib/lita/handlers/lita-hello.rb', line 50 def imagery(response) response.reply("http://139.59.66.54:9000/kkr#{$id}.png") $id=rand(100) end |
#index(response) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lita/handlers/lita-hello.rb', line 28 def index(response) if response.matches[0]=="hey" and ! response.matches[0].is_a?Array response.reply("Please enter hey <counter_group_id>") end conn = "tcp://demo.trisul.org:12006" tint = TRP::TimeInterval.new() tint.to= TRP::Timestamp.new({:tv_sec=>Time.now.tv_sec}) tint.from= TRP::Timestamp.new() tint.from.tv_sec = tint.to.tv_sec - 3600 req = TrisulRP::Protocol.mk_request(TRP::Message::Command::COUNTER_GROUP_TOPPER_REQUEST,{:counter_group=>response.matches[0][0],:meter=>0,:maxitems=>2,time_interval:tint}) TrisulRP::Protocol.get_response_zmq(conn,req) do |resp| resp.keys.each do |key| response.reply("#{key.label}=#{key.metric*300}") end end end |