diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index fd3050e05..880b5d6de 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -54,6 +54,14 @@ class WechatsController < ActionController::Base end end + on :click, with: 'MY_NEWS' do |request, key| + + news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + request.reply.news(news) do |article, n, index| # article is return object + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + end + end + # When user click the menu button on :click, with: 'BOOK_LUNCH' do |request, key| request.reply.text "User: #{request[:FromUserName]} click #{key}"