Last active
October 5, 2015 02:22
-
-
Save syusui-s/2070646 to your computer and use it in GitHub Desktop.
TLに特定のユーザーのツイートが流れてきたら、ユーザー名とツイートを通知します。
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(:update_notify) do | |
settings "ポスト通知" do | |
boolean "通知", :update_notify_bool | |
fileselect("通知音", :update_notify_sound, "skin/data/sounds") | |
input "ユーザー", :update_notify_users | |
end | |
onboot do | |
UserConfig[:boot_time] = Time.now.to_s; | |
end | |
onupdate do |psrc, mesgs| | |
if UserConfig[:update_notify_bool] && !UserConfig[:update_notify_users].empty? then | |
UserConfig[:update_notify_users].split(",").each { |usr| | |
mesgs.each { |m| | |
# メッセージのユーザーが一致し、自分の投稿ではなく、リプライやメンションでもなく、起動後にツイートされたものであれば、通知します | |
if (m.idname == usr) && (m.idname != Post.primary.user) && !("#{m.message}".index("@")) && (m[:created].to_s<=>UserConfig[:boot_time])>=0 then | |
Plugin.call(:popup_notify, User::findbyidname(m.message.user.idname),"update:#{m.message}") | |
Plugin.call(:play_sound, UserConfig[:update_notify_sound]) if !UserConfig[:update_notify_sound].empty? | |
end | |
} | |
} | |
end | |
end | |
end |
現在、終了時に通知をオフにしておかないと、次回起動時に通知が大量に発生してしまいます。終了時にわすれないようにしてください。
この問題を修正しました
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
現在、終了時に通知をオフにしておかないと、次回起動時に通知が大量に発生してしまいます。終了時にわすれないようにしてください。