添加菜单事件

This commit is contained in:
guange 2016-01-19 11:51:26 +08:00
parent 9f667588c4
commit 40047ff818
1 changed files with 8 additions and 0 deletions

View File

@ -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}"