Created
September 17, 2016 06:21
-
-
Save Na0ki/a672dd3c525fc4673cd0d85260f90a4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
Plugin.create(:ahiru_yakuna) do | |
DEFINED_TIME = Time.new.freeze | |
criminals = Set.new | |
あひる焼き = %w(burned\ duck) | |
filter_filter_stream_track do |watching| | |
p あひる焼き | |
[(watching.split(','.freeze) + あひる焼き).join(',')] | |
end | |
def select_reply(msg, time) | |
# 言語ごとに使用辞書を変える | |
if msg =~ /burned\ duck/ | |
reply = "test"+rand(1000).to_s | |
return reply | |
end | |
end | |
on_appear do |ms| | |
ms.each do |m| | |
if m.to_s =~ Regexp.union(あひる焼き) and m[:created] > DEFINED_TIME and !m.retweet? and !criminals.include?(m.id) | |
criminals << m.id | |
now = Time.now.hour | |
# select reply dic & get sample reply | |
reply = select_reply(m.to_s, now) | |
puts reply | |
# send reply & fav | |
Service.primary.post(:message => "@#{m.user.idname} #{reply}", :replyto => m) | |
m.favorite(true) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment