|
|
|
@ -6,6 +6,23 @@ class WechatsController < ActionController::Base
|
|
|
|
|
|
|
|
|
|
# default text responder when no other match
|
|
|
|
|
on :text do |request, content|
|
|
|
|
|
if content.size == 6
|
|
|
|
|
#邀请码
|
|
|
|
|
if join_class(content)
|
|
|
|
|
root_url = "http://wechat.trustie.net"
|
|
|
|
|
|
|
|
|
|
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
|
|
|
|
|
content: "课程名称: 数据结构\n班级名称: 数据结构A班\n任课老师: 尹刚\n进入班级,和小伙伴愉快的学习吧!0"} }
|
|
|
|
|
request.reply.news(news) do |article, n, index| # article is return object
|
|
|
|
|
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{root_url+'/wechat/user_activities#myclass'}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
|
|
|
|
|
pic_url = "#{Setting.protocol}://#{Setting.host_name}/images/class.jpg"
|
|
|
|
|
article.item title: "#{n[:title]}",
|
|
|
|
|
description: n[:content],
|
|
|
|
|
pic_url: pic_url,
|
|
|
|
|
url: url
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
request.reply.text "您的意见已收到,感谢您的反馈!" # Just echo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -133,7 +150,7 @@ class WechatsController < ActionController::Base
|
|
|
|
|
unless uw
|
|
|
|
|
sendBind(request)
|
|
|
|
|
else
|
|
|
|
|
request.reply.text "请直接回复班级邀请码 (不区分大小写):"
|
|
|
|
|
request.reply.text "请直接回复6位班级邀请码\n(不区分大小写):"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -165,6 +182,10 @@ class WechatsController < ActionController::Base
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def join_class(content)
|
|
|
|
|
true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
### controller method
|
|
|
|
|
module Controllers
|
|
|
|
|
def get_open_id
|
|
|
|
|