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
17 18 19 20 21 22 23 24 25 |
# File 'lib/lita/handlers/lita-hello.rb', line 17 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
64 65 66 |
# File 'lib/lita/handlers/lita-hello.rb', line 64 def hyper(response) response.reply("ihello") end |
#imagery(response) ⇒ Object
56 57 58 59 60 |
# File 'lib/lita/handlers/lita-hello.rb', line 56 def imagery(response) response.reply("http://#{config.lita_public_ip}:9000/kkr#{$id}.png") $id=rand(100) end |
#index(response) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lita/handlers/lita-hello.rb', line 34 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(config.query_endpoint,req) do |resp| resp.keys.each do |key| response.reply("#{key.label}=#{key.metric*300}") end end end |