-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
41 lines (35 loc) · 1.01 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'bundler/gem_tasks'
require 'wechat_bot'
require 'awesome_print'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'rubocop/rake_task'
RuboCop::RakeTask.new
task :default => [:rubocop, :spec]
desc 'Run a sample wechat bot'
task :bot do
bot = WeChat::Bot.new do
configure do |c|
c.verbose = true
end
on :message do |m|
case m.kind
when WeChat::Bot::Message::Kind::Text
m.reply m.message
when WeChat::Bot::Message::Kind::Emoticon
if m.media_id.to_s.empty?
m.reply "微信商店的表情哪有私藏的好用!"
else
m.reply m.media_id, type: :emoticon
end
when WeChat::Bot::Message::Kind::ShareCard
m.reply "标题:#{m.meta_data.title}\n描述:#{m.meta_data.description}\n#{m.meta_data.link}"
when WeChat::Bot::Message::Kind::System
m.reply "系统消息:#{m.message}"
else
m.reply "[#{m.kind}]消息:#{m.message}"
end
end
end
bot.start
end