Skip to content

Commit ec6e07a

Browse files
committed
init repository
0 parents  commit ec6e07a

20 files changed

+249
-0
lines changed

.rbenv-gemsets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wechat

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--color

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.0.0-p247

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source "https://rubygems.org"
2+
ruby "2.0.0"
3+
gem 'sinatra', '1.1.0'
4+
gem 'nokogiri'
5+
6+
group :test do
7+
gem 'rspec'
8+
end

Gemfile.lock

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
diff-lcs (1.2.4)
5+
mini_portile (0.5.1)
6+
nokogiri (1.6.0)
7+
mini_portile (~> 0.5.0)
8+
rack (1.5.2)
9+
rspec (2.14.1)
10+
rspec-core (~> 2.14.0)
11+
rspec-expectations (~> 2.14.0)
12+
rspec-mocks (~> 2.14.0)
13+
rspec-core (2.14.5)
14+
rspec-expectations (2.14.2)
15+
diff-lcs (>= 1.1.3, < 2.0)
16+
rspec-mocks (2.14.3)
17+
sinatra (1.1.0)
18+
rack (~> 1.1)
19+
tilt (~> 1.1)
20+
tilt (1.4.1)
21+
22+
PLATFORMS
23+
ruby
24+
25+
DEPENDENCIES
26+
nokogiri
27+
rspec
28+
sinatra (= 1.1.0)

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bundle exec ruby web.rb -p $PORT

config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
wechat_id: your_wechat_id
2+
help_message: your help message
3+
welcome_message:
4+
title: 微信公众账户开发指南
5+
picture: www.test.com
6+
description: 欢迎您关注微信公众账户开发指南
7+
link: linkedme.in

lib/content_retriever.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'net/http'
2+
require "json"
3+
4+
class ContentRetriver
5+
def self.retrieve targeting
6+
{
7+
total: 1,
8+
contents: [{
9+
title: 'fake title',
10+
description: 'fake description',
11+
picture: 'http://weixin.qq.com/zh_CN/htmledition/images/weixin/weixin_logo178fb4.png',
12+
url: 'http://linkedme.in/2013/09/25/turoial-to-be-wechat-public-account-developer/'}]
13+
}
14+
end
15+
end

lib/dispatcher.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Dispatcher
2+
def self.dispatch message_info
3+
return :help if not message_info[:content].nil? and message_info[:content].include? 'help'
4+
return :welcome if not message_info[:event].nil? and message_info[:event] == :subscribe
5+
:picture_message
6+
end
7+
end

lib/message_info.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class MessageInfo
2+
attr_reader :options
3+
4+
def initialize options
5+
@options = options
6+
end
7+
8+
def [] option
9+
@options[option]
10+
end
11+
end

0 commit comments

Comments
 (0)